Skip to content

Commit 48557f6

Browse files
committed
C/C++ overlay: exclude pulled in headers
1 parent 4d0c72e commit 48557f6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,20 @@ overlay[local]
9797
private predicate isBase() { not isOverlay() }
9898

9999
/**
100-
* Holds if `path` was extracted in the overlay database.
100+
* Holds if `path` is a file whose entities should be discarded from the base.
101+
* This covers explicitly changed files and source files compiled by the
102+
* overlay, but not headers pulled in only as transitive includes.
101103
*/
102104
overlay[local]
103105
private predicate overlayHasFile(string path) {
104106
isOverlay() and
105-
files(_, path) and
106-
path != ""
107+
(
108+
overlayChangedFiles(path)
109+
or
110+
exists(@file f |
111+
compilation_compiling_files(_, _, f) and files(f, path)
112+
)
113+
)
107114
}
108115

109116
/**

0 commit comments

Comments
 (0)