Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not set values if there is no expression #7295

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

firewave
Copy link
Collaborator

@firewave firewave commented Feb 7, 2025

No description provided.

@firewave
Copy link
Collaborator Author

firewave commented Feb 7, 2025

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.

@firewave firewave changed the title do not set values if there is no expression [skip ci] do not set values if there is no expression Feb 8, 2025
@firewave
Copy link
Collaborator Author

firewave commented Feb 8, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant