From f15bf03332333e04557cac94095e6ede13edee81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Thu, 15 Oct 2026 10:53:44 +0200 Subject: [PATCH 1/2] test --- test/testsuppressions.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 22ab9e200b2..9460999adb1 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -1124,38 +1124,45 @@ class TestSuppressions : public TestFixture { SuppressionList suppressions1; ASSERT_EQUALS("", suppressions1.parseFile(file1)); ASSERT_EQUALS(true, suppressions1.isSuppressed(errorMessage("abc", "test.cpp", 123))); + ASSERT_EQUALS("", suppressions1.getSuppressions().cbegin()->extraComment); std::istringstream file2("// comment\n" "abc"); SuppressionList suppressions2; ASSERT_EQUALS("", suppressions2.parseFile(file2)); ASSERT_EQUALS(true, suppressions2.isSuppressed(errorMessage("abc", "test.cpp", 123))); + ASSERT_EQUALS("", suppressions2.getSuppressions().cbegin()->extraComment); std::istringstream file3("abc // comment"); SuppressionList suppressions3; ASSERT_EQUALS("", suppressions3.parseFile(file3)); ASSERT_EQUALS(true, suppressions3.isSuppressed(errorMessage("abc", "test.cpp", 123))); + ASSERT_EQUALS("comment", suppressions3.getSuppressions().cbegin()->extraComment); std::istringstream file4("abc\t\t # comment"); SuppressionList suppressions4; ASSERT_EQUALS("", suppressions4.parseFile(file4)); ASSERT_EQUALS(true, suppressions4.isSuppressed(errorMessage("abc", "test.cpp", 123))); + ASSERT_EQUALS("comment", suppressions4.getSuppressions().cbegin()->extraComment); std::istringstream file5("abc:test.cpp\t\t # comment"); SuppressionList suppressions5; ASSERT_EQUALS("", suppressions5.parseFile(file5)); ASSERT_EQUALS(true, suppressions5.isSuppressed(errorMessage("abc", "test.cpp", 123))); + ASSERT_EQUALS("comment", suppressions5.getSuppressions().cbegin()->extraComment); std::istringstream file6("abc:test.cpp:123\t\t # comment with . inside"); SuppressionList suppressions6; ASSERT_EQUALS("", suppressions6.parseFile(file6)); ASSERT_EQUALS(true, suppressions6.isSuppressed(errorMessage("abc", "test.cpp", 123))); + ASSERT_EQUALS("comment with . inside", suppressions6.getSuppressions().cbegin()->extraComment); std::istringstream file7(" // comment\n" // #11450 "abc"); SuppressionList suppressions7; ASSERT_EQUALS("", suppressions7.parseFile(file7)); ASSERT_EQUALS(true, suppressions7.isSuppressed(errorMessage("abc", "test.cpp", 123))); + ASSERT_EQUALS("", suppressions7.getSuppressions().cbegin()->extraComment); } void inlinesuppress() const { From 5da7b3e38cc388be78cf57c55ec6ff496ed4cf0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Thu, 15 Oct 2026 10:53:48 +0200 Subject: [PATCH 2/2] fix --- lib/suppressions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index b158ac48107..c3569e40d85 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -255,6 +255,8 @@ SuppressionList::Suppression SuppressionList::parseLine(std::string line) // Strip any end of line comments std::string::size_type endpos = std::min(line.find('#'), line.find("//")); if (endpos != std::string::npos) { + const std::string::size_type offset = line[endpos] == '#' ? 1 : 2; + suppression.extraComment = trim(line.substr(endpos + offset)); while (endpos > 0 && std::isspace(line[endpos-1])) { endpos--; }