From 601156bce826addd5a6cf3030769a01035a684b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 16 Aug 2024 13:21:20 +0200 Subject: [PATCH] fixed and enabled `readability-avoid-const-params-in-decls` clang-tidy warnings (#4861) --- .clang-tidy | 1 - clang-tidy.md | 1 - cli/cppcheckexecutor.cpp | 2 +- gui/applicationlist.h | 8 ++++---- gui/mainwindow.h | 6 +++--- gui/resultstree.h | 2 +- gui/threadhandler.h | 2 +- lib/astutils.h | 22 +++++++++++----------- lib/checkcondition.h | 16 ++++++++-------- lib/checkexceptionsafety.h | 10 +++++----- lib/checkfunctions.h | 2 +- lib/checkio.h | 10 +++++----- lib/checkleakautovar.h | 6 +++--- lib/checkmemoryleak.h | 2 +- lib/checkother.h | 2 +- lib/checktype.h | 2 +- lib/checkuninitvar.h | 8 ++++---- lib/checkunusedvar.h | 2 +- lib/cppcheck.h | 4 ++-- lib/ctu.h | 2 +- lib/errorlogger.h | 2 +- lib/library.h | 8 ++++---- lib/preprocessor.h | 4 ++-- lib/suppressions.h | 4 ++-- lib/symboldatabase.cpp | 2 +- lib/symboldatabase.h | 2 +- lib/templatesimplifier.h | 6 +++--- lib/token.h | 26 +++++++++++++------------- lib/tokenize.h | 10 +++++----- lib/tokenlist.cpp | 2 +- lib/tokenlist.h | 4 ++-- test/fixture.h | 36 ++++++++++++++++++------------------ tools/triage/mainwindow.h | 2 +- 33 files changed, 108 insertions(+), 110 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 3a70ef512e7..ea453a81ee9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -57,7 +57,6 @@ Checks: > -performance-no-automatic-move, -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, diff --git a/clang-tidy.md b/clang-tidy.md index 4a7bcc48c85..05b4225fc43 100644 --- a/clang-tidy.md +++ b/clang-tidy.md @@ -117,7 +117,6 @@ We run this separately via `clang-include-cleaner` in the `iwyu.yml` workflow as `bugprone-branch-clone`
`modernize-return-braced-init-list`
`misc-throw-by-value-catch-by-reference`
-`readability-avoid-const-params-in-decls`
`bugprone-signed-char-misuse`
`concurrency-mt-unsafe`
`misc-use-anonymous-namespace`
diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 4904bee4570..a60e3040542 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -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(). diff --git a/gui/applicationlist.h b/gui/applicationlist.h index e9f307577bf..ede6698157f 100644 --- a/gui/applicationlist.h +++ b/gui/applicationlist.h @@ -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. @@ -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 diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 165e263246d..f2ee93a7986 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -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 @@ -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 @@ -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. diff --git a/gui/resultstree.h b/gui/resultstree.h index fd16c8c52d8..ff5af1a9d09 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -378,7 +378,7 @@ protected slots: */ QStandardItem *addBacktraceFiles(QStandardItem *parent, const ErrorLine &item, - const bool hide, + bool hide, const QString &icon, bool childOfMessage); diff --git a/gui/threadhandler.h b/gui/threadhandler.h index 63f18ab54e3..e198db7d59f 100644 --- a/gui/threadhandler.h +++ b/gui/threadhandler.h @@ -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) diff --git a/lib/astutils.h b/lib/astutils.h index 5c9427d6e79..2524f012765 100644 --- a/lib/astutils.h +++ b/lib/astutils.h @@ -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& pred); -const Token* findExpression(const Token* start, const nonneg int exprid); +const Token* findExpression(const Token* start, nonneg int exprid); template )> void astFlattenCopy(T* tok, const char* op, OuputIterator out, nonneg int depth = 100) @@ -269,7 +269,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); @@ -278,7 +278,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? @@ -293,9 +293,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); @@ -308,7 +308,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); @@ -346,8 +346,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); @@ -361,8 +361,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, diff --git a/lib/checkcondition.h b/lib/checkcondition.h index 111a633900f..b624c286f59 100644 --- a/lib/checkcondition.h +++ b/lib/checkcondition.h @@ -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(); @@ -133,9 +133,9 @@ class CPPCHECKLIB CheckCondition : public Check { std::set mCondDiags; bool diag(const Token* tok, bool insert=true); bool isAliased(const std::set &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, diff --git a/lib/checkexceptionsafety.h b/lib/checkexceptionsafety.h index 0a1c1922178..ef40c56016f 100644 --- a/lib/checkexceptionsafety.h +++ b/lib/checkexceptionsafety.h @@ -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); diff --git a/lib/checkfunctions.h b/lib/checkfunctions.h index 495b0ad37d4..c42b2a8ac83 100644 --- a/lib/checkfunctions.h +++ b/lib/checkfunctions.h @@ -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); diff --git a/lib/checkio.h b/lib/checkio.h index b798f562064..0f7d9b560e2 100644 --- a/lib/checkio.h +++ b/lib/checkio.h @@ -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); diff --git a/lib/checkleakautovar.h b/lib/checkleakautovar.h index 0cd9e4abdaa..ab22aae93bc 100644 --- a/lib/checkleakautovar.h +++ b/lib/checkleakautovar.h @@ -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 notzero, nonneg int recursiveCount); @@ -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); @@ -146,7 +146,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check { void changeAllocStatusIfRealloc(std::map &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); diff --git a/lib/checkmemoryleak.h b/lib/checkmemoryleak.h index 34080d61c45..93e716929b3 100644 --- a/lib/checkmemoryleak.h +++ b/lib/checkmemoryleak.h @@ -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 {} diff --git a/lib/checkother.h b/lib/checkother.h index d151ceb0862..71eba43362b 100644 --- a/lib/checkother.h +++ b/lib/checkother.h @@ -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); diff --git a/lib/checktype.h b/lib/checktype.h index d0130a3ade7..57c0dedbfbf 100644 --- a/lib/checktype.h +++ b/lib/checktype.h @@ -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); diff --git a/lib/checkuninitvar.h b/lib/checkuninitvar.h index 5b9aaf69c93..31c20abe965 100644 --- a/lib/checkuninitvar.h +++ b/lib/checkuninitvar.h @@ -92,11 +92,11 @@ class CPPCHECKLIB CheckUninitVar : public Check { void check(); void checkScope(const Scope* scope, const std::set &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& 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& 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; diff --git a/lib/checkunusedvar.h b/lib/checkunusedvar.h index 55d7735651d..8e4b214401c 100644 --- a/lib/checkunusedvar.h +++ b/lib/checkunusedvar.h @@ -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 */ diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 6483f80680f..5cfc3b472ba 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -132,7 +132,7 @@ class CPPCHECKLIB CppCheck : ErrorLogger { */ static void getErrorMessages(ErrorLogger &errorlogger); - void tooManyConfigsError(const std::string &file, const int numberOfConfigurations); + void tooManyConfigsError(const std::string &file, int numberOfConfigurations); void purgedConfigurationMessage(const std::string &file, const std::string& configuration); /** Analyse whole program, run this after all TUs has been scanned. @@ -231,7 +231,7 @@ class CPPCHECKLIB CppCheck : ErrorLogger { std::unordered_set mErrorList; Settings mSettings; - 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; ErrorLogger &mErrorLogger; diff --git a/lib/ctu.h b/lib/ctu.h index c642c4a2608..0a50bd63e47 100644 --- a/lib/ctu.h +++ b/lib/ctu.h @@ -134,7 +134,7 @@ namespace CTU { const UnsafeUsage &unsafeUsage, const std::map> &callsMap, const char info[], - const FunctionCall ** const functionCallPtr, + const FunctionCall ** functionCallPtr, bool warning); }; diff --git a/lib/errorlogger.h b/lib/errorlogger.h index 3af84f07751..c39d242f683 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -135,7 +135,7 @@ class CPPCHECKLIB ErrorMessage { const CWE &cwe, Certainty certainty); ErrorMessage(); - explicit ErrorMessage(const tinyxml2::XMLElement * const errmsg); + explicit ErrorMessage(const tinyxml2::XMLElement * errmsg); /** * Format the error message in XML format diff --git a/lib/library.h b/lib/library.h index a0742472e36..eaa4003ea24 100644 --- a/lib/library.h +++ b/lib/library.h @@ -341,7 +341,7 @@ class CPPCHECKLIB Library { return arg && arg->strz; } - bool isIntArgValid(const Token *ftok, int argnr, const MathLib::bigint argvalue) const; + bool isIntArgValid(const Token *ftok, int argnr, MathLib::bigint argvalue) const; bool isFloatArgValid(const Token *ftok, int argnr, double argvalue) const; const std::string& validarg(const Token *ftok, int argnr) const { @@ -393,8 +393,8 @@ class CPPCHECKLIB Library { const Token* getContainerFromYield(const Token* tok, Container::Yield yield) const; const Token* getContainerFromAction(const Token* tok, Container::Action action) const; - static bool isContainerYield(const Token* const cond, Library::Container::Yield y, const std::string& fallback = emptyString); - static Library::Container::Yield getContainerYield(const Token* const cond); + static bool isContainerYield(const Token* cond, Library::Container::Yield y, const std::string& fallback = emptyString); + static Library::Container::Yield getContainerYield(const Token* cond); bool isreflection(const std::string &token) const; @@ -463,7 +463,7 @@ class CPPCHECKLIB Library { Error load(const tinyxml2::XMLDocument &doc); // load a xml node - Error loadFunction(const tinyxml2::XMLElement * const node, const std::string &name, std::set &unknown_elements); + Error loadFunction(const tinyxml2::XMLElement * node, const std::string &name, std::set &unknown_elements); struct LibraryData; std::unique_ptr mData; diff --git a/lib/preprocessor.h b/lib/preprocessor.h index af9b7bc3cb8..97ac22d987d 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -69,7 +69,7 @@ struct CPPCHECKLIB Directive { /** record a directive (possibly filtering src) */ Directive(const simplecpp::Location & _loc, std::string _str); - Directive(std::string _file, const int _linenr, std::string _str); + Directive(std::string _file, int _linenr, std::string _str); }; class CPPCHECKLIB RemarkComment { @@ -138,7 +138,7 @@ class CPPCHECKLIB WARN_UNUSED Preprocessor { simplecpp::TokenList preprocess(const simplecpp::TokenList &tokens1, const std::string &cfg, std::vector &files, bool throwError = false); - std::string getcode(const simplecpp::TokenList &tokens1, const std::string &cfg, std::vector &files, const bool writeLocations); + std::string getcode(const simplecpp::TokenList &tokens1, const std::string &cfg, std::vector &files, bool writeLocations); /** * Calculate HASH. Using toolinfo, tokens1, filedata. diff --git a/lib/suppressions.h b/lib/suppressions.h index b6b8c815117..8f7337d7c60 100644 --- a/lib/suppressions.h +++ b/lib/suppressions.h @@ -229,13 +229,13 @@ class CPPCHECKLIB SuppressionList { * @brief Returns list of unmatched local (per-file) suppressions. * @return list of unmatched suppressions */ - std::list getUnmatchedLocalSuppressions(const FileWithDetails &file, const bool unusedFunctionChecking) const; + std::list getUnmatchedLocalSuppressions(const FileWithDetails &file, bool unusedFunctionChecking) const; /** * @brief Returns list of unmatched global (glob pattern) suppressions. * @return list of unmatched suppressions */ - std::list getUnmatchedGlobalSuppressions(const bool unusedFunctionChecking) const; + std::list getUnmatchedGlobalSuppressions(bool unusedFunctionChecking) const; /** * @brief Returns list of all suppressions. diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index df00fb60513..7573bb2c42b 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6514,7 +6514,7 @@ nonneg int SymbolDatabase::sizeOfType(const Token *type) const } static const Token* parsedecl(const Token* type, - ValueType* const valuetype, + ValueType* valuetype, ValueType::Sign defaultSignedness, const Settings& settings, SourceLocation loc = SourceLocation::current()); diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index d886c4866db..5b4ee0338c6 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1191,7 +1191,7 @@ class CPPCHECKLIB Scope { * @param typetok populated with pointer to the type token, if found * @return true if tok points to a variable declaration, false otherwise */ - bool isVariableDeclaration(const Token* const tok, const Token*& vartok, const Token*& typetok) const; + bool isVariableDeclaration(const Token* tok, const Token*& vartok, const Token*& typetok) const; void findFunctionInBase(const std::string & name, nonneg int args, std::vector & matches) const; diff --git a/lib/templatesimplifier.h b/lib/templatesimplifier.h index db7d6967e9c..6cbfd40a8ea 100644 --- a/lib/templatesimplifier.h +++ b/lib/templatesimplifier.h @@ -270,7 +270,7 @@ class CPPCHECKLIB TemplateSimplifier { * @param patternAfter pattern that must match the tokens after the ">" * @return match => true */ - static bool instantiateMatch(const Token *instance, const std::size_t numberOfArguments, bool variadic, const char patternAfter[]); + static bool instantiateMatch(const Token *instance, std::size_t numberOfArguments, bool variadic, const char patternAfter[]); /** * Match template declaration/instantiation @@ -308,7 +308,7 @@ class CPPCHECKLIB TemplateSimplifier { * Simplify templates * @param maxtime time when the simplification should be stopped */ - void simplifyTemplates(const std::time_t maxtime); + void simplifyTemplates(std::time_t maxtime); /** * Simplify constant calculations such as "1+2" => "3" @@ -396,7 +396,7 @@ class CPPCHECKLIB TemplateSimplifier { bool simplifyTemplateInstantiations( const TokenAndName &templateDeclaration, const std::list &specializations, - const std::time_t maxtime, + std::time_t maxtime, std::set &expandedtemplates); /** diff --git a/lib/token.h b/lib/token.h index 829cba6fe70..8c2dc667789 100644 --- a/lib/token.h +++ b/lib/token.h @@ -806,30 +806,30 @@ class CPPCHECKLIB Token { static const Token *findsimplematch(const Token * const startTok, const char (&pattern)[count]) { return findsimplematch(startTok, pattern, count-1); } - static const Token *findsimplematch(const Token * const startTok, const char pattern[], size_t pattern_len); + static const Token *findsimplematch(const Token * startTok, const char pattern[], size_t pattern_len); template static const Token *findsimplematch(const Token * const startTok, const char (&pattern)[count], const Token * const end) { return findsimplematch(startTok, pattern, count-1, end); } - static const Token *findsimplematch(const Token * const startTok, const char pattern[], size_t pattern_len, const Token * const end); + static const Token *findsimplematch(const Token * startTok, const char pattern[], size_t pattern_len, const Token * end); - static const Token *findmatch(const Token * const startTok, const char pattern[], const nonneg int varId = 0); - static const Token *findmatch(const Token * const startTok, const char pattern[], const Token * const end, const nonneg int varId = 0); + static const Token *findmatch(const Token * startTok, const char pattern[], nonneg int varId = 0); + static const Token *findmatch(const Token * startTok, const char pattern[], const Token * end, nonneg int varId = 0); template static Token *findsimplematch(Token * const startTok, const char (&pattern)[count]) { return findsimplematch(startTok, pattern, count-1); } - static Token *findsimplematch(Token * const startTok, const char pattern[], size_t pattern_len); + static Token *findsimplematch(Token * startTok, const char pattern[], size_t pattern_len); template static Token *findsimplematch(Token * const startTok, const char (&pattern)[count], const Token * const end) { return findsimplematch(startTok, pattern, count-1, end); } - static Token *findsimplematch(Token * const startTok, const char pattern[], size_t pattern_len, const Token * const end); + static Token *findsimplematch(Token * startTok, const char pattern[], size_t pattern_len, const Token * end); - static Token *findmatch(Token * const startTok, const char pattern[], const nonneg int varId = 0); - static Token *findmatch(Token * const startTok, const char pattern[], const Token * const end, const nonneg int varId = 0); + static Token *findmatch(Token * startTok, const char pattern[], nonneg int varId = 0); + static Token *findmatch(Token * startTok, const char pattern[], const Token * end, nonneg int varId = 0); private: template )> @@ -1286,19 +1286,19 @@ class CPPCHECKLIB Token { return mImpl->mValues->front().intvalue; } - const ValueFlow::Value* getValue(const MathLib::bigint val) const; + const ValueFlow::Value* getValue(MathLib::bigint val) const; const ValueFlow::Value* getMaxValue(bool condition, MathLib::bigint path = 0) const; const ValueFlow::Value* getMinValue(bool condition, MathLib::bigint path = 0) const; const ValueFlow::Value* getMovedValue() const; - const ValueFlow::Value * getValueLE(const MathLib::bigint val, const Settings &settings) const; - const ValueFlow::Value * getValueGE(const MathLib::bigint val, const Settings &settings) const; + const ValueFlow::Value * getValueLE(MathLib::bigint val, const Settings &settings) const; + const ValueFlow::Value * getValueGE(MathLib::bigint val, const Settings &settings) const; const ValueFlow::Value * getInvalidValue(const Token *ftok, nonneg int argnr, const Settings &settings) const; - const ValueFlow::Value* getContainerSizeValue(const MathLib::bigint val) const; + const ValueFlow::Value* getContainerSizeValue(MathLib::bigint val) const; const Token *getValueTokenMaxStrLength() const; const Token *getValueTokenMinStrSize(const Settings &settings, MathLib::bigint* path = nullptr) const; @@ -1432,7 +1432,7 @@ class CPPCHECKLIB Token { void update_property_isStandardType(); /** Internal helper function to avoid excessive string allocations */ - void astStringVerboseRecursive(std::string& ret, const nonneg int indent1 = 0, const nonneg int indent2 = 0) const; + void astStringVerboseRecursive(std::string& ret, nonneg int indent1 = 0, nonneg int indent2 = 0) const; public: void astOperand1(Token *tok); diff --git a/lib/tokenize.h b/lib/tokenize.h index cb66342797e..2695c4ca6b7 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -164,8 +164,8 @@ class CPPCHECKLIB Tokenizer { * Simplify variable declarations (split up) * \param only_k_r_fpar Only simplify K&R function parameters */ - void simplifyVarDecl(const bool only_k_r_fpar); - void simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, const bool only_k_r_fpar); // cppcheck-suppress functionConst // has side effects + void simplifyVarDecl( bool only_k_r_fpar); + void simplifyVarDecl(Token * tokBegin, const Token * tokEnd, bool only_k_r_fpar); // cppcheck-suppress functionConst // has side effects /** * Simplify variable initialization @@ -536,7 +536,7 @@ class CPPCHECKLIB Tokenizer { /** * report error message */ - void reportError(const Token* tok, const Severity severity, const std::string& id, const std::string& msg, bool inconclusive = false) const; + void reportError(const Token* tok, Severity severity, const std::string& id, const std::string& msg, bool inconclusive = false) const; void reportError(const std::list& callstack, Severity severity, const std::string& id, const std::string& msg, bool inconclusive = false) const; bool duplicateTypedef(Token *&tokPtr, const Token *name, const Token *typeDef) const; @@ -544,8 +544,8 @@ class CPPCHECKLIB Tokenizer { void unsupportedTypedef(const Token *tok) const; static void setVarIdClassFunction(const std::string &classname, - Token * const startToken, - const Token * const endToken, + Token * startToken, + const Token * endToken, const std::map &varlist, std::map>& structMembers, nonneg int &varId_); diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index ae129f4c412..fa23d414bca 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -581,7 +581,7 @@ static Token * findCppTypeInitPar(Token *tok) } // X{} X{} etc -static bool iscpp11init_impl(const Token * const tok); +static bool iscpp11init_impl(const Token * tok); static bool iscpp11init(const Token * const tok) { if (tok->isCpp11init() == TokenImpl::Cpp11init::UNKNOWN) diff --git a/lib/tokenlist.h b/lib/tokenlist.h index 1bf852d3734..09a74c4ca16 100644 --- a/lib/tokenlist.h +++ b/lib/tokenlist.h @@ -77,10 +77,10 @@ class CPPCHECKLIB TokenList { */ static void deleteTokens(Token *tok); - void addtoken(const std::string& str, const nonneg int lineno, const nonneg int column, const nonneg int fileno, bool split = false); + void addtoken(const std::string& str, nonneg int lineno, nonneg int column, nonneg int fileno, bool split = false); void addtoken(const std::string& str, const Token *locationTok); - void addtoken(const Token *tok, const nonneg int lineno, const nonneg int column, const nonneg int fileno); + void addtoken(const Token *tok, nonneg int lineno, nonneg int column, nonneg int fileno); void addtoken(const Token *tok, const Token *locationTok); void addtoken(const Token *tok); diff --git a/test/fixture.h b/test/fixture.h index c44e45fa1b2..313a2b5157e 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -66,9 +66,9 @@ class TestFixture : public ErrorLogger { virtual void prepareTestInternal() {} void teardownTest(); virtual void teardownTestInternal() {} - std::string getLocationStr(const char * const filename, const unsigned int linenr) const; + std::string getLocationStr(const char * filename, unsigned int linenr) const; - bool assert_(const char * const filename, const unsigned int linenr, const bool condition) const; + bool assert_(const char * filename, unsigned int linenr, bool condition) const; template bool assertEquals(const char* const filename, const unsigned int linenr, const T& expected, const T& actual, const std::string& msg = emptyString) const { @@ -92,25 +92,25 @@ class TestFixture : public ErrorLogger { //Helper function to be called when an assertEquals assertion fails. //Writes the appropriate failure message to errmsg and increments fails_counter - void assertEqualsFailed(const char* const filename, const unsigned int linenr, const std::string& expected, const std::string& actual, const std::string& msg) const; + void assertEqualsFailed(const char* filename, unsigned int linenr, const std::string& expected, const std::string& actual, const std::string& msg) const; - bool assertEquals(const char * const filename, const unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const; - void assertEqualsWithoutLineNumbers(const char * const filename, const unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const; - bool assertEquals(const char * const filename, const unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg = emptyString) const; - bool assertEquals(const char * const filename, const unsigned int linenr, const char expected[], const char actual[], const std::string &msg = emptyString) const; - bool assertEquals(const char * const filename, const unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg = emptyString) const; - bool assertEquals(const char * const filename, const unsigned int linenr, const long long expected, const long long actual, const std::string &msg = emptyString) const; - void assertEqualsDouble(const char * const filename, const unsigned int linenr, const double expected, const double actual, const double tolerance, const std::string &msg = emptyString) const; + bool assertEquals(const char * filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const; + void assertEqualsWithoutLineNumbers(const char * filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const; + bool assertEquals(const char * filename, unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg = emptyString) const; + bool assertEquals(const char * filename, unsigned int linenr, const char expected[], const char actual[], const std::string &msg = emptyString) const; + bool assertEquals(const char * filename, unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg = emptyString) const; + bool assertEquals(const char * filename, unsigned int linenr, long long expected, long long actual, const std::string &msg = emptyString) const; + void assertEqualsDouble(const char * filename, unsigned int linenr, double expected, double actual, double tolerance, const std::string &msg = emptyString) const; - void todoAssertEquals(const char * const filename, const unsigned int linenr, const std::string &wanted, + void todoAssertEquals(const char * filename, unsigned int linenr, const std::string &wanted, const std::string ¤t, const std::string &actual) const; - void todoAssertEquals(const char * const filename, const unsigned int linenr, const char wanted[], + void todoAssertEquals(const char * filename, unsigned int linenr, const char wanted[], const char current[], const std::string &actual) const; - void todoAssertEquals(const char * const filename, const unsigned int linenr, const long long wanted, - const long long current, const long long actual) const; - void assertThrow(const char * const filename, const unsigned int linenr) const; - void assertThrowFail(const char * const filename, const unsigned int linenr) const; - void assertNoThrowFail(const char * const filename, const unsigned int linenr) const; + void todoAssertEquals(const char * filename, unsigned int linenr, long long wanted, + long long current, long long actual) const; + void assertThrow(const char * filename, unsigned int linenr) const; + void assertThrowFail(const char * filename, unsigned int linenr) const; + void assertNoThrowFail(const char * filename, unsigned int linenr) const; static std::string deleteLineNumber(const std::string &message); void setVerbose(bool v) { @@ -278,7 +278,7 @@ class TestFixture : public ErrorLogger { static void printHelp(); const std::string classname; - explicit TestFixture(const char * const _name); + explicit TestFixture(const char * _name); static std::size_t runTests(const options& args); }; diff --git a/tools/triage/mainwindow.h b/tools/triage/mainwindow.h index cac725963bd..999740fb59d 100644 --- a/tools/triage/mainwindow.h +++ b/tools/triage/mainwindow.h @@ -62,7 +62,7 @@ public slots: bool runProcess(const QString &programName, const QStringList & arguments); bool wget(const QString &url); bool unpackArchive(const QString &archiveName); - void showSrcFile(const QString &fileName, const QString &url, const int lineNumber); + void showSrcFile(const QString &fileName, const QString &url, int lineNumber); QStringList mAllErrors; QFileSystemModel mFSmodel;