Repository navigation
Conversation
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. |
…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 new problems. The rewritten isAliasOf() gives the same results as the old code. The deref condition and the alias-value filtering only depend on ref and expr, so they can be computed once outside the AST walk. The early continue only skips searches that could never match: when it happens, r is still nullptr from the previous iteration, because a non-null r would already have caused a break. The new expr && guard is needed now that expr->exprId() is evaluated outside the walk.
Testing
- I built
cppcheckandtestrunnerinpr/, andcppcheckinbase/. Both builds succeeded. ./testrunner TestValueFlow TestAstUtils TestUninitVar TestNullPointer TestCondition TestOtherpassed: 653 tests, 0 failures. The full./testrunner -qalso passed with 0 failures.- Differential runs: I ran the base and PR
cppcheckwith--enable=all --inconclusive --debug-warningson these files, and the output was identical for each:scratch/a.cpp, with alias cases: a pointer to a local, a reference to an array element, a pointer to a struct member, a pointer parameter copied to another pointer, and a pointer to a pointertest/cfg/std.cpp,std.c,qt.cppandposix.clib/token.cpp,lib/mathlib.cppandlib/checkstring.cpp, checked with--enable=all --inconclusivebut without--debug-warnings
- I did not measure the speed-up, because there is no timing tool in the container.
Automated review of ee92b8b by Claude. The pull request was built and tested locally.
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.