Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,17 +1260,17 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
mErrorLogger.reportErr(errmsg);
}

if (analyzerInformation) {
mLogger->setAnalyzerInfo(nullptr);
analyzerInformation.reset();
}

// In jointSuppressionReport mode, unmatched suppressions are
// collected after all files are processed
if (!mSettings.useSingleJob() && (mSettings.severity.isEnabled(Severity::information) || mSettings.checkConfiguration)) {
SuppressionList::reportUnmatchedSuppressions(mSettings.supprs.nomsg.getUnmatchedLocalSuppressions(file, (bool)mUnusedFunctionsCheck), mErrorLogger);
}

if (analyzerInformation) {
mLogger->setAnalyzerInfo(nullptr);
analyzerInformation.reset();
}

// TODO: clear earlier?
mLogger->clear();

Expand Down
65 changes: 64 additions & 1 deletion test/cli/other_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2488,4 +2488,67 @@ def test_dump_check_config(tmp_path): # #13432
assert stderr == ''

# no dump file should have been generated
assert not os.path.exists(str(test_file) + '.dump')
assert not os.path.exists(str(test_file) + '.dump')


# TODO: remove all overrides when fully fixed
def __test_inline_suppr(tmp_path, extra_args): # #13087
test_file = tmp_path / 'test.c'
with open(test_file, 'wt') as f:
f.write("""
void f() {
// cppcheck-suppress memleak
}
""")

args = [
'-q',
'--template=simple',
'--enable=information',
'--inline-suppr',
str(test_file)
]

args += extra_args

exitcode, stdout, stderr, = cppcheck(args)
assert exitcode == 0, stdout
assert stdout == ''
assert stderr.splitlines() == [
'{}:4:0: information: Unmatched suppression: memleak [unmatchedSuppression]'.format(test_file)
]


def test_inline_suppr(tmp_path):
__test_inline_suppr(tmp_path, ['-j1'])


def test_inline_suppr_j(tmp_path):
__test_inline_suppr(tmp_path, ['-j2'])


def test_inline_suppr_builddir(tmp_path):
build_dir = tmp_path / 'b1'
os.mkdir(build_dir)
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j1'])


@pytest.mark.xfail(strict=True)
def test_inline_suppr_builddir_cached(tmp_path):
build_dir = tmp_path / 'b1'
os.mkdir(build_dir)
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j1'])
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j1'])


def test_inline_suppr_builddir_j(tmp_path):
build_dir = tmp_path / 'b1'
os.mkdir(build_dir)
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j2'])


def test_inline_suppr_builddir_j_cached(tmp_path):
build_dir = tmp_path / 'b1'
os.mkdir(build_dir)
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j2'])
__test_inline_suppr(tmp_path, ['--cppcheck-build-dir={}'.format(build_dir), '-j2'])