From 7b3d6ce443f5ef70e3ba154d8b4dbb603fd025fc Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 11 Mar 2026 23:56:18 +0100 Subject: [PATCH] fixed #14591 - store CTU function call information with proper slashes [skip ci] --- lib/ctu.cpp | 2 +- test/cli/other_test.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lib/ctu.cpp b/lib/ctu.cpp index 3f50dd1a485..d1be82b34fa 100644 --- a/lib/ctu.cpp +++ b/lib/ctu.cpp @@ -112,7 +112,7 @@ std::string CTU::FileInfo::FunctionCall::toXmlString() const out << ">\n"; for (const ErrorMessage::FileLocation &loc : callValuePath) out << " \n"; diff --git a/test/cli/other_test.py b/test/cli/other_test.py index ce4089c9ac4..7749ef18175 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -4234,3 +4234,41 @@ def run_and_assert_cppcheck(stdout_exp): # TODO: # - invalid error # - internalError + + +def test_ctu_function_call_path_slash(tmp_path): # #14591 + test_file = tmp_path / 'test.cpp' + with open(test_file, "w") as f: + f.write( +"""void g(T* p) +{ + *p = 0; +} + +void f(T* p) +{ + p = nullptr; + g(p); +} +""") + + build_dir = tmp_path / 'b1' + os.makedirs(build_dir) + + args = [ + '-q', + '--template=simple', + '--cppcheck-build-dir={}'.format(build_dir), + str(test_file) + ] + + exitcode, _, _ = cppcheck(args) + assert exitcode == 0 + + test_a1_file = build_dir / 'test.a1' + analyzerinfo = ElementTree.fromstring(test_a1_file.read_text()) + function_call_paths = analyzerinfo.findall('FileInfo/function-call/path') + assert len(function_call_paths) == 1 + file = function_call_paths[0].attrib['file'] + assert file + assert not '\\' in file # the path was incorrectly converted to native