Skip to content

Commit 2a38483

Browse files
committed
C/C++ overlay: fix failing header_dependency test
1 parent 2adddfb commit 2a38483

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ predicate isOverlay() { databaseMetadata("isOverlay", "true") }
1717
* in the base (isOverlayVariant=false) or overlay (isOverlayVariant=true) variant.
1818
*/
1919
overlay[local]
20-
private predicate locallyReachableTrapOrTag(boolean isOverlayVariant, string sourceFile, @trap_or_tag t) {
20+
private predicate locallyReachableTrapOrTag(
21+
boolean isOverlayVariant, string sourceFile, @trap_or_tag t
22+
) {
2123
exists(@source_file sf, @trap trap |
2224
(if isOverlay() then isOverlayVariant = true else isOverlayVariant = false) and
2325
source_file_uses_trap(sf, trap) and
@@ -57,13 +59,15 @@ private predicate discardElement(@element e) {
5759
// Finally, we have to make sure that base shouldn't retain it.
5860
// If it is reachable from a base source file, then that is
5961
// sufficient unless either the base source file has changed (in
60-
// particular, been deleted) or the overlay has redefined the TRAP
61-
// file or tag it is in.
62+
// particular, been deleted), or the overlay has redefined the TRAP
63+
// file or tag it is in, or the overlay runner has re-extracted the same
64+
// source file (e.g. because a header it includes has changed).
6265
forall(@trap_or_tag t, string sourceFile |
6366
locallyInTrapOrTag(false, e, t) and
6467
locallyReachableTrapOrTag(false, sourceFile, t)
6568
|
6669
overlayChangedFiles(sourceFile) or
67-
locallyReachableTrapOrTag(true, _, t)
70+
locallyReachableTrapOrTag(true, _, t) or
71+
locallyReachableTrapOrTag(true, sourceFile, _)
6872
)
6973
}

0 commit comments

Comments
 (0)