From 2dca7ef3ede04a6975422fb389e68cafb6fa92b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 15 Nov 2026 19:16:46 +0100 Subject: [PATCH 1/5] Fix #15221 (Deprecate the clang import) --- lib/cppcheck.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index c2c3060f03f..2cfed9a9c00 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -683,6 +683,16 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file) { // TODO: clear exitcode + // #15221 - clangimport is deprecated and will be removed + { + ErrorMessage errmsg; + errmsg.callStack.push_back(ErrorMessage::FileLocation(file.spath(), 1, 1)); + errmsg.setmsg("clang import is deprecated, it will be removed in 2.27"); + errmsg.severity = Severity::information; + errmsg.id = "clangimport"; + mErrorLogger.reportErr(errmsg); + } + if (mSettings.checks.isEnabled(Checks::unusedFunction) && !mUnusedFunctionsCheck) mUnusedFunctionsCheck.reset(new CheckUnusedFunctions()); From d56db0306a21fa1f5e7f4063a860358c50a763c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 15 Nov 2026 19:22:03 +0100 Subject: [PATCH 2/5] GUI: make clangimport option disabled and write a deprecated message. --- gui/projectfile.ui | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gui/projectfile.ui b/gui/projectfile.ui index 9f7ad91fa8f..fe32c84d405 100644 --- a/gui/projectfile.ui +++ b/gui/projectfile.ui @@ -472,8 +472,11 @@ + + false + - Clang (experimental) + Clang (this feature is deprecated; this option will be removed in 2.27) From 72e1f8bc9f9f6a6e584a0eb263e051dcf3524bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 16 Nov 2026 08:22:59 +0100 Subject: [PATCH 3/5] ci fixes --- lib/cppcheck.cpp | 2 +- test/cli/clang-import_test.py | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 2cfed9a9c00..7524a6fd6bd 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -686,7 +686,7 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file) // #15221 - clangimport is deprecated and will be removed { ErrorMessage errmsg; - errmsg.callStack.push_back(ErrorMessage::FileLocation(file.spath(), 1, 1)); + errmsg.callStack.emplace_back(file.spath(), 1, 1); errmsg.setmsg("clang import is deprecated, it will be removed in 2.27"); errmsg.severity = Severity::information; errmsg.id = "clangimport"; diff --git a/test/cli/clang-import_test.py b/test/cli/clang-import_test.py index da5bb2f3af7..26f20391434 100644 --- a/test/cli/clang-import_test.py +++ b/test/cli/clang-import_test.py @@ -6,7 +6,7 @@ import subprocess import sys import pytest -from testutils import cppcheck, assert_cppcheck +from testutils import cppcheck try: # TODO: handle exitcode? @@ -20,6 +20,19 @@ pytest.skip(allow_module_level=True) +__DEPRECATION_MSG = 'information: clang import is deprecated, it will be removed in 2.27 [clangimport]' + + +# #15221 - clang import is deprecated; check the message and return the remaining stderr lines +def __check_deprecation(stderr, filename): + lines = stderr.splitlines() + assert len(lines) >= 3, lines + assert lines[0] == '{}:1:1: {}'.format(filename, __DEPRECATION_MSG), lines + # the message is followed by the code snippet and the caret + assert lines[2] == '^', lines + return lines[3:] + + def __get_debug_section(title, stdout): s = re.sub(r'0x[0-9a-fA-F]+', '0x12345678', stdout) s = re.sub(r'nestedIn: Struct', 'nestedIn: Class', s) @@ -125,7 +138,10 @@ def test_log(tmpdir): 'Checking {} ...'.format(test_file).replace('\\', '/'), ] - assert_cppcheck(args, ec_exp=0, err_exp=[], out_exp=out_lines) + exitcode, stdout, stderr = cppcheck(args) + assert exitcode == 0, stdout + assert stdout.splitlines() == out_lines + assert __check_deprecation(stderr, test_file) == [] def test_include(tmp_path): @@ -151,7 +167,7 @@ def test_warning(tmpdir): # #12424 exitcode, stdout, stderr = cppcheck(['-q', '--enable=warning', '--clang', test_file]) assert exitcode == 0, stderr # do not assert assert stdout == '' - assert stderr == '' + assert __check_deprecation(stderr, test_file) == [] def __test_cmd(tmp_path, file_name, extra_args, stdout_exp_1, content=''): @@ -173,7 +189,7 @@ def __test_cmd(tmp_path, file_name, extra_args, stdout_exp_1, content=''): exitcode, stdout, stderr = cppcheck(args, cwd=tmp_path) assert exitcode == 0, stderr if not stdout else stdout - assert stderr == '' + assert __check_deprecation(stderr, file_name) == [] assert stdout.splitlines() == [ 'Checking {} ...'.format(file_name), 'clang -fsyntax-only -Xclang -ast-dump -fno-color-diagnostics {}{}'.format(stdout_exp_1, file_name) @@ -279,7 +295,7 @@ def test_debug_clang_output(tmp_path): exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0, stderr if not stdout else stdout - assert stderr == '' + assert __check_deprecation(stderr, test_file) == [] assert stdout.startswith('TranslationUnitDecl'), stdout assert stdout.find(str(test_file)) != -1, stdout @@ -312,7 +328,7 @@ def test_debug_clang_output_failure_exitcode(tmp_path): exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0, stderr if not stdout else stdout - stderr_lines = stderr.splitlines() + stderr_lines = __check_deprecation(stderr, test_file) assert len(stderr_lines) > 5, stderr_lines assert (stderr_lines[0] == "Failed to execute 'clang -fsyntax-only -Xclang -ast-dump -fno-color-diagnostics -x c {} 2>&1' - (exitcode: 1 / output: {}:3:12: error: indirection requires pointer operand ('int' invalid)".format(test_file, test_file)) From c5bef91ca90bb38199e02778478c808b91cb790f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 16 Nov 2026 11:01:11 +0100 Subject: [PATCH 4/5] manual --- man/manual-premium.md | 12 ------------ man/manual.md | 12 ------------ 2 files changed, 24 deletions(-) diff --git a/man/manual-premium.md b/man/manual-premium.md index 3553acc1b91..69395e60dfc 100644 --- a/man/manual-premium.md +++ b/man/manual-premium.md @@ -150,18 +150,6 @@ Typically a `compile_commands.json` contains absolute paths. However no matter i - a file with relative path `test1.cpp` can be checked. - a file with relative path `test/somefile.cpp` is not checked -### Clang parser (experimental) - -By default Cppcheck uses an internal C/C++ parser. However there is an experimental option to use the Clang parser instead. - -Install `clang`. Then use Cppcheck option `--clang`. - -Cppcheck executes clang with the -ast-dump option, imports the output, converts it to Cppcheck's internal format, and then -performs standard analysis. - -You can also pass a custom Clang executable to the option by using for example `--clang=clang-10`. You can also pass it -with a path. On Windows it will append the `.exe` extension unless you use a path. - ## Severities The possible severities for messages are: diff --git a/man/manual.md b/man/manual.md index 85dad95f8bb..2a8d42722ce 100644 --- a/man/manual.md +++ b/man/manual.md @@ -151,18 +151,6 @@ Typically a `compile_commands.json` contains absolute paths. However no matter i - a file with relative path `test1.cpp` can be checked. - a file with relative path `test/somefile.cpp` is not checked -### Clang parser (experimental) - -By default Cppcheck uses an internal C/C++ parser. However there is an experimental option to use the Clang parser instead. - -Install `clang`. Then use Cppcheck option `--clang`. - -Cppcheck executes clang with the -ast-dump option, imports the output, converts it to Cppcheck's internal format, and then -performs standard analysis. - -You can also pass a custom Clang executable to the option by using for example `--clang=clang-10`. You can also pass it -with a path. On Windows it will append the `.exe` extension unless you use a path. - ## Severities The possible severities for messages are: From 97a960cd6bbf7b172553500259aa899814f497c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 17 Nov 2026 20:10:15 +0100 Subject: [PATCH 5/5] releasenotes and --help --- cli/cmdlineparser.cpp | 9 ++------- releasenotes.txt | 9 +++++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 3a1b5ac1e6f..6e2bc67cd10 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -1793,13 +1793,8 @@ void CmdLineParser::printHelp() const " incomplete info.\n" " --checkers-report=\n" " Write a report of all the active checkers to the given file.\n" - " --clang= Experimental: Use Clang parser instead of the builtin Cppcheck\n" - " parser. Takes the executable as optional parameter and\n" - " defaults to `clang`. Cppcheck will run the given Clang\n" - " executable, import the Clang AST and convert it into\n" - " Cppcheck data. After that the normal Cppcheck analysis is\n" - " used. You must have the executable in PATH if no path is\n" - " given.\n" + " --clang= Deprecated: Use Clang parser instead of the builtin Cppcheck\n" + " parser. This option will be removed in Cppcheck 2.27.\n" " --config-exclude=\n" " Path (prefix) to be excluded from configuration\n" " checking. Preprocessor configurations defined in\n" diff --git a/releasenotes.txt b/releasenotes.txt index e70c9230171..fa3a16f9a37 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -1,6 +1,11 @@ Release Notes for Cppcheck 2.23 +Options: +- Rules: The PCRE library that we used is end-of-life. We have switched to PCRE2 instead. Existing rule files + will hopefully work without changes. +- The --clang option has been deprecated, it will be removed in Cppcheck 2.27 + Major bug fixes & crashes: - @@ -22,8 +27,8 @@ Import project: Infrastructure & dependencies: - Added arm64 platform files arm64-windows.xml, arm64-linux.xml and arm64-macos.xml (Apple Silicon). These describe the default setup for that OS. The arm64-wchar_t2.xml and arm64-wchar_t4.xml files are kept. -- The rules feature (HAVE_RULES) now uses PCRE2 instead of the discontinued PCRE library. Existing rule patterns - and rule files work unchanged. On Windows the Visual Studio project now expects pcre2-8.lib and pcre2.h in externals. +- The rules feature (HAVE_RULES) now uses PCRE2 instead of the discontinued PCRE library. On Windows the + Visual Studio project now expects pcre2-8.lib and pcre2.h in externals. Other: -