Skip to content

Commit fd98ecc

Browse files
committed
use inline suppressions
1 parent a613a7c commit fd98ecc

13 files changed

+38
-16
lines changed

.selfcheck_suppressions

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@ missingIncludeSystem
22

33
# temporary suppressions - fix the warnings!
44
simplifyUsing:lib/valueptr.h
5-
bitwiseOnBoolean:lib/library.cpp
6-
templateInstantiation:lib/checkunusedfunctions.cpp
7-
templateInstantiation:lib/errorlogger.cpp
8-
templateInstantiation:lib/liobrary.cpp
9-
shadowFunction:lib/checkbufferoverrun.cpp
10-
shadowFunction:lib/checkclass.cpp
11-
shadowFunction:lib/checknullpointer.cpp
12-
shadowFunction:lib/cppcheck.cpp
13-
shadowFunction:lib/fwdanalysis.cpp
14-
shadowFunction:lib/library.cpp
15-
shadowFunction:lib/symboldatabase.cpp
16-
shadowFunction:lib/templatesimplifier.cpp
17-
shadowFunction:lib/token.cpp
18-
shadowFunction:tools/triage/mainwindow.cpp
195

206
# warnings in Qt generated code we cannot fix
217
symbolDatabaseWarning:gui/temp/moc_*.cpp

lib/checkbufferoverrun.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,7 @@ Check::FileInfo *CheckBufferOverrun::getFileInfo(const Tokenizer *tokenizer, con
943943

944944
Check::FileInfo * CheckBufferOverrun::loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const
945945
{
946+
// cppcheck-suppress shadowFunction - TODO: fix this
946947
const std::string arrayIndex("array-index");
947948
const std::string pointerArith("pointer-arith");
948949

lib/checkclass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,6 +2471,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, Member
24712471
return false;
24722472
const Token* assignTok = end->next()->astParent();
24732473
if (var && assignTok && assignTok->isAssignmentOp() && assignTok->astOperand1() && assignTok->astOperand1()->variable()) {
2474+
// cppcheck-suppress shadowFunction - TODO: fix this
24742475
const Variable* assignVar = assignTok->astOperand1()->variable();
24752476
if (assignVar->isPointer() && !assignVar->isConst() && var->typeScope()) {
24762477
const auto& funcMap = var->typeScope()->functionMap;

lib/checknullpointer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ static std::string arithmeticTypeString(const Token *tok)
514514

515515
void CheckNullPointer::pointerArithmeticError(const Token* tok, const ValueFlow::Value *value, bool inconclusive)
516516
{
517+
// cppcheck-suppress shadowFunction - TODO: fix this
517518
std::string arithmetic = arithmeticTypeString(tok);
518519
std::string errmsg;
519520
if (tok && tok->str()[0] == '-') {
@@ -532,6 +533,7 @@ void CheckNullPointer::pointerArithmeticError(const Token* tok, const ValueFlow:
532533

533534
void CheckNullPointer::redundantConditionWarning(const Token* tok, const ValueFlow::Value *value, const Token *condition, bool inconclusive)
534535
{
536+
// cppcheck-suppress shadowFunction - TODO: fix this
535537
std::string arithmetic = arithmeticTypeString(tok);
536538
std::string errmsg;
537539
if (tok && tok->str()[0] == '-') {

lib/checkunusedfunctions.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,10 @@ void CheckUnusedFunctions::analyseWholeProgram(const Settings &settings, ErrorLo
459459
}
460460
if (std::strcmp(e2->Name(),"functiondecl") == 0) {
461461
const char* lineNumber = e2->Attribute("lineNumber");
462-
if (lineNumber)
462+
if (lineNumber) {
463+
// cppcheck-suppress templateInstantiation - TODO: fix this - see #11631
463464
decls[functionName] = Location(sourcefile, strToInt<int>(lineNumber));
465+
}
464466
}
465467
}
466468
}

lib/cppcheck.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
10361036
const std::time_t maxTime = mSettings.checksMaxTime > 0 ? std::time(nullptr) + mSettings.checksMaxTime : 0;
10371037

10381038
// call all "runChecks" in all registered Check classes
1039+
// cppcheck-suppress shadowFunction - TODO: fix this
10391040
for (Check *check : Check::instances()) {
10401041
if (Settings::terminated())
10411042
return;
@@ -1078,6 +1079,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
10781079
mAnalyzerInformation.setFileInfo("ctu", fi1->toString());
10791080
}
10801081

1082+
// cppcheck-suppress shadowFunction - TODO: fix this
10811083
for (const Check *check : Check::instances()) {
10821084
if (doUnusedFunctionOnly && dynamic_cast<const CheckUnusedFunctions*>(check) == nullptr)
10831085
continue;
@@ -1700,6 +1702,7 @@ bool CppCheck::analyseWholeProgram()
17001702
ctu.nestedCalls.insert(ctu.nestedCalls.end(), fi2->nestedCalls.cbegin(), fi2->nestedCalls.cend());
17011703
}
17021704
}
1705+
// cppcheck-suppress shadowFunction - TODO: fix this
17031706
for (Check *check : Check::instances())
17041707
errors |= check->analyseWholeProgram(&ctu, mFileInfo, mSettings, *this); // TODO: ctu
17051708
return errors && (mExitCode > 0);
@@ -1750,6 +1753,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::map<s
17501753
ctuFileInfo.loadFromXml(e);
17511754
continue;
17521755
}
1756+
// cppcheck-suppress shadowFunction - TODO: fix this
17531757
for (const Check *check : Check::instances()) {
17541758
if (checkClassAttr == check->name())
17551759
fileInfoList.push_back(check->loadFileInfoFromXml(e));
@@ -1761,6 +1765,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::map<s
17611765
CTU::maxCtuDepth = mSettings.maxCtuDepth;
17621766

17631767
// Analyse the tokens
1768+
// cppcheck-suppress shadowFunction - TODO: fix this
17641769
for (Check *check : Check::instances())
17651770
check->analyseWholeProgram(&ctuFileInfo, fileInfoList, mSettings, *this);
17661771

lib/errorlogger.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg)
168168
severity = attr ? severityFromString(attr) : Severity::none;
169169

170170
attr = errmsg->Attribute("cwe");
171+
// cppcheck-suppress templateInstantiation - TODO: fix this - see #11631
171172
cwe.id = attr ? strToInt<unsigned short>(attr) : 0;
172173

173174
attr = errmsg->Attribute("inconclusive");

lib/fwdanalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const Token *
317317
// ({ .. })
318318
if (hasGccCompoundStatement(parent->astParent()->astOperand2()))
319319
return Result(Result::Type::BAILOUT);
320+
// cppcheck-suppress shadowFunction - TODO: fix this
320321
const bool reassign = isSameExpression(mCpp, false, expr, parent, mLibrary, false, false, nullptr);
321322
if (reassign)
322323
return Result(Result::Type::WRITE, parent->astParent());

lib/library.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,10 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
390390
if (end)
391391
mExecutableBlocks[extension].setEnd(end);
392392
const char * offset = blocknode->Attribute("offset");
393-
if (offset)
393+
if (offset) {
394+
// cppcheck-suppress templateInstantiation - TODO: fix this - see #11631
394395
mExecutableBlocks[extension].setOffset(strToInt<int>(offset));
396+
}
395397
}
396398

397399
else
@@ -704,6 +706,7 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
704706
mReturnValueType[name] = type;
705707
if (const char *container = functionnode->Attribute("container"))
706708
mReturnValueContainer[name] = strToInt<int>(container);
709+
// cppcheck-suppress shadowFunction - TODO: fix this
707710
if (const char *unknownReturnValues = functionnode->Attribute("unknownValues")) {
708711
if (std::strcmp(unknownReturnValues, "all") == 0) {
709712
std::vector<MathLib::bigint> values{LLONG_MIN, LLONG_MAX};
@@ -1303,6 +1306,7 @@ bool Library::isCompliantValidationExpression(const char* p)
13031306
error |= (*(p + 1) == '-');
13041307
}
13051308
else if (*p == ':') {
1309+
// cppcheck-suppress bitwiseOnBoolean - TODO: fix this
13061310
error |= range | (*(p + 1) == '.');
13071311
range = true;
13081312
has_dot = false;
@@ -1317,6 +1321,7 @@ bool Library::isCompliantValidationExpression(const char* p)
13171321
has_dot = false;
13181322
has_E = false;
13191323
} else if (*p == '.') {
1324+
// cppcheck-suppress bitwiseOnBoolean - TODO: fix this
13201325
error |= has_dot | (!std::isdigit(*(p + 1)));
13211326
has_dot = true;
13221327
} else if (*p == 'E' || *p == 'e') {

lib/symboldatabase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,7 @@ const Type* Variable::smartPointerType() const
23682368
while (Token::Match(typeTok, "%name%|::"))
23692369
typeTok = typeTok->next();
23702370
if (Token::Match(typeTok, "< %name% >")) {
2371+
// cppcheck-suppress shadowFunction - TODO: fix this
23712372
const Scope* scope = typeTok->scope();
23722373
const Type* ptrType{};
23732374
while (scope && !ptrType) {

lib/templatesimplifier.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,6 +2946,7 @@ bool TemplateSimplifier::matchSpecialization(
29462946
startToken = startToken->previous();
29472947
if (!Token::simpleMatch(startToken, "template <"))
29482948
continue;
2949+
// cppcheck-suppress shadowFunction - TODO: fix this
29492950
std::vector<const Token *> templateParameters;
29502951
getTemplateParametersInDeclaration(startToken->tokAt(2), templateParameters);
29512952

lib/token.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,13 @@ void Token::swapWithNext()
316316
std::swap(mFlags, mNext->mFlags);
317317
std::swap(mImpl, mNext->mImpl);
318318
if (mImpl->mTemplateSimplifierPointers)
319+
// cppcheck-suppress shadowFunction - TODO: fix this
319320
for (auto *templateSimplifierPointer : *mImpl->mTemplateSimplifierPointers) {
320321
templateSimplifierPointer->token(this);
321322
}
322323

323324
if (mNext->mImpl->mTemplateSimplifierPointers)
325+
// cppcheck-suppress shadowFunction - TODO: fix this
324326
for (auto *templateSimplifierPointer : *mNext->mImpl->mTemplateSimplifierPointers) {
325327
templateSimplifierPointer->token(mNext);
326328
}
@@ -341,6 +343,7 @@ void Token::takeData(Token *fromToken)
341343
mImpl = fromToken->mImpl;
342344
fromToken->mImpl = nullptr;
343345
if (mImpl->mTemplateSimplifierPointers)
346+
// cppcheck-suppress shadowFunction - TODO: fix this
344347
for (auto *templateSimplifierPointer : *mImpl->mTemplateSimplifierPointers) {
345348
templateSimplifierPointer->token(this);
346349
}
@@ -636,6 +639,7 @@ bool Token::simpleMatch(const Token *tok, const char pattern[], size_t pattern_l
636639
return false; // shortcut
637640
const char *current = pattern;
638641
const char *end = pattern + pattern_len;
642+
// cppcheck-suppress shadowFunction - TODO: fix this
639643
const char *next = static_cast<const char*>(std::memchr(pattern, ' ', pattern_len));
640644
if (!next)
641645
next = end;
@@ -781,6 +785,7 @@ nonneg int Token::getStrLength(const Token *tok)
781785
assert(tok->mTokType == eString);
782786

783787
int len = 0;
788+
// cppcheck-suppress shadowFunction - TODO: fix this
784789
const std::string str(getStringLiteral(tok->str()));
785790
std::string::const_iterator it = str.cbegin();
786791
const std::string::const_iterator end = str.cend();
@@ -808,6 +813,7 @@ nonneg int Token::getStrArraySize(const Token *tok)
808813
{
809814
assert(tok != nullptr);
810815
assert(tok->tokType() == eString);
816+
// cppcheck-suppress shadowFunction - TODO: fix this
811817
const std::string str(getStringLiteral(tok->str()));
812818
int sizeofstring = 1;
813819
for (int i = 0; i < (int)str.size(); i++) {
@@ -1110,6 +1116,7 @@ Token* Token::insertToken(const std::string& tokenStr, const std::string& origin
11101116
tok1 = tok1->previous()->findOpeningBracket();
11111117
if (tok1 && Token::Match(tok1->tokAt(-3), "%name% :: %name%")) {
11121118
tok1 = tok1->tokAt(-2);
1119+
// cppcheck-suppress shadowFunction - TODO: fix this
11131120
std::string scope = tok1->strAt(-1);
11141121
while (Token::Match(tok1->tokAt(-2), ":: %name%")) {
11151122
scope = tok1->strAt(-3) + " :: " + scope;
@@ -1285,6 +1292,7 @@ std::string Token::stringifyList(const stringifyOptions& options, const std::vec
12851292
std::string ret;
12861293

12871294
unsigned int lineNumber = mImpl->mLineNumber - (options.linenumbers ? 1U : 0U);
1295+
// cppcheck-suppress shadowFunction - TODO: fix this
12881296
unsigned int fileIndex = options.files ? ~0U : mImpl->mFileIndex;
12891297
std::map<int, unsigned int> lineNumbers;
12901298
for (const Token *tok = this; tok != end; tok = tok->next()) {
@@ -1707,6 +1715,7 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
17071715
else
17081716
outs += "\n\n##Value flow\n";
17091717
for (const Token *tok = this; tok; tok = tok->next()) {
1718+
// cppcheck-suppress shadowFunction - TODO: fix this
17101719
const auto* const values = tok->mImpl->mValues;
17111720
if (!values)
17121721
continue;
@@ -2239,6 +2248,7 @@ void Token::assignProgressValues(Token *tok)
22392248

22402249
void Token::assignIndexes()
22412250
{
2251+
// cppcheck-suppress shadowFunction - TODO: fix this
22422252
int index = (mPrevious ? mPrevious->mImpl->mIndex : 0) + 1;
22432253
for (Token *tok = this; tok; tok = tok->next())
22442254
tok->mImpl->mIndex = index++;
@@ -2276,9 +2286,11 @@ const ::Type* Token::typeOf(const Token* tok, const Token** typeTok)
22762286
if (tok->function())
22772287
return tok->function()->retType;
22782288
if (Token::simpleMatch(tok, "return")) {
2289+
// cppcheck-suppress shadowFunction - TODO: fix this
22792290
const Scope *scope = tok->scope();
22802291
if (!scope)
22812292
return nullptr;
2293+
// cppcheck-suppress shadowFunction - TODO: fix this
22822294
const Function *function = scope->function;
22832295
if (!function)
22842296
return nullptr;
@@ -2390,15 +2402,18 @@ std::pair<const Token*, const Token*> Token::typeDecl(const Token* tok, bool poi
23902402
return {var->typeStartToken(), var->typeEndToken()->next()};
23912403
}
23922404
if (Token::simpleMatch(tok, "return")) {
2405+
// cppcheck-suppress shadowFunction - TODO: fix this
23932406
const Scope* scope = tok->scope();
23942407
if (!scope)
23952408
return {};
2409+
// cppcheck-suppress shadowFunction - TODO: fix this
23962410
const Function* function = scope->function;
23972411
if (!function)
23982412
return {};
23992413
return { function->retDef, function->returnDefEnd() };
24002414
}
24012415
if (tok->previous() && tok->previous()->function()) {
2416+
// cppcheck-suppress shadowFunction - TODO: fix this
24022417
const Function *function = tok->previous()->function();
24032418
return {function->retDef, function->returnDefEnd()};
24042419
}

tools/triage/mainwindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ void MainWindow::findInFilesClicked()
359359
ui->inFilesResult->clear();
360360
const QString text = ui->filterEdit->text();
361361

362+
// cppcheck-suppress shadowFunction - TODO: fix this
362363
QStringList filter;
363364
if (ui->hFilesFilter->isChecked())
364365
filter.append(hFiles);

0 commit comments

Comments
 (0)