-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C/C++ overlay: Add basic Overlay.qll file
#20909
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
Merged
+61
−0
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
39136f3
C/C++ overlay: Add basic Overlay.qll file
IdrissRio 6c09325
C/C++ Overlay: Preserve entities that have at least one location in a…
IdrissRio 3d69286
C/C++ overlay: Address review comments
IdrissRio eac06dd
C/C++ overlay: Address review comments
IdrissRio 4ad25e4
C/C++ overlay: Address review comments
IdrissRio 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 hidden or 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 hidden or 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,60 @@ | ||
| /** | ||
jketema marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * Defines entity discard predicates for C++ overlay analysis. | ||
IdrissRio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| */ | ||
|
|
||
| /** | ||
| * Holds always for the overlay variant and never for the base variant. | ||
| * This local predicate is used to define local predicates that behave | ||
| * differently for the base and overlay variant. | ||
| */ | ||
| overlay[local] | ||
| predicate isOverlay() { databaseMetadata("isOverlay", "true") } | ||
|
|
||
| overlay[local] | ||
| private string getLocationFilePath(@location_default loc) { | ||
| exists(@file file | locations_default(loc, file, _, _, _, _) | files(file, result)) | ||
| } | ||
|
|
||
| /** | ||
| * Gets the file path for an element with a single location. | ||
| */ | ||
| overlay[local] | ||
| private string getSingleLocationFilePath(@element e) { | ||
| // @var_decl has a direct location in the var_decls relation | ||
| exists(@location_default loc | var_decls(e, _, _, _, loc) | result = getLocationFilePath(loc)) | ||
| //TODO: add other kinds of elements with single locations | ||
| } | ||
|
|
||
| /** | ||
| * Gets the file path for an element with potentially multiple locations. | ||
| */ | ||
| overlay[local] | ||
| private string getMultiLocationFilePath(@element e) { | ||
| // @variable gets its location(s) from its @var_decl(s) | ||
| exists(@var_decl vd, @location_default loc | var_decls(vd, e, _, _, loc) | | ||
| result = getLocationFilePath(loc) | ||
| ) | ||
| //TODO: add other kinds of elements with multiple locations | ||
| } | ||
|
|
||
| /** | ||
| * A local helper predicate that holds in the base variant and never in the | ||
| * overlay variant. | ||
| */ | ||
| overlay[local] | ||
| private predicate holdsInBase() { not isOverlay() } | ||
|
|
||
| /** | ||
| * Discards an element from the base variant if: | ||
| * - It has a single location in a changed file, or | ||
| * - All of its locations are in changed files. | ||
| */ | ||
| overlay[discard_entity] | ||
| private predicate discardElement(@element e) { | ||
| holdsInBase() and | ||
| ( | ||
| overlayChangedFiles(getSingleLocationFilePath(e)) | ||
| or | ||
| forex(string path | path = getMultiLocationFilePath(e) | overlayChangedFiles(path)) | ||
| ) | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.