Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed and enabled readability-avoid-const-params-in-decls clang-tidy warnings #4861

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ Checks: >
-performance-noexcept-swap,
-portability-simd-intrinsics,
-portability-std-allocator-const,
-readability-avoid-const-params-in-decls,
-readability-avoid-nested-conditional-operator,
-readability-braces-around-statements,
-readability-container-data-pointer,
Expand Down
1 change: 0 additions & 1 deletion clang-tidy.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ We run this separately via `clang-include-cleaner` in the `iwyu.yml` workflow as
`bugprone-branch-clone`<br/>
`modernize-return-braced-init-list`<br/>
`misc-throw-by-value-catch-by-reference`<br/>
`readability-avoid-const-params-in-decls`<br/>
`bugprone-signed-char-misuse`<br/>
`concurrency-mt-unsafe`<br/>
`misc-use-anonymous-namespace`<br/>
Expand Down
2 changes: 1 addition & 1 deletion cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace {
/** xml output of errors */
void reportErr(const ErrorMessage &msg) override;

void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override;
void reportProgress(const std::string &filename, const char stage[], std::size_t value) override;

/**
* Pointer to current settings; set while check() is running for reportError().
Expand Down
8 changes: 4 additions & 4 deletions gui/applicationlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class ApplicationList : public QObject {
* @param index Index of the application whose name to get
* @return Name of the application
*/
const Application& getApplication(const int index) const;
Application& getApplication(const int index);
const Application& getApplication(int index) const;
Application& getApplication(int index);

/**
* @brief Return the default application.
Expand All @@ -88,13 +88,13 @@ class ApplicationList : public QObject {
*
* @param index Index of the application to remove.
*/
void removeApplication(const int index);
void removeApplication(int index);

/**
* @brief Set application as default application.
* @param index Index of the application to make the default one
*/
void setDefault(const int index);
void setDefault(int index);

/**
* @brief Remove all applications from this list and copy all applications from
Expand Down
6 changes: 3 additions & 3 deletions gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private slots:
* @param checkLibrary Flag to indicate if the library should be checked.
* @param checkConfiguration Flag to indicate if the configuration should be checked.
*/
void analyzeProject(const ProjectFile *projectFile, const bool checkLibrary = false, const bool checkConfiguration = false);
void analyzeProject(const ProjectFile *projectFile, bool checkLibrary = false, bool checkConfiguration = false);

/**
* @brief Set current language
Expand Down Expand Up @@ -304,7 +304,7 @@ private slots:
* @param checkLibrary Flag to indicate if library should be checked
* @param checkConfiguration Flag to indicate if the configuration should be checked.
*/
void doAnalyzeProject(ImportProject p, const bool checkLibrary = false, const bool checkConfiguration = false);
void doAnalyzeProject(ImportProject p, bool checkLibrary = false, bool checkConfiguration = false);

/**
* @brief Analyze all files specified in parameter files
Expand All @@ -313,7 +313,7 @@ private slots:
* @param checkLibrary Flag to indicate if library should be checked
* @param checkConfiguration Flag to indicate if the configuration should be checked.
*/
void doAnalyzeFiles(const QStringList &files, const bool checkLibrary = false, const bool checkConfiguration = false);
void doAnalyzeFiles(const QStringList &files, bool checkLibrary = false, bool checkConfiguration = false);

/**
* @brief Get our default cppcheck settings and read project file.
Expand Down
2 changes: 1 addition & 1 deletion gui/resultstree.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ protected slots:
*/
QStandardItem *addBacktraceFiles(QStandardItem *parent,
const ErrorLine &item,
const bool hide,
bool hide,
const QString &icon,
bool childOfMessage);

Expand Down
2 changes: 1 addition & 1 deletion gui/threadhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ThreadHandler : public QObject {
* @brief Set the number of threads to use
* @param count The number of threads to use
*/
void setThreadCount(const int count);
void setThreadCount(int count);

/**
* @brief Initialize the threads (connect all signals to resultsview's slots)
Expand Down
22 changes: 11 additions & 11 deletions lib/astutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ const Token* findParent(const Token* tok, const TFunc& pred)
return parent;
}

const Token* findExpression(const nonneg int exprid,
const Token* findExpression(nonneg int exprid,
const Token* start,
const Token* end,
const std::function<bool(const Token*)>& pred);
const Token* findExpression(const Token* start, const nonneg int exprid);
const Token* findExpression(const Token* start, nonneg int exprid);

template<class T, class OuputIterator, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
void astFlattenCopy(T* tok, const char* op, OuputIterator out, nonneg int depth = 100)
Expand Down Expand Up @@ -265,7 +265,7 @@ const Token* followReferences(const Token* tok, ErrorPath* errors = nullptr);

CPPCHECKLIB bool isSameExpression(bool macro, const Token *tok1, const Token *tok2, const Settings& settings, bool pure, bool followVar, ErrorPath* errors=nullptr);

bool isEqualKnownValue(const Token * const tok1, const Token * const tok2);
bool isEqualKnownValue(const Token * tok1, const Token * tok2);

bool isStructuredBindingVariable(const Variable* var);

Expand All @@ -274,7 +274,7 @@ const Token* isInLoopCondition(const Token* tok);
/**
* Is token used as boolean, that is to say cast to a bool, or used as a condition in a if/while/for
*/
CPPCHECKLIB bool isUsedAsBool(const Token* const tok, const Settings& settings);
CPPCHECKLIB bool isUsedAsBool(const Token* tok, const Settings& settings);

/**
* Are the tokens' flags equal?
Expand All @@ -289,9 +289,9 @@ bool compareTokenFlags(const Token* tok1, const Token* tok2, bool macro);
* @param settings settings
* @param pure boolean
*/
bool isOppositeCond(bool isNot, const Token * const cond1, const Token * const cond2, const Settings& settings, bool pure, bool followVar, ErrorPath* errors=nullptr);
bool isOppositeCond(bool isNot, const Token * cond1, const Token * cond2, const Settings& settings, bool pure, bool followVar, ErrorPath* errors=nullptr);

bool isOppositeExpression(const Token * const tok1, const Token * const tok2, const Settings& settings, bool pure, bool followVar, ErrorPath* errors=nullptr);
bool isOppositeExpression(const Token * tok1, const Token * tok2, const Settings& settings, bool pure, bool followVar, ErrorPath* errors=nullptr);

bool isConstFunctionCall(const Token* ftok, const Library& library);

Expand All @@ -304,7 +304,7 @@ bool isUniqueExpression(const Token* tok);
bool isEscapeFunction(const Token* ftok, const Library* library);

/** Is scope a return scope (scope will unconditionally return) */
CPPCHECKLIB bool isReturnScope(const Token* const endToken,
CPPCHECKLIB bool isReturnScope(const Token* endToken,
const Library& library,
const Token** unknownFunc = nullptr,
bool functionScope = false);
Expand Down Expand Up @@ -342,8 +342,8 @@ bool isVariableChangedByFunctionCall(const Token *tok, int indirect, nonneg int
CPPCHECKLIB bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Settings &settings, bool *inconclusive);

/** Is variable changed in block of code? */
CPPCHECKLIB bool isVariableChanged(const Token *start, const Token *end, const nonneg int exprid, bool globalvar, const Settings &settings, int depth = 20);
bool isVariableChanged(const Token *start, const Token *end, int indirect, const nonneg int exprid, bool globalvar, const Settings &settings, int depth = 20);
CPPCHECKLIB bool isVariableChanged(const Token *start, const Token *end, nonneg int exprid, bool globalvar, const Settings &settings, int depth = 20);
bool isVariableChanged(const Token *start, const Token *end, int indirect, nonneg int exprid, bool globalvar, const Settings &settings, int depth = 20);

bool isVariableChanged(const Token *tok, int indirect, const Settings &settings, int depth = 20);

Expand All @@ -357,8 +357,8 @@ bool isVariablesChanged(const Token* start,

bool isThisChanged(const Token* tok, int indirect, const Settings& settings);

const Token* findVariableChanged(const Token *start, const Token *end, int indirect, const nonneg int exprid, bool globalvar, const Settings &settings, int depth = 20);
Token* findVariableChanged(Token *start, const Token *end, int indirect, const nonneg int exprid, bool globalvar, const Settings &settings, int depth = 20);
const Token* findVariableChanged(const Token *start, const Token *end, int indirect, nonneg int exprid, bool globalvar, const Settings &settings, int depth = 20);
Token* findVariableChanged(Token *start, const Token *end, int indirect, nonneg int exprid, bool globalvar, const Settings &settings, int depth = 20);

CPPCHECKLIB const Token* findExpressionChanged(const Token* expr,
const Token* start,
Expand Down
16 changes: 8 additions & 8 deletions lib/checkcondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ class CPPCHECKLIB CheckCondition : public Check {
void assignIf();

/** parse scopes recursively */
bool assignIfParseScope(const Token * const assignTok,
const Token * const startTok,
const nonneg int varid,
const bool islocal,
const char bitop,
const MathLib::bigint num);
bool assignIfParseScope(const Token * assignTok,
const Token * startTok,
nonneg int varid,
bool islocal,
char bitop,
MathLib::bigint num);

/** check bitmask using | instead of & */
void checkBadBitmaskCheck();
Expand Down Expand Up @@ -133,9 +133,9 @@ class CPPCHECKLIB CheckCondition : public Check {
std::set<const Token*> mCondDiags;
bool diag(const Token* tok, bool insert=true);
bool isAliased(const std::set<int> &vars) const;
bool isOverlappingCond(const Token * const cond1, const Token * const cond2, bool pure) const;
bool isOverlappingCond(const Token * cond1, const Token * cond2, bool pure) const;
void assignIfError(const Token *tok1, const Token *tok2, const std::string &condition, bool result);
void mismatchingBitAndError(const Token *tok1, const MathLib::bigint num1, const Token *tok2, const MathLib::bigint num2);
void mismatchingBitAndError(const Token *tok1, MathLib::bigint num1, const Token *tok2, MathLib::bigint num2);
void badBitmaskCheckError(const Token *tok, bool isNoOp = false);
void comparisonError(const Token *tok,
const std::string &bitop,
Expand Down
10 changes: 5 additions & 5 deletions lib/checkexceptionsafety.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ class CPPCHECKLIB CheckExceptionSafety : public Check {
void rethrowNoCurrentException();

/** Don't throw exceptions in destructors */
void destructorsError(const Token * const tok, const std::string &className);
void deallocThrowError(const Token * const tok, const std::string &varname);
void rethrowCopyError(const Token * const tok, const std::string &varname);
void destructorsError(const Token * tok, const std::string &className);
void deallocThrowError(const Token * tok, const std::string &varname);
void rethrowCopyError(const Token * tok, const std::string &varname);
void catchExceptionByValueError(const Token *tok);
void noexceptThrowError(const Token * const tok);
void noexceptThrowError(const Token * tok);
/** Missing exception specification */
void unhandledExceptionSpecificationError(const Token * const tok1, const Token * const tok2, const std::string & funcname);
void unhandledExceptionSpecificationError(const Token * tok1, const Token * tok2, const std::string & funcname);
/** Rethrow without currently handled exception */
void rethrowNoCurrentExceptionError(const Token *tok);

Expand Down
2 changes: 1 addition & 1 deletion lib/checkfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CPPCHECKLIB CheckFunctions : public Check {
void invalidFunctionArgStrError(const Token *tok, const std::string &functionName, nonneg int argnr);
void ignoredReturnValueError(const Token* tok, const std::string& function);
void ignoredReturnErrorCode(const Token* tok, const std::string& function);
void mathfunctionCallWarning(const Token *tok, const nonneg int numParam = 1);
void mathfunctionCallWarning(const Token *tok, nonneg int numParam = 1);
void mathfunctionCallWarning(const Token *tok, const std::string& oldexp, const std::string& newexp);
void memsetZeroBytesError(const Token *tok);
void memsetFloatError(const Token *tok, const std::string &var_value);
Expand Down
10 changes: 5 additions & 5 deletions lib/checkio.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ class CPPCHECKLIB CheckIO : public Check {
bool isCPP{};
};

void checkFormatString(const Token * const tok,
const Token * const formatStringTok,
const Token * argListTok,
const bool scan,
const bool scanf_s);
void checkFormatString(const Token * tok,
const Token * formatStringTok,
const Token * argListTok,
bool scan,
bool scanf_s);

// Reporting errors..
void coutCerrMisusageError(const Token* tok, const std::string& streamName);
Expand Down
6 changes: 3 additions & 3 deletions lib/checkleakautovar.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check {
void check();

/** check for leaks in a function scope */
bool checkScope(const Token * const startToken,
bool checkScope(const Token * startToken,
VarInfo &varInfo,
std::set<int> notzero,
nonneg int recursiveCount);
Expand All @@ -134,7 +134,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check {
* @param varInfo Variable info
* @return next token to process (if no other checks needed for this token). NULL if other checks could be performed.
*/
const Token * checkTokenInsideExpression(const Token * const tok, VarInfo &varInfo, bool inFuncCall = false);
const Token * checkTokenInsideExpression(const Token * tok, VarInfo &varInfo, bool inFuncCall = false);

/** parse function call */
void functionCall(const Token *tokName, const Token *tokOpeningPar, VarInfo &varInfo, const VarInfo::AllocInfo& allocation, const Library::AllocFunc* af);
Expand All @@ -146,7 +146,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check {
void changeAllocStatusIfRealloc(std::map<int, VarInfo::AllocInfo> &alloctype, const Token *fTok, const Token *retTok) const;

/** return. either "return" or end of variable scope is seen */
void ret(const Token *tok, VarInfo &varInfo, const bool isEndOfScope = false);
void ret(const Token *tok, VarInfo &varInfo, bool isEndOfScope = false);

/** if variable is allocated then there is a leak */
void leakIfAllocated(const Token *vartok, const VarInfo &varInfo);
Expand Down
2 changes: 1 addition & 1 deletion lib/checkmemoryleak.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class CPPCHECKLIB CheckMemoryLeakStructMember : public Check, private CheckMemor
/** Is local variable allocated with malloc? */
bool isMalloc(const Variable *variable) const;

void checkStructVariable(const Variable* const variable) const;
void checkStructVariable(const Variable* variable) const;

void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const override {}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkother.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class CPPCHECKLIB CheckOther : public Check {
void overlappingWriteFunction(const Token *tok);

// Error messages..
void checkComparisonFunctionIsAlwaysTrueOrFalseError(const Token* tok, const std::string &functionName, const std::string &varName, const bool result);
void checkComparisonFunctionIsAlwaysTrueOrFalseError(const Token* tok, const std::string &functionName, const std::string &varName, bool result);
void checkCastIntToCharAndBackError(const Token *tok, const std::string &strFunctionName);
void clarifyCalculationError(const Token *tok, const std::string &op);
void clarifyStatementError(const Token* tok);
Expand Down
2 changes: 1 addition & 1 deletion lib/checktype.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CPPCHECKLIB CheckType : public Check {
void tooBigBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits);
void tooBigSignedBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits);
void integerOverflowError(const Token *tok, const ValueFlow::Value &value);
void signConversionError(const Token *tok, const ValueFlow::Value *negativeValue, const bool constvalue);
void signConversionError(const Token *tok, const ValueFlow::Value *negativeValue, bool constvalue);
void longCastAssignError(const Token *tok, const ValueType* src = nullptr, const ValueType* tgt = nullptr);
void longCastReturnError(const Token *tok, const ValueType* src = nullptr, const ValueType* tgt = nullptr);
void floatToIntegerOverflowError(const Token *tok, const ValueFlow::Value &value);
Expand Down
8 changes: 4 additions & 4 deletions lib/checkuninitvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ class CPPCHECKLIB CheckUninitVar : public Check {
void check();
void checkScope(const Scope* scope, const std::set<std::string> &arrayTypeDefs);
void checkStruct(const Token *tok, const Variable &structvar);
bool checkScopeForVariable(const Token *tok, const Variable& var, bool* const possibleInit, bool* const noreturn, Alloc* const alloc, const std::string &membervar, std::map<nonneg int, VariableValue>& variableValue);
const Token* checkExpr(const Token* tok, const Variable& var, const Alloc alloc, bool known, bool* bailout = nullptr) const;
bool checkScopeForVariable(const Token *tok, const Variable& var, bool* possibleInit, bool* noreturn, Alloc* alloc, const std::string &membervar, std::map<nonneg int, VariableValue>& variableValue);
const Token* checkExpr(const Token* tok, const Variable& var, Alloc alloc, bool known, bool* bailout = nullptr) const;
bool checkIfForWhileHead(const Token *startparentheses, const Variable& var, bool suppressErrors, bool isuninit, Alloc alloc, const std::string &membervar);
bool checkLoopBody(const Token *tok, const Variable& var, const Alloc alloc, const std::string &membervar, const bool suppressErrors);
const Token* checkLoopBodyRecursive(const Token *start, const Variable& var, const Alloc alloc, const std::string &membervar, bool &bailout) const;
bool checkLoopBody(const Token *tok, const Variable& var, Alloc alloc, const std::string &membervar, bool suppressErrors);
const Token* checkLoopBodyRecursive(const Token *start, const Variable& var, Alloc alloc, const std::string &membervar, bool &bailout) const;
void checkRhs(const Token *tok, const Variable &var, Alloc alloc, nonneg int number_of_if, const std::string &membervar);
static int isFunctionParUsage(const Token *vartok, const Library &library, bool pointer, Alloc alloc, int indirect = 0);
int isFunctionParUsage(const Token *vartok, bool pointer, Alloc alloc, int indirect = 0) const;
Expand Down
2 changes: 1 addition & 1 deletion lib/checkunusedvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CPPCHECKLIB CheckUnusedVar : public Check {
}

/** @brief %Check for unused function variables */
void checkFunctionVariableUsage_iterateScopes(const Scope* const scope, Variables& variables);
void checkFunctionVariableUsage_iterateScopes(const Scope* scope, Variables& variables);
void checkFunctionVariableUsage();

/** @brief %Check that all struct members are used */
Expand Down
Loading
Loading