diff --git a/.clang-tidy b/.clang-tidy index fc451fb3c9a4..0da54e59b1fd 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -47,7 +47,6 @@ Checks: > -performance-no-automatic-move, -portability-simd-intrinsics, -portability-std-allocator-const, - -readability-avoid-const-params-in-decls, -readability-braces-around-statements, -readability-const-return-type, -readability-container-data-pointer, diff --git a/clang-tidy.md b/clang-tidy.md index 8d1de3c83aaf..fcc85034ff15 100644 --- a/clang-tidy.md +++ b/clang-tidy.md @@ -130,7 +130,6 @@ Also reports a false positive about templates which deduce the array length: htt `readability-const-return-type`
`modernize-return-braced-init-list`
`misc-throw-by-value-catch-by-reference`
-`readability-avoid-const-params-in-decls`
`bugprone-signed-char-misuse`
`readability-redundant-access-specifiers`
`concurrency-mt-unsafe`
diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index 23e845e0e6f7..3bebad525450 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -79,7 +79,7 @@ class CppCheckExecutor : public ErrorLogger { /** 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; /** * @param exceptionOutput Output file diff --git a/gui/applicationlist.h b/gui/applicationlist.h index 537ca51af350..ec104010ff9d 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 78782b22bddd..3d65ccb1e900 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -260,7 +260,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 @@ -299,7 +299,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 @@ -308,7 +308,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 5828c0e383bf..2353afcfad9a 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -373,7 +373,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 cdf2a6f02619..370cf197d4ba 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 04143bc7f571..8cb675d44e6e 100644 --- a/lib/astutils.h +++ b/lib/astutils.h @@ -108,11 +108,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); std::vector astFlatten(const Token* tok, const char* op); std::vector astFlatten(Token* tok, const char* op); @@ -244,7 +244,7 @@ const Token* followReferences(const Token* tok, ErrorPath* errors = nullptr); CPPCHECKLIB bool isSameExpression(bool cpp, bool macro, const Token *tok1, const Token *tok2, const Library& library, 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); @@ -253,7 +253,7 @@ const Token* isInLoopCondition(const Token* tok); /** * Is token used a 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); +CPPCHECKLIB bool isUsedAsBool(const Token * tok); /** * Are two conditions opposite @@ -264,9 +264,9 @@ CPPCHECKLIB bool isUsedAsBool(const Token * const tok); * @param library files data * @param pure boolean */ -bool isOppositeCond(bool isNot, bool cpp, const Token * const cond1, const Token * const cond2, const Library& library, bool pure, bool followVar, ErrorPath* errors=nullptr); +bool isOppositeCond(bool isNot, bool cpp, const Token * cond1, const Token * cond2, const Library& library, bool pure, bool followVar, ErrorPath* errors=nullptr); -bool isOppositeExpression(bool cpp, const Token * const tok1, const Token * const tok2, const Library& library, bool pure, bool followVar, ErrorPath* errors=nullptr); +bool isOppositeExpression(bool cpp, const Token * tok1, const Token * tok2, const Library& library, bool pure, bool followVar, ErrorPath* errors=nullptr); bool isConstFunctionCall(const Token* ftok, const Library& library); @@ -279,7 +279,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 = nullptr, const Token** unknownFunc = nullptr, bool functionScope = false); @@ -317,8 +317,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, bool cpp, int depth = 20); -bool isVariableChanged(const Token *start, const Token *end, int indirect, const nonneg int exprid, bool globalvar, const Settings *settings, bool cpp, int depth = 20); +CPPCHECKLIB bool isVariableChanged(const Token *start, const Token *end, nonneg int exprid, bool globalvar, const Settings *settings, bool cpp, int depth = 20); +bool isVariableChanged(const Token *start, const Token *end, int indirect, nonneg int exprid, bool globalvar, const Settings *settings, bool cpp, int depth = 20); bool isVariableChanged(const Token *tok, int indirect, const Settings *settings, bool cpp, int depth = 20); @@ -334,8 +334,8 @@ bool isVariablesChanged(const Token* start, bool isThisChanged(const Token* tok, int indirect, const Settings* settings, bool cpp); bool isThisChanged(const Token* start, const Token* end, int indirect, const Settings* settings, bool cpp); -const Token* findVariableChanged(const Token *start, const Token *end, int indirect, const nonneg int exprid, bool globalvar, const Settings *settings, bool cpp, int depth = 20); -Token* findVariableChanged(Token *start, const Token *end, int indirect, const nonneg int exprid, bool globalvar, const Settings *settings, bool cpp, int depth = 20); +const Token* findVariableChanged(const Token *start, const Token *end, int indirect, nonneg int exprid, bool globalvar, const Settings *settings, bool cpp, int depth = 20); +Token* findVariableChanged(Token *start, const Token *end, int indirect, nonneg int exprid, bool globalvar, const Settings *settings, bool cpp, int depth = 20); CPPCHECKLIB bool isExpressionChanged(const Token* expr, const Token* start, diff --git a/lib/checkcondition.h b/lib/checkcondition.h index 57e09c50b49e..54b3b93668f8 100644 --- a/lib/checkcondition.h +++ b/lib/checkcondition.h @@ -79,12 +79,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 6f90b881c7a4..8a39e7fc17f9 100644 --- a/lib/checkexceptionsafety.h +++ b/lib/checkexceptionsafety.h @@ -90,13 +90,13 @@ class CPPCHECKLIB CheckExceptionSafety : public Check { private: /** 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 bff40c2eb000..360ff1bf0a51 100644 --- a/lib/checkfunctions.h +++ b/lib/checkfunctions.h @@ -118,7 +118,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 29c3344d5c19..cca9e6e979bf 100644 --- a/lib/checkio.h +++ b/lib/checkio.h @@ -96,11 +96,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 1d7cb5fb37e8..cf633a8366f8 100644 --- a/lib/checkleakautovar.h +++ b/lib/checkleakautovar.h @@ -126,7 +126,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); @@ -136,7 +136,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); + const Token * checkTokenInsideExpression(const Token * tok, VarInfo &varInfo); /** parse function call */ void functionCall(const Token *tokName, const Token *tokOpeningPar, VarInfo &varInfo, const VarInfo::AllocInfo& allocation, const Library::AllocFunc* af); @@ -148,7 +148,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 48144668fcdb..198fd6acfdc1 100644 --- a/lib/checkmemoryleak.h +++ b/lib/checkmemoryleak.h @@ -281,7 +281,7 @@ class CPPCHECKLIB CheckMemoryLeakStructMember : private Check, private CheckMemo /** 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 747f1e63857d..063c98eba50e 100644 --- a/lib/checkother.h +++ b/lib/checkother.h @@ -228,7 +228,7 @@ class CPPCHECKLIB CheckOther : public Check { private: // 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 e403bf16dd0a..97e0416549b4 100644 --- a/lib/checktype.h +++ b/lib/checktype.h @@ -83,7 +83,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 fbb645e07ca3..776e4801a7d9 100644 --- a/lib/checkuninitvar.h +++ b/lib/checkuninitvar.h @@ -81,11 +81,11 @@ class CPPCHECKLIB CheckUninitVar : public Check { void checkScope(const Scope* scope, const std::set &arrayTypeDefs); void checkStruct(const Token *tok, const Variable &structvar); enum Alloc { NO_ALLOC, NO_CTOR_CALL, CTOR_CALL, ARRAY }; - 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 const Token *isVariableUsage(bool cpp, const Token *vartok, const Library &library, bool pointer, Alloc alloc, int indirect = 0); const Token *isVariableUsage(const Token *vartok, bool pointer, Alloc alloc, int indirect = 0) const; diff --git a/lib/checkunusedfunctions.h b/lib/checkunusedfunctions.h index af008a17bd65..06ecdedc5c3e 100644 --- a/lib/checkunusedfunctions.h +++ b/lib/checkunusedfunctions.h @@ -63,7 +63,7 @@ class CPPCHECKLIB CheckUnusedFunctions : public Check { void parseTokens(const Tokenizer &tokenizer, const char FileName[], const Settings *settings); // Return true if an error is reported. - bool check(ErrorLogger * const errorLogger, const Settings& settings) const; + bool check(ErrorLogger * errorLogger, const Settings& settings) const; /** @brief Parse current TU and extract file info */ Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override; @@ -76,7 +76,7 @@ class CPPCHECKLIB CheckUnusedFunctions : public Check { std::string analyzerInfo() const; /** @brief Combine and analyze all analyzerInfos for all TUs */ - static void analyseWholeProgram(const Settings &settings, ErrorLogger * const errorLogger, const std::string &buildDir); + static void analyseWholeProgram(const Settings &settings, ErrorLogger * errorLogger, const std::string &buildDir); private: @@ -89,7 +89,7 @@ class CPPCHECKLIB CheckUnusedFunctions : public Check { /** * Dummy implementation, just to provide error for --errorlist */ - static void unusedFunctionError(ErrorLogger * const errorLogger, + static void unusedFunctionError(ErrorLogger * errorLogger, const std::string &filename, unsigned int lineNumber, const std::string &funcname); diff --git a/lib/checkunusedvar.h b/lib/checkunusedvar.h index 743a732ba428..317843178ca7 100644 --- a/lib/checkunusedvar.h +++ b/lib/checkunusedvar.h @@ -63,7 +63,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 925111ae75b3..fc5ebf9c20bc 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -118,7 +118,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. @@ -210,7 +210,7 @@ class CPPCHECKLIB CppCheck : ErrorLogger { std::list 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 a353ac1d7d7e..944f78be451a 100644 --- a/lib/ctu.h +++ b/lib/ctu.h @@ -133,7 +133,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 ef8d8a719370..801609ff5844 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -141,7 +141,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 300382d9fc77..aec9b367cf8e 100644 --- a/lib/library.h +++ b/lib/library.h @@ -366,7 +366,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 { @@ -511,7 +511,7 @@ class CPPCHECKLIB Library { */ std::string getFunctionName(const Token *ftok) const; - static bool isContainerYield(const Token * const cond, Library::Container::Yield y, const std::string& fallback=emptyString); + static bool isContainerYield(const Token * cond, Library::Container::Yield y, const std::string& fallback=emptyString); /** Suppress/check a type */ enum class TypeCheck { def, @@ -524,7 +524,7 @@ class CPPCHECKLIB Library { private: // 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); class ExportedFunctions { public: diff --git a/lib/preprocessor.h b/lib/preprocessor.h index fdc63ed72b03..ef87801c4cce 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -58,7 +58,7 @@ class CPPCHECKLIB Directive { std::string str; /** record a directive (possibly filtering src) */ - Directive(std::string _file, const int _linenr, const std::string &_str); + Directive(std::string _file, int _linenr, const std::string &_str); }; /// @addtogroup Core @@ -146,7 +146,7 @@ class CPPCHECKLIB 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 cc64ee51cef4..9d7af53f3bde 100644 --- a/lib/suppressions.h +++ b/lib/suppressions.h @@ -182,13 +182,13 @@ class CPPCHECKLIB Suppressions { * @brief Returns list of unmatched local (per-file) suppressions. * @return list of unmatched suppressions */ - std::list getUnmatchedLocalSuppressions(const std::string &file, const bool unusedFunctionChecking) const; + std::list getUnmatchedLocalSuppressions(const std::string &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 4712e646ec88..65a93e673d0e 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6077,7 +6077,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, bool isCpp, diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index d7c50ee7a2a2..17146b9f394e 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1192,7 +1192,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 763962ea24c7..e61d449ba6a1 100644 --- a/lib/templatesimplifier.h +++ b/lib/templatesimplifier.h @@ -271,7 +271,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 @@ -311,7 +311,7 @@ class CPPCHECKLIB TemplateSimplifier { * @param codeWithTemplates output parameter that is set if code contains templates */ void simplifyTemplates( - const std::time_t maxtime, + std::time_t maxtime, bool &codeWithTemplates); /** @@ -400,7 +400,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 d04d365d4450..65a416ccdca2 100644 --- a/lib/token.h +++ b/lib/token.h @@ -332,7 +332,7 @@ class CPPCHECKLIB Token { * @param tok token with C-string * @param settings Settings **/ - static nonneg int getStrSize(const Token *tok, const Settings *const settings); + static nonneg int getStrSize(const Token *tok, const Settings * settings); const ValueType *valueType() const { return mImpl->mValueType; @@ -755,16 +755,16 @@ 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]) { @@ -1221,18 +1221,18 @@ 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* 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; @@ -1368,7 +1368,7 @@ class CPPCHECKLIB Token { void update_property_char_string_literal(); /** 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 cea8e5132384..f7f23e4a0636 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -194,8 +194,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 @@ -572,16 +572,16 @@ class CPPCHECKLIB Tokenizer { /** * report error message */ - void reportError(const Token* tok, const Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive = false) const; + void reportError(const Token* tok, Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive = false) const; void reportError(const std::list& callstack, Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive = false) const; bool duplicateTypedef(Token **tokPtr, const Token *name, const Token *typeDef) const; void unsupportedTypedef(const Token *tok) const; - void setVarIdClassDeclaration(Token* const startToken, // cppcheck-suppress functionConst // has side effects + void setVarIdClassDeclaration(Token* startToken, // cppcheck-suppress functionConst // has side effects VariableMap& variableMap, - const nonneg int scopeStartVarId, + nonneg int scopeStartVarId, std::map>& structMembers); void setVarIdStructMembers(Token **tok1, @@ -589,8 +589,8 @@ class CPPCHECKLIB Tokenizer { nonneg int &varId) const; void setVarIdClassFunction(const std::string &classname, // cppcheck-suppress functionConst // has side effects - 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 2e023d548419..cb1b829837f4 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -528,7 +528,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 a150d36f3602..b1e39d4a03b0 100644 --- a/lib/tokenlist.h +++ b/lib/tokenlist.h @@ -69,10 +69,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 2a3c26eca876..470d82889d6c 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -60,9 +60,9 @@ class TestFixture : public ErrorLogger { virtual void run() = 0; bool prepareTest(const char testname[]); - 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 U& actual, const std::string& msg = emptyString) const { @@ -79,25 +79,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) { @@ -216,7 +216,7 @@ class TestFixture : public ErrorLogger { static void printHelp(); const std::string classname; - explicit TestFixture(const char * const _name); + explicit TestFixture(const char * _name); ~TestFixture() override {} static std::size_t runTests(const options& args); diff --git a/tools/triage/mainwindow.h b/tools/triage/mainwindow.h index 6c5085b4d1d1..1cca1e3507c7 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;