Don't use native separators for suppression matching
This commit is contained in:
parent
14feaa8d39
commit
2333aa2cc7
|
@ -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),
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue