-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Changes from 3 commits
39136f3
6c09325
3d69286
eac06dd
4ad25e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /** | ||
|
jketema marked this conversation as resolved.
|
||
| * Defines entity discard predicates for C++ overlay analysis. | ||
|
IdrissRio marked this conversation as 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)) | ||
| } | ||
|
|
||
| /** | ||
| * An element with a single location. Discard if in a changed file. | ||
| */ | ||
| overlay[local] | ||
| abstract private class Discardable extends @element { | ||
| abstract string getFilePath(); | ||
|
|
||
| predicate existsInBase() { not isOverlay() } | ||
|
|
||
| string toString() { none() } | ||
| } | ||
|
|
||
| overlay[discard_entity] | ||
| private predicate discardable(@element e) { | ||
| e = any(Discardable d | d.existsInBase() and overlayChangedFiles(d.getFilePath())) | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we're going to need to do something more complex for C. For example, if you have and then if you change then It gets even more complex when you might have different header variants, e.g. we might have one include or
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this something we should do here, or should it happen when we detect which files changed? |
||
|
|
||
| /** | ||
| * An element with potentially multiple locations, e.g., variables, functions and types. | ||
| * Discard only if all locations are in changed files. | ||
| */ | ||
| overlay[local] | ||
| abstract private class MultiDiscardable extends @element { | ||
| abstract string getFilePath(); | ||
|
|
||
| predicate existsInBase() { not isOverlay() } | ||
|
|
||
| string toString() { none() } | ||
| } | ||
|
|
||
| overlay[discard_entity] | ||
| private predicate multiDiscardable(@element e) { | ||
| e = | ||
| any(MultiDiscardable d | | ||
| d.existsInBase() and | ||
| forall(string path | path = d.getFilePath() | overlayChangedFiles(path)) | ||
| ) | ||
| } | ||
|
|
||
| overlay[local] | ||
| private class DiscardableVarDecl extends Discardable instanceof @var_decl { | ||
| override string getFilePath() { | ||
| exists(@location_default loc | var_decls(this, _, _, _, loc) | | ||
| result = getLocationFilePath(loc) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| overlay[local] | ||
| private class DiscardableVariable extends MultiDiscardable instanceof @variable { | ||
| override string getFilePath() { | ||
| exists(@var_decl vd, @location_default loc | var_decls(vd, this, _, _, loc) | | ||
| result = getLocationFilePath(loc) | ||
| ) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.