Repository navigation
Conversation
…node in the expression) The values of the reference token were filtered again for every node in the expression. Filter them once and skip the AST search when there is nothing that can match. No changed warnings in a 50 package debian corpus, ValueFlow ~10% faster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found no problems. The refactored isAliasOf() behaves the same as before: the deref condition and the filtered alias values are now computed once per reference instead of for every AST node, and the early continue only skips searches that could never match. The new expr && guard is needed, and the regression test that was added catches the case where it is missing (see testing). There are no earlier comments to track.
Testing
- I built
cppcheckandtestrunnerin bothpr/andbase/, and both builds succeeded. ./testrunner TestValueFlowpasses in the PR. The full./testrunner -qalso passes, with 0 failures.- New test in base: I copied the PR's
testvalueflow.cppinto base, and it passes there too. Base never crashed on this code, becausefindAstNode(nullptr, …)returns nothing. - New test without the guard: I removed the
expr &&guard from the hoistedderefin a copy of the PR. With that change,TestValueFlow::valueFlowCrashcrashes. So the test does protect the new guard. - Differential run: I ran base and PR
cppcheck --enable=all --inconclusive --check-level=exhaustiveon every file intest/cfg/*.c*andsamples/*/*. The outputs were identical (2451 lines each). - Alias cases: I wrote small cases in
scratch/a.cpp(pointer to a local, array alias, reference to a struct, pointer parameter alias, pointer to a reference) and ran them with--debug-warnings. Base and PR gave identical output. - I did not measure the performance gain.
Automated review of 9d1c87a by Claude. The pull request was built and tested locally.
|
Test results for commit 9d1c87a (tools/test-my-pr.py, main compared to this PR): Test: http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/pr-9062/ 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. |
The values of the reference token were filtered again for every node in the expression. Filter them once and skip the AST search when there is nothing that can match.
No changed warnings in a 50 package debian corpus, ValueFlow ~10% faster.