Skip to content

Commit 4182f94

Browse files
authored
use more granular suppressions in selfcheck and prefer inline suppressions (#5703)
1 parent d6a1a65 commit 4182f94

14 files changed

+54
-17
lines changed

.selfcheck_suppressions

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
missingIncludeSystem
2-
shadowFunction
3-
bitwiseOnBoolean
42

53
# temporary suppressions - fix the warnings!
64
simplifyUsing:lib/valueptr.h
75
varid0:gui/projectfile.cpp
86
naming-privateMemberVariable:gui/test/cppchecklibrarydata/testcppchecklibrarydata.h
9-
templateInstantiation
107
symbolDatabaseWarning:*/moc_*.cpp
118
simplifyUsing:*/moc_*.cpp
129

@@ -19,10 +16,13 @@ functionStatic:*/ui_fileview.h
1916
valueFlowBailout
2017
valueFlowBailoutIncompleteVar
2118
autoNoType
22-
bailoutUninitVar
2319

2420
naming-varname:externals/simplecpp/simplecpp.h
2521
naming-privateMemberVariable:externals/simplecpp/simplecpp.h
26-
# TODO: use more granular suppressions - might expose false positives
27-
*:externals/picojson/*
28-
*:externals/tinyxml2/*
22+
23+
# these warnings need to be addressed upstream
24+
uninitMemberVar:externals/tinyxml2/tinyxml2.h
25+
noExplicitConstructor:externals/tinyxml2/tinyxml2.h
26+
missingOverride:externals/tinyxml2/tinyxml2.h
27+
invalidPrintfArgType_sint:externals/tinyxml2/tinyxml2.h
28+
naming-privateMemberVariable:externals/tinyxml2/tinyxml2.h

gui/resultstree.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,8 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
643643
}
644644

645645
//Create an action for the application
646-
QAction *recheckSelectedFiles = new QAction(tr("Recheck"), &menu);
647-
QAction *copy = new QAction(tr("Copy"), &menu);
646+
QAction *recheckAction = new QAction(tr("Recheck"), &menu);
647+
QAction *copyAction = new QAction(tr("Copy"), &menu);
648648
QAction *hide = new QAction(tr("Hide"), &menu);
649649
QAction *hideallid = new QAction(tr("Hide all with id"), &menu);
650650
QAction *opencontainingfolder = new QAction(tr("Open containing folder"), &menu);
@@ -654,13 +654,13 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
654654
opencontainingfolder->setDisabled(true);
655655
}
656656
if (mThread->isChecking())
657-
recheckSelectedFiles->setDisabled(true);
657+
recheckAction->setDisabled(true);
658658
else
659-
recheckSelectedFiles->setDisabled(false);
659+
recheckAction->setDisabled(false);
660660

661-
menu.addAction(recheckSelectedFiles);
661+
menu.addAction(recheckAction);
662662
menu.addSeparator();
663-
menu.addAction(copy);
663+
menu.addAction(copyAction);
664664
menu.addSeparator();
665665
menu.addAction(hide);
666666
menu.addAction(hideallid);
@@ -672,8 +672,8 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
672672
menu.addSeparator();
673673
menu.addAction(opencontainingfolder);
674674

675-
connect(recheckSelectedFiles, SIGNAL(triggered()), this, SLOT(recheckSelectedFiles()));
676-
connect(copy, SIGNAL(triggered()), this, SLOT(copy()));
675+
connect(recheckAction, SIGNAL(triggered()), this, SLOT(recheckAction()));
676+
connect(copyAction, SIGNAL(triggered()), this, SLOT(copyAction()));
677677
connect(hide, SIGNAL(triggered()), this, SLOT(hideResult()));
678678
connect(hideallid, SIGNAL(triggered()), this, SLOT(hideAllIdResult()));
679679
connect(opencontainingfolder, SIGNAL(triggered()), this, SLOT(openContainingFolder()));

lib/checkbufferoverrun.cpp

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

954954
Check::FileInfo * CheckBufferOverrun::loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const
955955
{
956+
// cppcheck-suppress shadowFunction - TODO: fix this
956957
const std::string arrayIndex("array-index");
957958
const std::string pointerArith("pointer-arith");
958959

lib/checkclass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,6 +2479,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, Member
24792479
return false;
24802480
const Token* assignTok = end->next()->astParent();
24812481
if (var && assignTok && assignTok->isAssignmentOp() && assignTok->astOperand1() && assignTok->astOperand1()->variable()) {
2482+
// cppcheck-suppress shadowFunction - TODO: fix this
24822483
const Variable* assignVar = assignTok->astOperand1()->variable();
24832484
if (assignVar->isPointer() && !assignVar->isConst() && var->typeScope()) {
24842485
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
@@ -1062,6 +1062,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
10621062
const std::time_t maxTime = mSettings.checksMaxTime > 0 ? std::time(nullptr) + mSettings.checksMaxTime : 0;
10631063

10641064
// call all "runChecks" in all registered Check classes
1065+
// cppcheck-suppress shadowFunction - TODO: fix this
10651066
for (Check *check : Check::instances()) {
10661067
if (Settings::terminated())
10671068
return;
@@ -1104,6 +1105,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
11041105
mAnalyzerInformation.setFileInfo("ctu", fi1->toString());
11051106
}
11061107

1108+
// cppcheck-suppress shadowFunction - TODO: fix this
11071109
for (const Check *check : Check::instances()) {
11081110
if (doUnusedFunctionOnly && dynamic_cast<const CheckUnusedFunctions*>(check) == nullptr)
11091111
continue;
@@ -1735,6 +1737,7 @@ bool CppCheck::analyseWholeProgram()
17351737
ctu.nestedCalls.insert(ctu.nestedCalls.end(), fi2->nestedCalls.cbegin(), fi2->nestedCalls.cend());
17361738
}
17371739
}
1740+
// cppcheck-suppress shadowFunction - TODO: fix this
17381741
for (Check *check : Check::instances())
17391742
errors |= check->analyseWholeProgram(&ctu, mFileInfo, mSettings, *this); // TODO: ctu
17401743
return errors && (mExitCode > 0);
@@ -1785,6 +1788,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::list<
17851788
ctuFileInfo.loadFromXml(e);
17861789
continue;
17871790
}
1791+
// cppcheck-suppress shadowFunction - TODO: fix this
17881792
for (const Check *check : Check::instances()) {
17891793
if (checkClassAttr == check->name())
17901794
fileInfoList.push_back(check->loadFileInfoFromXml(e));
@@ -1796,6 +1800,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::list<
17961800
CTU::maxCtuDepth = mSettings.maxCtuDepth;
17971801

17981802
// Analyse the tokens
1803+
// cppcheck-suppress shadowFunction - TODO: fix this
17991804
for (Check *check : Check::instances())
18001805
check->analyseWholeProgram(&ctuFileInfo, fileInfoList, mSettings, *this);
18011806

lib/errorlogger.cpp

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

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

174175
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
@@ -392,8 +392,10 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
392392
if (end)
393393
mExecutableBlocks[extension].setEnd(end);
394394
const char * offset = blocknode->Attribute("offset");
395-
if (offset)
395+
if (offset) {
396+
// cppcheck-suppress templateInstantiation - TODO: fix this - see #11631
396397
mExecutableBlocks[extension].setOffset(strToInt<int>(offset));
398+
}
397399
}
398400

399401
else
@@ -706,6 +708,7 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
706708
mReturnValueType[name] = type;
707709
if (const char *container = functionnode->Attribute("container"))
708710
mReturnValueContainer[name] = strToInt<int>(container);
711+
// cppcheck-suppress shadowFunction - TODO: fix this
709712
if (const char *unknownReturnValues = functionnode->Attribute("unknownValues")) {
710713
if (std::strcmp(unknownReturnValues, "all") == 0) {
711714
std::vector<MathLib::bigint> values{LLONG_MIN, LLONG_MAX};
@@ -1305,6 +1308,7 @@ bool Library::isCompliantValidationExpression(const char* p)
13051308
error |= (*(p + 1) == '-');
13061309
}
13071310
else if (*p == ':') {
1311+
// cppcheck-suppress bitwiseOnBoolean - TODO: fix this
13081312
error |= range | (*(p + 1) == '.');
13091313
range = true;
13101314
has_dot = false;
@@ -1319,6 +1323,7 @@ bool Library::isCompliantValidationExpression(const char* p)
13191323
has_dot = false;
13201324
has_E = false;
13211325
} else if (*p == '.') {
1326+
// cppcheck-suppress bitwiseOnBoolean - TODO: fix this
13221327
error |= has_dot | (!std::isdigit(*(p + 1)));
13231328
has_dot = true;
13241329
} else if (*p == 'E' || *p == 'e') {

0 commit comments

Comments
 (0)