Merge pull request #2727 from jpyllman/fix_simplifypath

fix use simplifyPath() to make sure file name is same as in the checks
This commit is contained in:
Daniel Marjamäki 2020-08-03 15:31:16 +02:00 committed by GitHub
commit 87643ea882
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -373,6 +373,7 @@ void Suppressions::dump(std::ostream & out) const
std::list<Suppressions::Suppression> Suppressions::getUnmatchedLocalSuppressions(const std::string &file, const bool unusedFunctionChecking) const
{
std::string tmpFile = Path::simplifyPath(file);
std::list<Suppression> result;
for (const Suppression &s : mSuppressions) {
if (s.matched)
@ -381,7 +382,7 @@ std::list<Suppressions::Suppression> Suppressions::getUnmatchedLocalSuppressions
continue;
if (!unusedFunctionChecking && s.errorId == "unusedFunction")
continue;
if (file.empty() || !s.isLocal() || s.fileName != file)
if (tmpFile.empty() || !s.isLocal() || s.fileName != tmpFile)
continue;
result.push_back(s);
}

View File

@ -19,3 +19,8 @@ def test_unmatched_suppression():
ret, stdout, stderr = cppcheck(['--inline-suppr', '--enable=information', '--error-exitcode=1', 'proj-inline-suppress/2.c'])
assert ret == 1
assert 'Unmatched suppression: some_warning_id' in stderr
def test_unmatched_suppression_path_with_extra_stuf():
ret, stdout, stderr = cppcheck(['--inline-suppr', '--enable=information', '--error-exitcode=1', './proj-inline-suppress/2.c'])
assert ret == 1
assert 'Unmatched suppression: some_warning_id' in stderr