Skip to content

Fix #15221 (Deprecate the clang import) - #9031

Merged
danmar merged 5 commits into
cppcheck-opensource:mainfrom
cppchecksolutions:fix-15221
Nov 18, 2026
Merged

danmar merged 5 commits into
cppcheck-opensource:mainfrom
cppchecksolutions:fix-15221

Conversation

@danmar

@danmar danmar commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@dmcppcheck

Copy link
Copy Markdown
Contributor

Tests may be missing

@ludviggunne

Copy link
Copy Markdown
Collaborator

If it's mentioned in the manual maybe we should say that it's deprecated there too?

@dmcppcheck dmcppcheck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review

The new deprecation message goes through the normal error path (mErrorLogger.reportErr). Because of that it counts as a finding: --clang --error-exitcode=1 now exits with 1 on code that has no issues. That would break CI jobs that use --clang as soon as they upgrade. The message is also repeated for every checked file, and for empty files it prints an empty code snippet. A deprecation warning from the command line parser, printed once per run and not counted as a finding, would avoid both problems. The releasenotes change also rewrites the unrelated PCRE2 entry and adds a duplicate "Rules:" item about PCRE2 under "Options". Apart from that I found no problems.

Comments

# Comment By Where Status
1 Tests may be missing @dmcppcheck general ✅ Fixed
2 Manual should say that the clang import is deprecated @ludviggunne general ✅ Fixed
3 Deprecation notice counts as a finding: --error-exitcode fails on clean code AI review lib/cppcheck.cpp:691 🆕 New
4 Unrelated PCRE2 releasenotes rewrite and duplicate entry AI review releasenotes.txt:5 🆕 New

@danmar, please fix, resolve or reply to the open and new comments: #3, #4.

Testing

I built cppcheck and testrunner in pr/ with no errors. I ran python3 -m pytest clang-import_test.py in test/cli (clang is installed here): 38 passed.

Manual tests with a.c containing int f(int x){return x;}, b.c containing a function, and an empty file empty.c:

$ cppcheck --clang --error-exitcode=1 -q a.c; echo ec=$?
a.c:1:1: information: clang import is deprecated, it will be removed in 2.27 [clangimport]
int f(int x){return x;}
^
ec=1
$ cppcheck --clang --error-exitcode=1 -q --suppress=clangimport a.c; echo ec=$?
ec=0

Before the PR, --error-exitcode=1 gave exit code 0 on this clean file.

$ cppcheck --clang -q a.c b.c empty.c
a.c:1:1: information: clang import is deprecated, ... [clangimport]
int f(int x){return x;}
^
b.c:1:1: information: clang import is deprecated, ... [clangimport]

^
empty.c:1:1: information: clang import is deprecated, ... [clangimport]

^
  • The message is printed once per file, also with -j2.
  • It is also written to --xml output as an <error id="clangimport">.
  • It is printed again on every run with --cppcheck-build-dir.
  • clangimport is not listed in --errorlist.

I did not test the GUI because it can't be built here.


Automated review of 97a960c by Claude. The pull request was built and tested locally.

Comment thread lib/cppcheck.cpp Resolved
Comment thread releasenotes.txt Resolved
@danmar danmar added the ai-assisted contains code which was written with the assistance of AI - please review extra carefully label Nov 18, 2026
@dmcppcheck

Copy link
Copy Markdown
Contributor

Test results for commit 97a960c (tools/test-my-pr.py, main compared to this PR):

Test: http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/pr-9031/
packages: 100
Differing warnings: 0 (+0 -0)
Timing: -1.2% (http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/pr-9031/2026-11-17_19-11-07-97a960cd6bbf_timing.html)

Posted automatically by the cppcheck PR test runner. +N: warnings only with this PR, -N: warnings only with main. The AI review is written by Claude and can be wrong.

@danmar
danmar merged commit 68bf94a into cppcheck-opensource:main Nov 18, 2026
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted contains code which was written with the assistance of AI - please review extra carefully

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants