do not set values if there is no expression
All tests still pass with the early returns added.
Example output:
TestLeakAutoVar::doublefree9
ExprIdToken - no tok
setValue - no expr - 0@1
setValue - no expr - 0@1
ExprIdToken - no tok
setValue - no expr - 1@2
setValue - no expr - 1@2
setValue - no expr - 1
setValue - no expr - 0
Looks like this is related to unnamed parameters.
@pfultz2 please have a look.
Happens with unnamed parameters when a function body exists:
void cb(int) {}
void func()
{
cb(0);
}
ExprIdToken - no tok
setValue - no expr - 0@1
ExprIdToken - no tok
solveExprValue - no expr
setValue - no expr - 0@1
ExprIdToken - no tok
solveExprValue - no expr
##file scratch_3.cpp
1: void cb ( int ) { }
2:
3: void func ( )
4: {
5: cb (@exprUNIQUE 0 ) ;
6: }
##Value flow
File scratch_3.cpp
Line 5
0 always 0
Naming the parameter fixes it:
##file scratch_3.cpp
1: void cb ( int i@var1 ) { }
2:
3: void func ( )
4: {
5: cb (@exprUNIQUE 0 ) ;
6: }
##Value flow
File scratch_3.cpp
Line 5
0 always 0
The MultiValueFlowAnalyzer happens in TestAutoVariables::testinvaliddealloc (among others). I assume that should not get such data so it possibly needs to be addressed earlier in the code.
spontanously this sounds good to me. what is the motivation? is there speedup or change of results or simpler code?
I cannot remember how I came across this but I assume it was in the context of some of the other drafts PRs where I try to get rid of unnecessary calls.
Depending on the code this might have performance implications as less values are being generated.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
I tested it with #7800 and there were no differences in the output.