From 292b23a651068ec39f9cc3001197a39d8ca7327b Mon Sep 17 00:00:00 2001 From: idrissrio Date: Thu, 26 Feb 2026 15:47:50 +0100 Subject: [PATCH] C/C++ overlay: exclude pulled in headers --- cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll b/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll index 3dea144bbf67..28253e70098e 100644 --- a/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll +++ b/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll @@ -97,13 +97,18 @@ overlay[local] private predicate isBase() { not isOverlay() } /** - * Holds if `path` was extracted in the overlay database. + * Holds if `path` is a file whose entities should be discarded from the base. + * This covers explicitly changed files and source files compiled by the + * overlay, but not headers pulled in only as transitive includes. */ overlay[local] private predicate overlayHasFile(string path) { isOverlay() and - files(_, path) and - path != "" + ( + overlayChangedFiles(path) + or + exists(@file f | compilation_compiling_files(_, _, f) and files(f, path)) + ) } /**