diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 5bc10fcef..d48547e0d 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -814,7 +814,7 @@ void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processe fin.open(cur.c_str()); if (!fin.is_open()) { - if (_settings && !_settings->nomsg.isSuppressed("missingInclude", cur, 1)) { + if (_settings && !_settings->nomsg.isSuppressed("missingInclude", Path::fromNativeSeparators(cur), 1)) { missingIncludeFlag = true; if (_settings->checkConfiguration) { missingInclude(Path::toNativeSeparators(Path::getPathFromFilename(cur)), @@ -2088,7 +2088,7 @@ std::string Preprocessor::handleIncludes(const std::string &code, const std::str filepath = path; std::ifstream fin; if (!openHeader(filename, includePaths, filepath, fin)) { - if (_settings && !_settings->nomsg.isSuppressed("missingInclude", filename, linenr)) { + if (_settings && !_settings->nomsg.isSuppressed("missingInclude", Path::fromNativeSeparators(filename), linenr)) { missingIncludeFlag = true; if (_settings->checkConfiguration) @@ -2216,7 +2216,7 @@ void Preprocessor::handleIncludes(std::string &code, const std::string &filePath } } - if (!_settings->nomsg.isSuppressed("missingInclude", f, linenr)) { + if (!_settings->nomsg.isSuppressed("missingInclude", Path::fromNativeSeparators(f), linenr)) { missingIncludeFlag = true; if (_errorLogger && _settings->checkConfiguration) { missingInclude(Path::toNativeSeparators(f), diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 307e1ebc8..f318dd0e1 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -87,7 +87,7 @@ std::string Suppressions::addSuppressionLine(const std::string &line) } // We could perhaps check if the id is valid and return error if it is not - const std::string errmsg(addSuppression(id, file, lineNumber)); + const std::string errmsg(addSuppression(id, Path::fromNativeSeparators(file), lineNumber)); if (!errmsg.empty()) return errmsg; diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 7fa46ebc2..e98d5e513 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -41,6 +41,7 @@ private: TEST_CASE(suppressionsFileNameWithExtraPath); TEST_CASE(suppressionsSettings); TEST_CASE(suppressionsMultiFile); + TEST_CASE(suppressionsPathSeparator); TEST_CASE(inlinesuppress_unusedFunction); // #4210 - unusedFunction } @@ -66,9 +67,9 @@ private: Suppressions suppressions; std::istringstream s("errorid:c:\\foo.cpp\nerrorid:c:\\bar.cpp:12"); ASSERT_EQUALS("", suppressions.parseFile(s)); - ASSERT_EQUALS(true, suppressions.isSuppressed("errorid", "c:\\foo.cpp", 1111)); - ASSERT_EQUALS(false, suppressions.isSuppressed("errorid", "c:\\bar.cpp", 10)); - ASSERT_EQUALS(true, suppressions.isSuppressed("errorid", "c:\\bar.cpp", 12)); + ASSERT_EQUALS(true, suppressions.isSuppressed("errorid", "c:/foo.cpp", 1111)); + ASSERT_EQUALS(false, suppressions.isSuppressed("errorid", "c:/bar.cpp", 10)); + ASSERT_EQUALS(true, suppressions.isSuppressed("errorid", "c:/bar.cpp", 12)); } void suppressionsGlob() const { @@ -313,6 +314,12 @@ private: ASSERT_EQUALS("", errout.str()); } + void suppressionsPathSeparator() const { + Suppressions suppressions; + suppressions.addSuppressionLine("*:test\\*"); + ASSERT_EQUALS(true, suppressions.isSuppressed("someid", "test/foo/bar.cpp", 142)); + } + void inlinesuppress_unusedFunction() const { // #4210 - wrong report of "unmatchedSuppression" for "unusedFunction" Suppressions suppressions; suppressions.addSuppression("unusedFunction", "test.c", 3U);