Skip to content

Commit 003fc18

Browse files
committed
set proper line for file-level unmatchedSuppression
1 parent 8840415 commit 003fc18

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cli/cppcheckexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static std::vector<::ErrorMessage> reportUnmatchedSuppressions(const std::list<S
328328

329329
std::list<::ErrorMessage::FileLocation> callStack;
330330
if (!s.fileName.empty()) {
331-
callStack.emplace_back(s.fileName, s.lineNumber, 0);
331+
callStack.emplace_back(s.fileName, s.lineNumber == -1 ? 0 : s.lineNumber, 0); // TODO: get rid of s.lineNumber == -1 hack
332332
}
333333
const std::string unmatchedSuppressionId = s.isPolyspace ? "unmatchedPolyspaceSuppression" : "unmatchedSuppression";
334334
auto errmsg = ::ErrorMessage(std::move(callStack), "", Severity::information, "Unmatched suppression: " + s.errorId, unmatchedSuppressionId, Certainty::normal);

test/testsuppressions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class TestSuppressions : public TestFixture {
542542
" b++;\n"
543543
"}\n",
544544
"uninitvar:test.cpp"));
545-
ASSERT_EQUALS("[test.cpp]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str());
545+
ASSERT_EQUALS("[test.cpp:0:0]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str());
546546

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

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

0 commit comments

Comments
 (0)