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 Aug 8, 2023
1 parent 037bed5 commit 1d2d36c
Show file tree
Hide file tree
Showing 34 changed files with 109 additions and 111 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion clang-tidy.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,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>
`readability-redundant-access-specifiers`<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;

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

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

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

/**
* @brief Remove all applications from this list and copy all applications from
Expand Down
6 changes: 3 additions & 3 deletions gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion gui/resultstree.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ protected slots:
*/
QStandardItem *addBacktraceFiles(QStandardItem *parent,
const ErrorLine &item,
const bool hide,
bool hide,
const QString &icon,
bool childOfMessage);

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

/**
* @brief Initialize the threads (connect all signals to resultsview's slots)
Expand Down
22 changes: 11 additions & 11 deletions lib/astutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -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);

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

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

Expand All @@ -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,
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 @@ -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<int> notzero,
nonneg int recursiveCount);
Expand All @@ -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);
Expand All @@ -148,7 +148,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check {
void changeAllocStatusIfRealloc(std::map<int, VarInfo::AllocInfo> &alloctype, const Token *fTok, const Token *retTok) const;

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

/** if variable is allocated then there is a leak */
void leakIfAllocated(const Token *vartok, const VarInfo &varInfo);
Expand Down
2 changes: 1 addition & 1 deletion lib/checkmemoryleak.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

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
2 changes: 1 addition & 1 deletion lib/checktype.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions lib/checkuninitvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class CPPCHECKLIB CheckUninitVar : public Check {
void checkScope(const Scope* scope, const std::set<std::string> &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<nonneg int, VariableValue> variableValue);
const Token* checkExpr(const Token* tok, const Variable& var, const Alloc alloc, bool known, bool* bailout = nullptr) const;
bool checkScopeForVariable(const Token *tok, const Variable& var, bool* possibleInit, bool* noreturn, Alloc* alloc, const std::string &membervar, std::map<nonneg int, VariableValue> variableValue);
const Token* checkExpr(const Token* tok, const Variable& var, Alloc alloc, bool known, bool* bailout = nullptr) const;
bool checkIfForWhileHead(const Token *startparentheses, const Variable& var, bool suppressErrors, bool isuninit, Alloc alloc, const std::string &membervar);
bool checkLoopBody(const Token *tok, const Variable& var, const Alloc alloc, const std::string &membervar, const bool suppressErrors);
const Token* checkLoopBodyRecursive(const Token *start, const Variable& var, const Alloc alloc, const std::string &membervar, bool &bailout) const;
bool checkLoopBody(const Token *tok, const Variable& var, Alloc alloc, const std::string &membervar, bool suppressErrors);
const Token* checkLoopBodyRecursive(const Token *start, const Variable& var, Alloc alloc, const std::string &membervar, bool &bailout) const;
void checkRhs(const Token *tok, const Variable &var, Alloc alloc, nonneg int number_of_if, const std::string &membervar);
static 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;
Expand Down
Loading

0 comments on commit 1d2d36c

Please sign in to comment.