From c6cd63bbe2da077231816eee03ba7a60ce74b555 Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 26 Feb 2026 10:37:50 +0100 Subject: [PATCH] removed `SuppressionList::Suppression::NO_LINE` [skip ci] The suppressions were using `-1` as indication that no line is used but in simplecpp `0` was used for that. --- Makefile | 4 ++-- cli/cppcheckexecutor.cpp | 6 +++--- gui/projectfile.cpp | 3 ++- gui/projectfiledialog.cpp | 4 +++- lib/errorlogger.cpp | 11 ++++------- lib/errorlogger.h | 2 +- lib/importproject.cpp | 2 +- lib/suppressions.cpp | 22 +++++++++++----------- lib/suppressions.h | 12 +++++------- oss-fuzz/Makefile | 2 +- test/testerrorlogger.cpp | 9 ++++----- test/testsuppressions.cpp | 26 +++++++++++++------------- 12 files changed, 50 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index b6f3ea7bd5c..196f6f8fdaf 100644 --- a/Makefile +++ b/Makefile @@ -590,7 +590,7 @@ $(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson/picojson.h external $(libcppdir)/ctu.o: lib/ctu.cpp externals/tinyxml2/tinyxml2.h lib/astutils.h lib/check.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/ctu.cpp -$(libcppdir)/errorlogger.o: lib/errorlogger.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/regex.h lib/settings.h lib/smallvector.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h +$(libcppdir)/errorlogger.o: lib/errorlogger.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/regex.h lib/settings.h lib/smallvector.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/errorlogger.cpp $(libcppdir)/errortypes.o: lib/errortypes.cpp lib/config.h lib/errortypes.h lib/utils.h @@ -785,7 +785,7 @@ test/testconstructors.o: test/testconstructors.cpp lib/addoninfo.h lib/check.h l test/testcppcheck.o: test/testcppcheck.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/regex.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} ${CFLAGS_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcppcheck.cpp -test/testerrorlogger.o: test/testerrorlogger.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/regex.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/xml.h test/fixture.h test/helpers.h +test/testerrorlogger.o: test/testerrorlogger.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/regex.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/xml.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} ${CFLAGS_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testerrorlogger.cpp test/testexceptionsafety.o: test/testexceptionsafety.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/checkexceptionsafety.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/regex.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index a0a2a7bcb0b..62b4c916c9b 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -311,7 +311,7 @@ static std::vector getUnmatchedSuppressions(const std::list getUnmatchedSuppressions(const std::list callStack; if (!s.fileName.empty()) { - callStack.emplace_back(s.fileName, s.lineNumber == -1 ? 0 : s.lineNumber, s.column); // TODO: get rid of s.lineNumber == -1 hack + callStack.emplace_back(s.fileName, s.lineNumber, s.column); } const std::string unmatchedSuppressionId = s.isPolyspace ? "unmatchedPolyspaceSuppression" : "unmatchedSuppression"; errors.emplace_back(std::move(callStack), "", Severity::information, "Unmatched suppression: " + s.errorId, unmatchedSuppressionId, Certainty::normal); @@ -346,7 +346,7 @@ bool CppCheckExecutor::reportUnmatchedSuppressions(const Settings &settings, con auto suppr = suppressions.getSuppressions(); if (std::any_of(suppr.cbegin(), suppr.cend(), [](const SuppressionList::Suppression& s) { // TODO: handle unmatchedPolyspaceSuppression? - return s.errorId == "unmatchedSuppression" && (s.fileName.empty() || s.fileName == "*") && s.lineNumber == SuppressionList::Suppression::NO_LINE; + return s.errorId == "unmatchedSuppression" && (s.fileName.empty() || s.fileName == "*") && s.lineNumber == 0; })) return false; diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index b807723ceeb..8de30e264f5 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -627,7 +627,7 @@ void ProjectFile::readSuppressions(QXmlStreamReader &reader) if (reader.attributes().hasAttribute(QString(),"fileName")) suppression.fileName = reader.attributes().value(QString(),"fileName").toString().toStdString(); if (reader.attributes().hasAttribute(QString(),"lineNumber")) - suppression.lineNumber = reader.attributes().value(QString(),"lineNumber").toInt(); + suppression.lineNumber = reader.attributes().value(QString(),"lineNumber").toUInt(); if (reader.attributes().hasAttribute(QString(),"symbolName")) suppression.symbolName = reader.attributes().value(QString(),"symbolName").toString().toStdString(); if (reader.attributes().hasAttribute(QString(),"hash")) @@ -948,6 +948,7 @@ bool ProjectFile::write(const QString &filename) CppcheckXml::LibraryElementName); if (!mSuppressions.isEmpty()) { + // TODO: merge/align with SuppressionList::dump()? xmlWriter.writeStartElement(CppcheckXml::SuppressionsElementName); for (const SuppressionList::Suppression &suppression : utils::as_const(mSuppressions)) { xmlWriter.writeStartElement(CppcheckXml::SuppressionElementName); diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index d46eb5c3489..64fc173d068 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -91,6 +91,7 @@ static const std::array builtinPlatforms = { Platform::Type::Unix64 }; +// TODO: use SuppressionList::Suppression::toString() instead? static std::string suppressionAsText(const SuppressionList::Suppression& s) { std::string ret; @@ -98,8 +99,9 @@ static std::string suppressionAsText(const SuppressionList::Suppression& s) ret = s.errorId; if (!s.fileName.empty()) ret += " fileName=" + s.fileName; - if (s.lineNumber != SuppressionList::Suppression::NO_LINE) + if (s.lineNumber != 0) ret += " lineNumber=" + std::to_string(s.lineNumber); + // do not include column as suppressions are only line-based if (!s.symbolName.empty()) ret += " symbolName=" + s.symbolName; if (s.hash > 0) diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 07332d94fe9..0d75925d2e4 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -22,7 +22,6 @@ #include "cppcheck.h" #include "path.h" #include "settings.h" -#include "suppressions.h" #include "token.h" #include "tokenlist.h" #include "utils.h" @@ -766,13 +765,11 @@ std::string ErrorMessage::FileLocation::stringify(bool addcolumn) const std::string str; str += '['; str += Path::toNativeSeparators(mFileName); - if (line != SuppressionList::Suppression::NO_LINE) { // TODO: should not depend on Suppression + str += ':'; + str += std::to_string(line); + if (addcolumn) { str += ':'; - str += std::to_string(line); - if (addcolumn) { - str += ':'; - str += std::to_string(column); - } + str += std::to_string(column); } str += ']'; return str; diff --git a/lib/errorlogger.h b/lib/errorlogger.h index d739cb3fbf9..f98cce251a5 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -88,7 +88,7 @@ class CPPCHECKLIB ErrorMessage { std::string stringify(bool addcolumn = false) const; unsigned int fileIndex; - int line; // negative value means "no line" + int line; // TODO: should be unsigned unsigned int column; const std::string& getinfo() const { diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 4033b678d02..3188a343de5 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -1434,7 +1434,7 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings &setti s.fileName = empty_if_null(child->Attribute("fileName")); if (!s.fileName.empty()) s.fileName = joinRelativePath(path, s.fileName); - s.lineNumber = child->IntAttribute("lineNumber", SuppressionList::Suppression::NO_LINE); // TODO: should not depend on Suppression + s.lineNumber = child->UnsignedAttribute("lineNumber", 0); s.symbolName = empty_if_null(child->Attribute("symbolName")); s.hash = strToInt(default_if_null(child->Attribute("hash"), "0")); suppressions.push_back(std::move(s)); diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 70b689e2cdb..524ebce5e0f 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -50,7 +50,7 @@ SuppressionList::ErrorMessage SuppressionList::ErrorMessage::fromErrorMessage(co ret.lineNumber = msg.callStack.back().line; } else { ret.setFileName(msg.file0); - ret.lineNumber = SuppressionList::Suppression::NO_LINE; + ret.lineNumber = 0; } ret.certainty = msg.certainty; ret.symbolNames = msg.symbolNames(); @@ -132,7 +132,7 @@ std::string SuppressionList::parseXmlFile(const char *filename) else if (std::strcmp(name, "fileName") == 0) s.fileName = Path::simplifyPath(text); else if (std::strcmp(name, "lineNumber") == 0) - s.lineNumber = strToInt(text); + s.lineNumber = strToInt(text); else if (std::strcmp(name, "symbolName") == 0) s.symbolName = text; else if (*text && std::strcmp(name, "hash") == 0) @@ -247,7 +247,7 @@ SuppressionList::Suppression SuppressionList::parseLine(std::string line) throw std::runtime_error("filename is missing"); try { - suppression.lineNumber = strToInt(line_s); + suppression.lineNumber = strToInt(line_s); } catch (const std::runtime_error& e) { throw std::runtime_error(std::string("invalid line number (") + e.what() + ")"); } @@ -415,7 +415,7 @@ SuppressionList::Suppression::Result SuppressionList::Suppression::isSuppressed( if (!errorId.empty() && !matchglob(errorId, errmsg.errorId)) return Result::Checked; } else { - if ((SuppressionList::Type::unique == type) && (lineNumber != NO_LINE) && (lineNumber != errmsg.lineNumber)) { + if ((SuppressionList::Type::unique == type) && (lineNumber != 0) && (lineNumber != errmsg.lineNumber)) { if (!thisAndNextLine || lineNumber + 1 != errmsg.lineNumber) return Result::None; } @@ -524,15 +524,15 @@ void SuppressionList::dump(std::ostream & out, const std::string& filePath) cons out << " errorId=\"" << ErrorLogger::toxml(suppression.errorId) << '"'; if (!suppression.fileName.empty()) out << " fileName=\"" << ErrorLogger::toxml(suppression.fileName) << '"'; - if (suppression.lineNumber != Suppression::NO_LINE) + if (suppression.lineNumber != 0) out << " lineNumber=\"" << suppression.lineNumber << '"'; if (!suppression.symbolName.empty()) out << " symbolName=\"" << ErrorLogger::toxml(suppression.symbolName) << '\"'; if (suppression.hash > 0) out << " hash=\"" << suppression.hash << '\"'; - if (suppression.lineBegin != Suppression::NO_LINE) + if (suppression.lineBegin != 0) out << " lineBegin=\"" << suppression.lineBegin << '"'; - if (suppression.lineEnd != Suppression::NO_LINE) + if (suppression.lineEnd != 0) out << " lineEnd=\"" << suppression.lineEnd << '"'; if (suppression.type == SuppressionList::Type::file) out << " type=\"file\""; @@ -565,7 +565,7 @@ std::list SuppressionList::getUnmatchedLocalSuppre continue; if (s.matched) continue; - if ((s.lineNumber != Suppression::NO_LINE) && !s.checked) + if ((s.lineNumber != 0) && !s.checked) continue; if (s.type == SuppressionList::Type::macro) continue; @@ -631,7 +631,7 @@ std::list SuppressionList::getSuppressions() const void SuppressionList::markUnmatchedInlineSuppressionsAsChecked(const TokenList &tokenlist) { std::lock_guard lg(mSuppressionsSync); - int currLineNr = -1; + unsigned int currLineNr = 0; int currFileIdx = -1; for (const Token *tok = tokenlist.front(); tok; tok = tok->next()) { if (currFileIdx != tok->fileIndex() || currLineNr != tok->linenr()) { @@ -661,7 +661,7 @@ std::string SuppressionList::Suppression::toString() const if (!fileName.empty()) { s += ':'; s += fileName; - if (lineNumber != -1) { + if (lineNumber != 0) { s += ':'; s += std::to_string(lineNumber); } @@ -746,7 +746,7 @@ polyspace::CommentKind polyspace::Parser::parseKind(const std::string& comment, } -std::list polyspace::Parser::parse(const std::string &comment, int line, const std::string &filename) const +std::list polyspace::Parser::parse(const std::string &comment, unsigned int line, const std::string &filename) const { // Syntax for a polyspace suppression: // https://se.mathworks.com/help/bugfinder/ug/annotate-hide-known-acceptable-polyspace-results-web-browser.html diff --git a/lib/suppressions.h b/lib/suppressions.h index 849c972d0a7..4c011f62171 100644 --- a/lib/suppressions.h +++ b/lib/suppressions.h @@ -69,7 +69,7 @@ class CPPCHECKLIB SuppressionList { struct CPPCHECKLIB Suppression { Suppression() = default; - Suppression(std::string id, std::string file, int line=NO_LINE) : errorId(std::move(id)), fileName(std::move(file)), lineNumber(line) {} + Suppression(std::string id, std::string file, unsigned int line=0) : errorId(std::move(id)), fileName(std::move(file)), lineNumber(line) {} bool operator<(const Suppression &other) const { if (errorId != other.errorId) @@ -153,9 +153,9 @@ class CPPCHECKLIB SuppressionList { std::string extraComment; // TODO: use simplecpp::Location? int fileIndex{}; - int lineNumber = NO_LINE; // TODO: needs to be unsigned - int lineBegin = NO_LINE; - int lineEnd = NO_LINE; + unsigned int lineNumber{}; + unsigned int lineBegin{}; + unsigned int lineEnd {}; int column{}; Type type = Type::unique; std::string symbolName; @@ -166,8 +166,6 @@ class CPPCHECKLIB SuppressionList { bool checked{}; /** This suppression applied to code which was being analyzed but did not match the error in an isSuppressed() call */ bool isInline{}; bool isPolyspace{}; - - enum : std::int8_t { NO_LINE = -1 }; }; /** @@ -312,7 +310,7 @@ namespace polyspace { Parser() = delete; explicit Parser(const Settings &settings); - std::list parse(const std::string &comment, int line, const std::string &filename) const; + std::list parse(const std::string &comment, unsigned int line, const std::string &filename) const; static int parseRange(const std::string& comment, std::string::size_type& pos); static std::vector> parseFamilyRules(const std::string& comment, std::string::size_type& pos); diff --git a/oss-fuzz/Makefile b/oss-fuzz/Makefile index 1dfa482ae95..77ea6719954 100644 --- a/oss-fuzz/Makefile +++ b/oss-fuzz/Makefile @@ -266,7 +266,7 @@ $(libcppdir)/cppcheck.o: ../lib/cppcheck.cpp ../externals/picojson/picojson.h .. $(libcppdir)/ctu.o: ../lib/ctu.cpp ../externals/tinyxml2/tinyxml2.h ../lib/astutils.h ../lib/check.h ../lib/config.h ../lib/ctu.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/ctu.cpp -$(libcppdir)/errorlogger.o: ../lib/errorlogger.cpp ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/check.h ../lib/checkers.h ../lib/color.h ../lib/config.h ../lib/cppcheck.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/regex.h ../lib/settings.h ../lib/smallvector.h ../lib/standards.h ../lib/suppressions.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h +$(libcppdir)/errorlogger.o: ../lib/errorlogger.cpp ../externals/tinyxml2/tinyxml2.h ../lib/addoninfo.h ../lib/check.h ../lib/checkers.h ../lib/color.h ../lib/config.h ../lib/cppcheck.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/regex.h ../lib/settings.h ../lib/smallvector.h ../lib/standards.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h ../lib/xml.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/errorlogger.cpp $(libcppdir)/errortypes.o: ../lib/errortypes.cpp ../lib/config.h ../lib/errortypes.h ../lib/utils.h diff --git a/test/testerrorlogger.cpp b/test/testerrorlogger.cpp index 01bdfc7f8ce..913dbbf9d5e 100644 --- a/test/testerrorlogger.cpp +++ b/test/testerrorlogger.cpp @@ -22,7 +22,6 @@ #include "errortypes.h" #include "fixture.h" #include "helpers.h" -#include "suppressions.h" #include #include @@ -237,14 +236,14 @@ class TestErrorLogger : public TestFixture { } void FileLocationSetFile2() const { - ErrorMessage::FileLocation loc("foo1.cpp", SuppressionList::Suppression::NO_LINE, 0); // TODO: should not depend on Suppression + ErrorMessage::FileLocation loc("foo1.cpp", 0, 0); loc.setfile("foo.cpp"); ASSERT_EQUALS("foo1.cpp", loc.getOrigFile(false)); ASSERT_EQUALS("foo.cpp", loc.getfile(false)); - ASSERT_EQUALS(SuppressionList::Suppression::NO_LINE, loc.line); + ASSERT_EQUALS(0, loc.line); ASSERT_EQUALS(0, loc.column); - ASSERT_EQUALS("[foo.cpp]", loc.stringify(false)); - ASSERT_EQUALS("[foo.cpp]", loc.stringify(true)); + ASSERT_EQUALS("[foo.cpp:0]", loc.stringify(false)); + ASSERT_EQUALS("[foo.cpp:0:0]", loc.stringify(true)); } void ErrorMessageConstruct() const { diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 3233a5918c7..3b1913f80b0 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -1630,7 +1630,7 @@ class TestSuppressions : public TestFixture { { SuppressionList suppressions; addCheckedSuppression(suppressions, {"abc", "a.c", 10U}); - addCheckedSuppression(suppressions, {"unmatchedSuppression", "*", SuppressionList::Suppression::NO_LINE}); + addCheckedSuppression(suppressions, {"unmatchedSuppression", "*", 0}); ASSERT_EQUALS(false, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this)); ASSERT_EQUALS("", errout_str()); } @@ -1639,7 +1639,7 @@ class TestSuppressions : public TestFixture { { SuppressionList suppressions; addCheckedSuppression(suppressions, {"abc", "a.c", 10U}); - addCheckedSuppression(suppressions, {"unmatchedSuppression", "", SuppressionList::Suppression::NO_LINE}); + addCheckedSuppression(suppressions, {"unmatchedSuppression", "", 0}); ASSERT_EQUALS(false, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this)); ASSERT_EQUALS("", errout_str()); } @@ -1648,7 +1648,7 @@ class TestSuppressions : public TestFixture { { SuppressionList suppressions; addCheckedSuppression(suppressions, {"abc", "a.c", 10U}); - addCheckedSuppression(suppressions, {"unmatchedSuppression", "a.c", SuppressionList::Suppression::NO_LINE}); + addCheckedSuppression(suppressions, {"unmatchedSuppression", "a.c", 0}); ASSERT_EQUALS(false, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this)); ASSERT_EQUALS("", errout_str()); } @@ -1666,7 +1666,7 @@ class TestSuppressions : public TestFixture { { SuppressionList suppressions; addCheckedSuppression(suppressions, {"abc", "a.c", 10U}); - addCheckedSuppression(suppressions, {"unmatchedSuppression", "b.c", SuppressionList::Suppression::NO_LINE}); + addCheckedSuppression(suppressions, {"unmatchedSuppression", "b.c", 0}); ASSERT_EQUALS(true, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this)); ASSERT_EQUALS("[a.c:10:0]: (information) Unmatched suppression: abc [unmatchedSuppression]\n", errout_str()); } @@ -1822,22 +1822,22 @@ class TestSuppressions : public TestFixture { ASSERT_EQUALS("syntaxError", it->errorId); ASSERT_EQUALS("", it->fileName); - ASSERT_EQUALS(SuppressionList::Suppression::NO_LINE, it->lineNumber); + ASSERT_EQUALS(0, it->lineNumber); ++it; ASSERT_EQUALS("uninitvar", it->errorId); ASSERT_EQUALS("1.c", it->fileName); - ASSERT_EQUALS(SuppressionList::Suppression::NO_LINE, it->lineNumber); + ASSERT_EQUALS(0, it->lineNumber); ++it; ASSERT_EQUALS("memleak", it->errorId); ASSERT_EQUALS("1.c", it->fileName); - ASSERT_EQUALS(SuppressionList::Suppression::NO_LINE, it->lineNumber); + ASSERT_EQUALS(0, it->lineNumber); ++it; ASSERT_EQUALS("uninitvar", it->errorId); ASSERT_EQUALS("2.c", it->fileName); - ASSERT_EQUALS(SuppressionList::Suppression::NO_LINE, it->lineNumber); + ASSERT_EQUALS(0, it->lineNumber); ++it; ASSERT_EQUALS("memleak", it->errorId); @@ -1883,7 +1883,7 @@ class TestSuppressions : public TestFixture { const ErrorMessage msg({}, "test1.cpp", Severity::information, "msg", "id", Certainty::inconclusive); const auto msg_s = SuppressionList::ErrorMessage::fromErrorMessage(msg, {"m1", "m2"}); ASSERT_EQUALS("test1.cpp", msg_s.getFileName()); - ASSERT_EQUALS(SuppressionList::Suppression::NO_LINE, msg_s.lineNumber); + ASSERT_EQUALS(0, msg_s.lineNumber); ASSERT_EQUALS("id", msg_s.errorId); ASSERT_EQUALS_ENUM(Certainty::inconclusive, msg_s.certainty); ASSERT_EQUALS("", msg_s.symbolNames); @@ -2052,15 +2052,15 @@ class TestSuppressions : public TestFixture { int lineNumber; std::string extraComment; SuppressionList::Type type = SuppressionList::Type::unique; - int lineBegin = SuppressionList::Suppression::NO_LINE; - int lineEnd = SuppressionList::Suppression::NO_LINE; + int lineBegin = 0; + int lineEnd = 0; PolyspaceParseResult(const std::string &&errorId, int lineNumber, const std::string &&extraComment = "", SuppressionList::Type type = SuppressionList::Type::unique, - int lineBegin = SuppressionList::Suppression::NO_LINE, - int lineEnd = SuppressionList::Suppression::NO_LINE) + int lineBegin = 0, + int lineEnd = 0) : errorId(errorId) , lineNumber(lineNumber) , extraComment(extraComment)