-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix C style function resolution #1860
Open
peckto
wants to merge
3
commits into
main
Choose a base branch
from
peckto/c-func-resolve-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
cpg-language-cxx/src/test/resources/calls/c-function-resolution.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//#define MY_CONST_INT 1 | ||
|
||
void foo(int i) { | ||
} | ||
void bar(int i) { | ||
} | ||
|
||
int main() { | ||
foo(MY_CONST_INT); | ||
foo(1); | ||
bar(1,2); | ||
return 0; | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has multiple issues
At the very least I think we need to make this configurable. Depending on the use case you MAY or MAY NOT want to do this. For example if you actually want to check if something is resolving similar to a compiler (e.g., also inference turned off), you want to have an empty list of invokes edges here.
If you want to be very optimistic about matching types, this may be another (maybe even global?) configuration option. You can always of course override the
tryCast
in a language that depends on the C language if you want to have a "matches-everything-C-language`.So I am very skeptical about this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's true, default arguments are a problem, haven't thought about that.
Also the go var args arguments fail.
Do we have a language feature for that to match on?
Affecting other languages is not a problem per se I would say, but other languages bring other combinations of features, which must be taken into account during the resolution.
Override the
tryCast
might be an alternative for the C language.Not sure if we want to make this configurable, as long as it is conform with the language design.
Configuration options tend to be only used by the person who implemented them and others are wondering why it's not working, not knowing about the option.