Skip to content

Commit b6d413d

Browse files
committed
C/C++ overlay: use files table instead of overlayChangedFiles for overlay discard
1 parent 7849503 commit b6d413d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,27 @@ private string getMultiLocationFilePath(@element e) {
6464
overlay[local]
6565
private predicate isBase() { not isOverlay() }
6666

67+
/**
68+
* Holds if `path` was extracted in the overlay database.
69+
*/
70+
overlay[local]
71+
private predicate overlayHasFile(string path) {
72+
isOverlay() and
73+
files(_, path) and
74+
path != ""
75+
}
76+
6777
/**
6878
* Discards an element from the base variant if:
69-
* - It has a single location in a changed file, or
70-
* - All of its locations are in changed files.
79+
* - It has a single location in a file extracted in the overlay, or
80+
* - All of its locations are in files extracted in the overlay.
7181
*/
7282
overlay[discard_entity]
7383
private predicate discardElement(@element e) {
7484
isBase() and
7585
(
76-
overlayChangedFiles(getSingleLocationFilePath(e))
86+
overlayHasFile(getSingleLocationFilePath(e))
7787
or
78-
forex(string path | path = getMultiLocationFilePath(e) | overlayChangedFiles(path))
88+
forex(string path | path = getMultiLocationFilePath(e) | overlayHasFile(path))
7989
)
8090
}

0 commit comments

Comments
 (0)