Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static bool reportUnmatchedSuppressions(const std::list<SuppressionList::Suppres

std::list<::ErrorMessage::FileLocation> callStack;
if (!s.fileName.empty()) {
callStack.emplace_back(s.fileName, s.lineNumber, 0);
callStack.emplace_back(s.fileName, s.lineNumber == -1 ? 0 : s.lineNumber, 0); // TODO: get rid of s.lineNumber == -1 hack
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like you should tweak NO_LINE and what reportErr does with the NO_LINE value instead. there are warnings that don't have a line number and we should have a consistent output.

}
const std::string unmatchedSuppressionId = s.isPolyspace ? "unmatchedPolyspaceSuppression" : "unmatchedSuppression";
errorLogger.reportErr(::ErrorMessage(std::move(callStack), "", Severity::information, "Unmatched suppression: " + s.errorId, unmatchedSuppressionId, Certainty::normal));
Expand Down
28 changes: 13 additions & 15 deletions test/cli/other_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3371,11 +3371,10 @@ def test_suppress_unmatched_wildcard(tmp_path): # #13660
exitcode, stdout, stderr = cppcheck(args, cwd=tmp_path)
assert exitcode == 0, stdout
assert stdout.splitlines() == []
# TODO: invalid locations - see #13659
assert stderr.splitlines() == [
'test*.c:-1:0: information: Unmatched suppression: id [unmatchedSuppression]',
'test*.c:-1:0: information: Unmatched suppression: id2 [unmatchedSuppression]',
'tes?.c:-1:0: information: Unmatched suppression: id2 [unmatchedSuppression]'
'test*.c:0:0: information: Unmatched suppression: id [unmatchedSuppression]',
'test*.c:0:0: information: Unmatched suppression: id2 [unmatchedSuppression]',
'tes?.c:0:0: information: Unmatched suppression: id2 [unmatchedSuppression]'
]


Expand All @@ -3400,12 +3399,11 @@ def test_suppress_unmatched_wildcard_unchecked(tmp_path):
exitcode, stdout, stderr = cppcheck(args, cwd=tmp_path)
assert exitcode == 0, stdout
assert stdout.splitlines() == []
# TODO: invalid locations - see #13659
assert stderr.splitlines() == [
'test*.c:-1:0: information: Unmatched suppression: id [unmatchedSuppression]',
'tes?.c:-1:0: information: Unmatched suppression: id [unmatchedSuppression]',
'*:-1:0: information: Unmatched suppression: id2 [unmatchedSuppression]',
'test*.c:-1:0: information: Unmatched suppression: * [unmatchedSuppression]'
'test*.c:0:0: information: Unmatched suppression: id [unmatchedSuppression]',
'tes?.c:0:0: information: Unmatched suppression: id [unmatchedSuppression]',
'*:0:0: information: Unmatched suppression: id2 [unmatchedSuppression]',
'test*.c:0:0: information: Unmatched suppression: * [unmatchedSuppression]'
]


Expand Down Expand Up @@ -3859,12 +3857,12 @@ def test_unmatched_file(tmp_path): # #14248 / #14249
ret, stdout, stderr = cppcheck(args)
assert stdout == ''
assert stderr.splitlines() == [
f'{lib_file}:-1:0: information: Unmatched suppression: error [unmatchedSuppression]',
f'{lib_file}:-1:0: information: Unmatched suppression: error2 [unmatchedSuppression]',
f'{lib_file}:-1:0: information: Unmatched suppression: error3 [unmatchedSuppression]',
f'{lib_file}:-1:0: information: Unmatched suppression: error4 [unmatchedSuppression]',
f'{lib_file}:-1:0: information: Unmatched suppression: error5 [unmatchedSuppression]',
f'{lib_file}:-1:0: information: Unmatched suppression: error6 [unmatchedSuppression]'
f'{lib_file}:0:0: information: Unmatched suppression: error [unmatchedSuppression]',
f'{lib_file}:0:0: information: Unmatched suppression: error2 [unmatchedSuppression]',
f'{lib_file}:0:0: information: Unmatched suppression: error3 [unmatchedSuppression]',
f'{lib_file}:0:0: information: Unmatched suppression: error4 [unmatchedSuppression]',
f'{lib_file}:0:0: information: Unmatched suppression: error5 [unmatchedSuppression]',
f'{lib_file}:0:0: information: Unmatched suppression: error6 [unmatchedSuppression]'
]
assert ret == 0, stdout

Expand Down
4 changes: 2 additions & 2 deletions test/testsuppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ class TestSuppressions : public TestFixture {
" b++;\n"
"}\n",
"uninitvar:test.cpp"));
ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str());
ASSERT_EQUALS("[test.cpp:0:0]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str());

// suppress all for this file only
ASSERT_EQUALS(0, (this->*check)("void f() {\n"
Expand All @@ -558,7 +558,7 @@ class TestSuppressions : public TestFixture {
" b++;\n"
"}\n",
"*:test.cpp"));
ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: * [unmatchedSuppression]\n", errout_str());
ASSERT_EQUALS("[test.cpp:0:0]: (information) Unmatched suppression: * [unmatchedSuppression]\n", errout_str());

// suppress uninitvar for this file and line
ASSERT_EQUALS(0, (this->*check)("void f() {\n"
Expand Down
Loading