Skip to content

Commit 755225f

Browse files
committed
C/C++ overlay: fix failing header_dependency test
1 parent cbc1598 commit 755225f

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
@@ -15,7 +15,9 @@ predicate isOverlay() { databaseMetadata("isOverlay", "true") }
1515
* in the base (isOverlayVariant=false) or overlay (isOverlayVariant=true) variant.
1616
*/
1717
overlay[local]
18-
private predicate locallyReachableTrapOrTag(boolean isOverlayVariant, string sourceFile, @trap_or_tag t) {
18+
private predicate locallyReachableTrapOrTag(
19+
boolean isOverlayVariant, string sourceFile, @trap_or_tag t
20+
) {
1921
exists(@source_file sf, @trap trap |
2022
(if isOverlay() then isOverlayVariant = true else isOverlayVariant = false) and
2123
source_file_uses_trap(sf, trap) and
@@ -55,13 +57,15 @@ private predicate discardElement(@element e) {
5557
// Finally, we have to make sure that base shouldn't retain it.
5658
// If it is reachable from a base source file, then that is
5759
// sufficient unless either the base source file has changed (in
58-
// particular, been deleted) or the overlay has redefined the TRAP
59-
// file or tag it is in.
60+
// particular, been deleted), or the overlay has redefined the TRAP
61+
// file or tag it is in, or the overlay runner has re-extracted the same
62+
// source file (e.g. because a header it includes has changed).
6063
forall(@trap_or_tag t, string sourceFile |
6164
locallyInTrapOrTag(false, e, t) and
6265
locallyReachableTrapOrTag(false, sourceFile, t)
6366
|
6467
overlayChangedFiles(sourceFile) or
65-
locallyReachableTrapOrTag(true, _, t)
68+
locallyReachableTrapOrTag(true, _, t) or
69+
locallyReachableTrapOrTag(true, sourceFile, _)
6670
)
6771
}

0 commit comments

Comments
 (0)