diff --git a/.selfcheck_suppressions b/.selfcheck_suppressions index a93693ef8e2..16f8f316a49 100644 --- a/.selfcheck_suppressions +++ b/.selfcheck_suppressions @@ -6,20 +6,6 @@ varid0:gui/projectfile.cpp naming-privateMemberVariable:gui/test/cppchecklibrarydata/testcppchecklibrarydata.h symbolDatabaseWarning:*/moc_*.cpp simplifyUsing:*/moc_*.cpp -bitwiseOnBoolean:lib/library.cpp -templateInstantiation:lib/checkunusedfunctions.cpp -templateInstantiation:lib/errorlogger.cpp -templateInstantiation:lib/liobrary.cpp -shadowFunction:lib/checkbufferoverrun.cpp -shadowFunction:lib/checkclass.cpp -shadowFunction:lib/checknullpointer.cpp -shadowFunction:lib/cppcheck.cpp -shadowFunction:lib/fwdanalysis.cpp -shadowFunction:lib/library.cpp -shadowFunction:lib/symboldatabase.cpp -shadowFunction:lib/templatesimplifier.cpp -shadowFunction:lib/token.cpp -shadowFunction:tools/triage/mainwindow.cpp # warnings in Qt generated code we cannot fix funcArgNamesDifferent:*/moc_*.cpp diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index d9acf389218..c0c5ddb64c8 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -953,6 +953,7 @@ Check::FileInfo *CheckBufferOverrun::getFileInfo(const Tokenizer *tokenizer, con Check::FileInfo * CheckBufferOverrun::loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const { + // cppcheck-suppress shadowFunction - TODO: fix this const std::string arrayIndex("array-index"); const std::string pointerArith("pointer-arith"); diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index c6005eca1ee..245455ad4ca 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2479,6 +2479,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, Member return false; const Token* assignTok = end->next()->astParent(); if (var && assignTok && assignTok->isAssignmentOp() && assignTok->astOperand1() && assignTok->astOperand1()->variable()) { + // cppcheck-suppress shadowFunction - TODO: fix this const Variable* assignVar = assignTok->astOperand1()->variable(); if (assignVar->isPointer() && !assignVar->isConst() && var->typeScope()) { const auto& funcMap = var->typeScope()->functionMap; diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 86a6542f0b6..cf70f7293eb 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -514,6 +514,7 @@ static std::string arithmeticTypeString(const Token *tok) void CheckNullPointer::pointerArithmeticError(const Token* tok, const ValueFlow::Value *value, bool inconclusive) { + // cppcheck-suppress shadowFunction - TODO: fix this std::string arithmetic = arithmeticTypeString(tok); std::string errmsg; if (tok && tok->str()[0] == '-') { @@ -532,6 +533,7 @@ void CheckNullPointer::pointerArithmeticError(const Token* tok, const ValueFlow: void CheckNullPointer::redundantConditionWarning(const Token* tok, const ValueFlow::Value *value, const Token *condition, bool inconclusive) { + // cppcheck-suppress shadowFunction - TODO: fix this std::string arithmetic = arithmeticTypeString(tok); std::string errmsg; if (tok && tok->str()[0] == '-') { diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index 24151998ce1..eb789fdf727 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -459,8 +459,10 @@ void CheckUnusedFunctions::analyseWholeProgram(const Settings &settings, ErrorLo } if (std::strcmp(e2->Name(),"functiondecl") == 0) { const char* lineNumber = e2->Attribute("lineNumber"); - if (lineNumber) + if (lineNumber) { + // cppcheck-suppress templateInstantiation - TODO: fix this - see #11631 decls[functionName] = Location(sourcefile, strToInt(lineNumber)); + } } } } diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index f70bca725a2..2d772662d69 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1062,6 +1062,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer) const std::time_t maxTime = mSettings.checksMaxTime > 0 ? std::time(nullptr) + mSettings.checksMaxTime : 0; // call all "runChecks" in all registered Check classes + // cppcheck-suppress shadowFunction - TODO: fix this for (Check *check : Check::instances()) { if (Settings::terminated()) return; @@ -1104,6 +1105,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer) mAnalyzerInformation.setFileInfo("ctu", fi1->toString()); } + // cppcheck-suppress shadowFunction - TODO: fix this for (const Check *check : Check::instances()) { if (doUnusedFunctionOnly && dynamic_cast(check) == nullptr) continue; @@ -1735,6 +1737,7 @@ bool CppCheck::analyseWholeProgram() ctu.nestedCalls.insert(ctu.nestedCalls.end(), fi2->nestedCalls.cbegin(), fi2->nestedCalls.cend()); } } + // cppcheck-suppress shadowFunction - TODO: fix this for (Check *check : Check::instances()) errors |= check->analyseWholeProgram(&ctu, mFileInfo, mSettings, *this); // TODO: ctu return errors && (mExitCode > 0); @@ -1785,6 +1788,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::list< ctuFileInfo.loadFromXml(e); continue; } + // cppcheck-suppress shadowFunction - TODO: fix this for (const Check *check : Check::instances()) { if (checkClassAttr == check->name()) fileInfoList.push_back(check->loadFileInfoFromXml(e)); @@ -1796,6 +1800,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::list< CTU::maxCtuDepth = mSettings.maxCtuDepth; // Analyse the tokens + // cppcheck-suppress shadowFunction - TODO: fix this for (Check *check : Check::instances()) check->analyseWholeProgram(&ctuFileInfo, fileInfoList, mSettings, *this); diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index a8a18b6c365..09aeba231a6 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -169,6 +169,7 @@ ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg) severity = attr ? severityFromString(attr) : Severity::none; attr = errmsg->Attribute("cwe"); + // cppcheck-suppress templateInstantiation - TODO: fix this - see #11631 cwe.id = attr ? strToInt(attr) : 0; attr = errmsg->Attribute("inconclusive"); diff --git a/lib/fwdanalysis.cpp b/lib/fwdanalysis.cpp index 1dd44759d02..e43b5dfec08 100644 --- a/lib/fwdanalysis.cpp +++ b/lib/fwdanalysis.cpp @@ -317,6 +317,7 @@ FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const Token * // ({ .. }) if (hasGccCompoundStatement(parent->astParent()->astOperand2())) return Result(Result::Type::BAILOUT); + // cppcheck-suppress shadowFunction - TODO: fix this const bool reassign = isSameExpression(mCpp, false, expr, parent, mLibrary, false, false, nullptr); if (reassign) return Result(Result::Type::WRITE, parent->astParent()); diff --git a/lib/library.cpp b/lib/library.cpp index 9ce1a4f36aa..f1058c7883a 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -392,8 +392,10 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc) if (end) mExecutableBlocks[extension].setEnd(end); const char * offset = blocknode->Attribute("offset"); - if (offset) + if (offset) { + // cppcheck-suppress templateInstantiation - TODO: fix this - see #11631 mExecutableBlocks[extension].setOffset(strToInt(offset)); + } } else @@ -706,6 +708,7 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co mReturnValueType[name] = type; if (const char *container = functionnode->Attribute("container")) mReturnValueContainer[name] = strToInt(container); + // cppcheck-suppress shadowFunction - TODO: fix this if (const char *unknownReturnValues = functionnode->Attribute("unknownValues")) { if (std::strcmp(unknownReturnValues, "all") == 0) { std::vector values{LLONG_MIN, LLONG_MAX}; @@ -1305,6 +1308,7 @@ bool Library::isCompliantValidationExpression(const char* p) error |= (*(p + 1) == '-'); } else if (*p == ':') { + // cppcheck-suppress bitwiseOnBoolean - TODO: fix this error |= range | (*(p + 1) == '.'); range = true; has_dot = false; @@ -1319,6 +1323,7 @@ bool Library::isCompliantValidationExpression(const char* p) has_dot = false; has_E = false; } else if (*p == '.') { + // cppcheck-suppress bitwiseOnBoolean - TODO: fix this error |= has_dot | (!std::isdigit(*(p + 1))); has_dot = true; } else if (*p == 'E' || *p == 'e') { diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index ac053cfe52d..960deb886c6 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2364,6 +2364,7 @@ const Type* Variable::smartPointerType() const while (Token::Match(typeTok, "%name%|::")) typeTok = typeTok->next(); if (Token::Match(typeTok, "< %name% >")) { + // cppcheck-suppress shadowFunction - TODO: fix this const Scope* scope = typeTok->scope(); const Type* ptrType{}; while (scope && !ptrType) { diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index e1af536d3e8..e156e4be792 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -2946,6 +2946,7 @@ bool TemplateSimplifier::matchSpecialization( startToken = startToken->previous(); if (!Token::simpleMatch(startToken, "template <")) continue; + // cppcheck-suppress shadowFunction - TODO: fix this std::vector templateParameters; getTemplateParametersInDeclaration(startToken->tokAt(2), templateParameters); diff --git a/lib/token.cpp b/lib/token.cpp index be6d7730e97..e77b2dfcf38 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -316,11 +316,13 @@ void Token::swapWithNext() std::swap(mFlags, mNext->mFlags); std::swap(mImpl, mNext->mImpl); if (mImpl->mTemplateSimplifierPointers) + // cppcheck-suppress shadowFunction - TODO: fix this for (auto *templateSimplifierPointer : *mImpl->mTemplateSimplifierPointers) { templateSimplifierPointer->token(this); } if (mNext->mImpl->mTemplateSimplifierPointers) + // cppcheck-suppress shadowFunction - TODO: fix this for (auto *templateSimplifierPointer : *mNext->mImpl->mTemplateSimplifierPointers) { templateSimplifierPointer->token(mNext); } @@ -341,6 +343,7 @@ void Token::takeData(Token *fromToken) mImpl = fromToken->mImpl; fromToken->mImpl = nullptr; if (mImpl->mTemplateSimplifierPointers) + // cppcheck-suppress shadowFunction - TODO: fix this for (auto *templateSimplifierPointer : *mImpl->mTemplateSimplifierPointers) { templateSimplifierPointer->token(this); } @@ -636,6 +639,7 @@ bool Token::simpleMatch(const Token *tok, const char pattern[], size_t pattern_l return false; // shortcut const char *current = pattern; const char *end = pattern + pattern_len; + // cppcheck-suppress shadowFunction - TODO: fix this const char *next = static_cast(std::memchr(pattern, ' ', pattern_len)); if (!next) next = end; @@ -781,6 +785,7 @@ nonneg int Token::getStrLength(const Token *tok) assert(tok->mTokType == eString); int len = 0; + // cppcheck-suppress shadowFunction - TODO: fix this const std::string str(getStringLiteral(tok->str())); std::string::const_iterator it = str.cbegin(); const std::string::const_iterator end = str.cend(); @@ -808,6 +813,7 @@ nonneg int Token::getStrArraySize(const Token *tok) { assert(tok != nullptr); assert(tok->tokType() == eString); + // cppcheck-suppress shadowFunction - TODO: fix this const std::string str(getStringLiteral(tok->str())); int sizeofstring = 1; for (int i = 0; i < (int)str.size(); i++) { @@ -1110,6 +1116,7 @@ Token* Token::insertToken(const std::string& tokenStr, const std::string& origin tok1 = tok1->previous()->findOpeningBracket(); if (tok1 && Token::Match(tok1->tokAt(-3), "%name% :: %name%")) { tok1 = tok1->tokAt(-2); + // cppcheck-suppress shadowFunction - TODO: fix this std::string scope = tok1->strAt(-1); while (Token::Match(tok1->tokAt(-2), ":: %name%")) { scope = tok1->strAt(-3) + " :: " + scope; @@ -1285,6 +1292,7 @@ std::string Token::stringifyList(const stringifyOptions& options, const std::vec std::string ret; unsigned int lineNumber = mImpl->mLineNumber - (options.linenumbers ? 1U : 0U); + // cppcheck-suppress shadowFunction - TODO: fix this unsigned int fileIndex = options.files ? ~0U : mImpl->mFileIndex; std::map lineNumbers; for (const Token *tok = this; tok != end; tok = tok->next()) { @@ -1701,6 +1709,7 @@ void Token::printValueFlow(bool xml, std::ostream &out) const { std::string outs; + // cppcheck-suppress shadowFunction int fileIndex = -1; int line = 0; if (xml) @@ -1708,6 +1717,7 @@ void Token::printValueFlow(bool xml, std::ostream &out) const else outs += "\n\n##Value flow\n"; for (const Token *tok = this; tok; tok = tok->next()) { + // cppcheck-suppress shadowFunction - TODO: fix this const auto* const values = tok->mImpl->mValues; if (!values) continue; @@ -2246,6 +2256,7 @@ void Token::assignProgressValues(Token *tok) void Token::assignIndexes() { + // cppcheck-suppress shadowFunction - TODO: fix this int index = (mPrevious ? mPrevious->mImpl->mIndex : 0) + 1; for (Token *tok = this; tok; tok = tok->next()) tok->mImpl->mIndex = index++; @@ -2283,9 +2294,11 @@ const ::Type* Token::typeOf(const Token* tok, const Token** typeTok) if (tok->function()) return tok->function()->retType; if (Token::simpleMatch(tok, "return")) { + // cppcheck-suppress shadowFunction - TODO: fix this const Scope *scope = tok->scope(); if (!scope) return nullptr; + // cppcheck-suppress shadowFunction - TODO: fix this const Function *function = scope->function; if (!function) return nullptr; @@ -2395,15 +2408,18 @@ std::pair Token::typeDecl(const Token* tok, bool poi return {var->typeStartToken(), var->typeEndToken()->next()}; } if (Token::simpleMatch(tok, "return")) { + // cppcheck-suppress shadowFunction - TODO: fix this const Scope* scope = tok->scope(); if (!scope) return {}; + // cppcheck-suppress shadowFunction - TODO: fix this const Function* function = scope->function; if (!function) return {}; return { function->retDef, function->returnDefEnd() }; } if (tok->previous() && tok->previous()->function()) { + // cppcheck-suppress shadowFunction - TODO: fix this const Function *function = tok->previous()->function(); return {function->retDef, function->returnDefEnd()}; } diff --git a/tools/triage/mainwindow.cpp b/tools/triage/mainwindow.cpp index 22ffe8e536d..27aa47b5b6e 100644 --- a/tools/triage/mainwindow.cpp +++ b/tools/triage/mainwindow.cpp @@ -359,6 +359,7 @@ void MainWindow::findInFilesClicked() ui->inFilesResult->clear(); const QString text = ui->filterEdit->text(); + // cppcheck-suppress shadowFunction - TODO: fix this QStringList filter; if (ui->hFilesFilter->isChecked()) filter.append(hFiles);