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
5 changes: 3 additions & 2 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,10 @@ unsigned int CppCheck::checkClang(const std::string &path)
}

try {
std::istringstream ast(output2);
Tokenizer tokenizer(mSettings, this);
Preprocessor preprocessor(mSettings, this);
Tokenizer tokenizer(mSettings, this, &preprocessor);
tokenizer.list.appendFileIfNew(path);
std::istringstream ast(output2);
clangimport::parseClangAstDump(tokenizer, ast);
ValueFlow::setValues(tokenizer.list,
const_cast<SymbolDatabase&>(*tokenizer.getSymbolDatabase()),
Expand Down
13 changes: 12 additions & 1 deletion test/cli/clang-import_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,15 @@ def test_log(tmpdir):
'Checking {} ...'.format(test_file).replace('\\', '/'),
]

assert_cppcheck(args, ec_exp=0, err_exp=[], out_exp=out_lines)
assert_cppcheck(args, ec_exp=0, err_exp=[], out_exp=out_lines)


def test_warning(tmpdir): # #12424
test_file = os.path.join(tmpdir, 'test_2')
with open(test_file, 'wt') as f:
f.write('''void f() {}''')

exitcode, stdout, stderr = cppcheck(['-q', '--enable=warning', '--clang', test_file])
assert exitcode == 0, stderr # do not assert
assert stdout == ''
assert stderr == ''