Skip to content

Commit 29f9e3c

Browse files
committed
fixed #13810 - fixed missing column for unmatchedSuppression [skip ci]
1 parent b9e6ace commit 29f9e3c

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static std::vector<ErrorMessage> getUnmatchedSuppressions(const std::list<Suppre
329329

330330
std::list<ErrorMessage::FileLocation> callStack;
331331
if (!s.fileName.empty()) {
332-
callStack.emplace_back(s.fileName, s.lineNumber == -1 ? 0 : s.lineNumber, 0); // TODO: set column - see #13810 / get rid of s.lineNumber == -1 hack
332+
callStack.emplace_back(s.fileName, s.lineNumber == -1 ? 0 : s.lineNumber, s.column); // TODO: get rid of s.lineNumber == -1 hack
333333
}
334334
const std::string unmatchedSuppressionId = s.isPolyspace ? "unmatchedPolyspaceSuppression" : "unmatchedSuppression";
335335
errors.emplace_back(std::move(callStack), "", Severity::information, "Unmatched suppression: " + s.errorId, unmatchedSuppressionId, Certainty::normal);

cli/processexecutor.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ namespace {
113113
{
114114
std::string suppr_str = suppr.toString();
115115
suppr_str += ";";
116+
suppr_str += std::to_string(suppr.column);
117+
suppr_str += ";";
116118
suppr_str += suppr.checked ? "1" : "0";
117119
suppr_str += ";";
118120
suppr_str += suppr.matched ? "1" : "0";
@@ -241,18 +243,19 @@ bool ProcessExecutor::handleRead(int rpipe, unsigned int &result, const std::str
241243
if (!buf.empty()) {
242244
// TODO: avoid string splitting
243245
auto parts = splitString(buf, ';');
244-
if (parts.size() < 4)
246+
if (parts.size() < 5)
245247
{
246248
// TODO: make this non-fatal
247249
std::cerr << "#### ThreadExecutor::handleRead(" << filename << ") adding of inline suppression failed - insufficient data" << std::endl;
248250
std::exit(EXIT_FAILURE);
249251
}
250252
auto suppr = SuppressionList::parseLine(parts[0]);
251253
suppr.isInline = (type == PipeWriter::REPORT_SUPPR_INLINE);
252-
suppr.checked = parts[1] == "1";
253-
suppr.matched = parts[2] == "1";
254-
suppr.extraComment = parts[3];
255-
for (std::size_t i = 4; i < parts.size(); i++) {
254+
suppr.column = strToInt<int>(parts[1]);
255+
suppr.checked = parts[2] == "1";
256+
suppr.matched = parts[3] == "1";
257+
suppr.extraComment = parts[4];
258+
for (std::size_t i = 5; i < parts.size(); i++) {
256259
suppr.extraComment += ";" + parts[i];
257260
}
258261
const std::string err = mSuppressions.nomsg.addSuppression(suppr);

test/testsuppressions.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ class TestSuppressions : public TestFixture {
528528
" b++;\n"
529529
"}\n",
530530
""));
531-
ASSERT_EQUALS("[test.cpp:1:0]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str());
531+
ASSERT_EQUALS("[test.cpp:1:1]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str());
532532

533533
// suppress uninitvar for this file only
534534
ASSERT_EQUALS(0, (this->*check)("void f() {\n"
@@ -706,7 +706,7 @@ class TestSuppressions : public TestFixture {
706706
" b++;\n"
707707
"}\n",
708708
""));
709-
ASSERT_EQUALS("[test.cpp:4:0]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str());
709+
ASSERT_EQUALS("[test.cpp:4:5]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str());
710710

711711
// suppress block inline checks
712712
ASSERT_EQUALS(0, (this->*check)("void f() {\n"
@@ -889,7 +889,7 @@ class TestSuppressions : public TestFixture {
889889
" // cppcheck-suppress-end [uninitvar, syntaxError]\n"
890890
"}\n",
891891
""));
892-
ASSERT_EQUALS("[test.cpp:2:0]: (information) Unmatched suppression: syntaxError [unmatchedSuppression]\n", errout_str());
892+
ASSERT_EQUALS("[test.cpp:2:5]: (information) Unmatched suppression: syntaxError [unmatchedSuppression]\n", errout_str());
893893

894894
ASSERT_EQUALS(1, (this->*check)("// cppcheck-suppress-begin [uninitvar, syntaxError]\n"
895895
"void f() {\n"
@@ -904,7 +904,7 @@ class TestSuppressions : public TestFixture {
904904
"}\n"
905905
"// cppcheck-suppress-end [uninitvar, syntaxError]\n",
906906
""));
907-
ASSERT_EQUALS("[test.cpp:1:0]: (information) Unmatched suppression: syntaxError [unmatchedSuppression]\n", errout_str());
907+
ASSERT_EQUALS("[test.cpp:1:1]: (information) Unmatched suppression: syntaxError [unmatchedSuppression]\n", errout_str());
908908

909909
ASSERT_EQUALS(1, (this->*check)("// cppcheck-suppress-begin [uninitvar, syntaxError]\n"
910910
"void f() {\n"
@@ -919,7 +919,7 @@ class TestSuppressions : public TestFixture {
919919
"}\n"
920920
"// cppcheck-suppress-end [uninitvar, syntaxError]",
921921
""));
922-
ASSERT_EQUALS("[test.cpp:1:0]: (information) Unmatched suppression: syntaxError [unmatchedSuppression]\n", errout_str());
922+
ASSERT_EQUALS("[test.cpp:1:1]: (information) Unmatched suppression: syntaxError [unmatchedSuppression]\n", errout_str());
923923

924924
// test of multiple suppression types
925925
ASSERT_EQUALS(0, (this->*check)("// cppcheck-suppress-file uninitvar\n"
@@ -969,7 +969,7 @@ class TestSuppressions : public TestFixture {
969969
" a++;\n"
970970
"}\n",
971971
""));
972-
ASSERT_EQUALS("[test.cpp:4:0]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str());
972+
ASSERT_EQUALS("[test.cpp:4:5]: (information) Unmatched suppression: uninitvar [unmatchedSuppression]\n", errout_str());
973973

974974
// #5746 - exitcode
975975
ASSERT_EQUALS(1U,
@@ -998,7 +998,7 @@ class TestSuppressions : public TestFixture {
998998
"#define DIV(A,B) A/B\n"
999999
"a = DIV(10,1);\n",
10001000
"");
1001-
ASSERT_EQUALS("[test.cpp:2:0]: (information) Unmatched suppression: abc [unmatchedSuppression]\n", errout_str());
1001+
ASSERT_EQUALS("[test.cpp:2:1]: (information) Unmatched suppression: abc [unmatchedSuppression]\n", errout_str());
10021002
}
10031003

10041004
void suppressionsSettingsFiles() {

0 commit comments

Comments
 (0)