Skip to content

Commit

Permalink
fixed and enabled readability-avoid-const-params-in-decls clang-tid…
Browse files Browse the repository at this point in the history
…y warnings
  • Loading branch information
firewave committed Mar 6, 2023
1 parent e8e00d8 commit 78fa1a0
Show file tree
Hide file tree
Showing 34 changed files with 111 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,google-explicit-constructor,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-redundant-member-init,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-readability-const-return-type,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-misc-non-private-member-variables-in-classes,-clang-analyzer-*,-bugprone-signed-char-misuse,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer,-bugprone-assignment-in-if-condition,-misc-const-correctness,-portability-std-allocator-const,-modernize-deprecated-ios-base-aliases,-bugprone-unchecked-optional-access,-modernize-replace-auto-ptr,-readability-identifier-naming,-portability-simd-intrinsics,-misc-use-anonymous-namespace'
Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,google-explicit-constructor,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-redundant-member-init,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-readability-const-return-type,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-misc-non-private-member-variables-in-classes,-clang-analyzer-*,-bugprone-signed-char-misuse,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer,-bugprone-assignment-in-if-condition,-misc-const-correctness,-portability-std-allocator-const,-modernize-deprecated-ios-base-aliases,-bugprone-unchecked-optional-access,-modernize-replace-auto-ptr,-readability-identifier-naming,-portability-simd-intrinsics,-misc-use-anonymous-namespace'
WarningsAsErrors: '*'
HeaderFilterRegex: '(cli|gui|lib|oss-fuzz|test|triage)\/[a-z]+\.h'
CheckOptions:
Expand Down
1 change: 0 additions & 1 deletion clang-tidy.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ Also reports a false positive about templates which deduce the array length: htt
`readability-const-return-type`<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>
`performance-noexcept-move-constructor`<br>
`concurrency-mt-unsafe`<br>
Expand Down
2 changes: 1 addition & 1 deletion cli/cppcheckexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* Information about how many files have been checked
Expand Down
8 changes: 4 additions & 4 deletions gui/applicationlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,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 @@ -86,13 +86,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 @@ -259,7 +259,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 @@ -298,7 +298,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 @@ -307,7 +307,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 @@ -379,7 +379,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 @@ -55,7 +55,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 @@ -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<bool(const Token*)>& pred);
const Token* findExpression(const Token* start, const nonneg int exprid);
const Token* findExpression(const Token* start, nonneg int exprid);

std::vector<const Token*> astFlatten(const Token* tok, const char* op);
std::vector<Token*> astFlatten(Token* tok, const char* op);
Expand Down Expand Up @@ -242,7 +242,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);

Expand All @@ -251,7 +251,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
Expand All @@ -262,9 +262,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);

Expand All @@ -277,7 +277,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);
Expand Down Expand Up @@ -315,8 +315,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);

Expand All @@ -332,8 +332,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);

bool isExpressionChanged(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 @@ -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();
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 {

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);

Expand Down
2 changes: 1 addition & 1 deletion lib/checkfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions lib/checkio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions lib/checkleakautovar.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,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 @@ -135,7 +135,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);
Expand All @@ -147,7 +147,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check {
void changeAllocStatusIfRealloc(std::map<int, VarInfo::AllocInfo> &alloctype, const Token *fTok, const Token *retTok);

/** 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 @@ -284,7 +284,7 @@ class CPPCHECKLIB CheckMemoryLeakStructMember : private Check, private CheckMemo
/** Is local variable allocated with malloc? */
static bool isMalloc(const Variable *variable);

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

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 @@ -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);
Expand Down
Loading

0 comments on commit 78fa1a0

Please sign in to comment.