Skip to content

Commit 08473e4

Browse files
authored
refs #13087 - fixed unmatchedSuppression not being shown with cached results and -j2 (danmar#7093)
1 parent c2313ad commit 08473e4

File tree

2 files changed

+69
-6
lines changed

2 files changed

+69
-6
lines changed

lib/cppcheck.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,17 +1260,17 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
12601260
mErrorLogger.reportErr(errmsg);
12611261
}
12621262

1263-
if (analyzerInformation) {
1264-
mLogger->setAnalyzerInfo(nullptr);
1265-
analyzerInformation.reset();
1266-
}
1267-
12681263
// In jointSuppressionReport mode, unmatched suppressions are
12691264
// collected after all files are processed
12701265
if (!mSettings.useSingleJob() && (mSettings.severity.isEnabled(Severity::information) || mSettings.checkConfiguration)) {
12711266
SuppressionList::reportUnmatchedSuppressions(mSettings.supprs.nomsg.getUnmatchedLocalSuppressions(file, (bool)mUnusedFunctionsCheck), mErrorLogger);
12721267
}
12731268

1269+
if (analyzerInformation) {
1270+
mLogger->setAnalyzerInfo(nullptr);
1271+
analyzerInformation.reset();
1272+
}
1273+
12741274
// TODO: clear earlier?
12751275
mLogger->clear();
12761276

test/cli/other_test.py

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2539,4 +2539,67 @@ def test_dump_check_config(tmp_path): # #13432
25392539
assert stderr == ''
25402540

25412541
# no dump file should have been generated
2542-
assert not os.path.exists(str(test_file) + '.dump')
2542+
assert not os.path.exists(str(test_file) + '.dump')
2543+
2544+
2545+
# TODO: remove all overrides when fully fixed
2546+
def __test_inline_suppr(tmp_path, extra_args): # #13087
2547+
test_file = tmp_path / 'test.c'
2548+
with open(test_file, 'wt') as f:
2549+
f.write("""
2550+
void f() {
2551+
// cppcheck-suppress memleak
2552+
}
2553+
""")
2554+
2555+
args = [
2556+
'-q',
2557+
'--template=simple',
2558+
'--enable=information',
2559+
'--inline-suppr',
2560+
str(test_file)
2561+
]
2562+
2563+
args += extra_args
2564+
2565+
exitcode, stdout, stderr, = cppcheck(args)
2566+
assert exitcode == 0, stdout
2567+
assert stdout == ''
2568+
assert stderr.splitlines() == [
2569+
'{}:4:0: information: Unmatched suppression: memleak [unmatchedSuppression]'.format(test_file)
2570+
]
2571+
2572+
2573+
def test_inline_suppr(tmp_path):
2574+
__test_inline_suppr(tmp_path, ['-j1'])
2575+
2576+
2577+
def test_inline_suppr_j(tmp_path):
2578+
__test_inline_suppr(tmp_path, ['-j2'])
2579+
2580+
2581+
def test_inline_suppr_builddir(tmp_path):
2582+
build_dir = tmp_path / 'b1'
2583+
os.mkdir(build_dir)
2584+
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j1'])
2585+
2586+
2587+
@pytest.mark.xfail(strict=True)
2588+
def test_inline_suppr_builddir_cached(tmp_path):
2589+
build_dir = tmp_path / 'b1'
2590+
os.mkdir(build_dir)
2591+
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j1'])
2592+
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j1'])
2593+
2594+
2595+
def test_inline_suppr_builddir_j(tmp_path):
2596+
build_dir = tmp_path / 'b1'
2597+
os.mkdir(build_dir)
2598+
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j2'])
2599+
2600+
2601+
def test_inline_suppr_builddir_j_cached(tmp_path):
2602+
build_dir = tmp_path / 'b1'
2603+
os.mkdir(build_dir)
2604+
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j2'])
2605+
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j2'])

0 commit comments

Comments
 (0)