From 4702e208b7c2bb4a32663d171e98e55bfe31c125 Mon Sep 17 00:00:00 2001 From: idrissrio Date: Mon, 8 Dec 2025 16:08:28 +0100 Subject: [PATCH 1/4] C/C++ overlay: Add overlay support for discarding functions --- .../lib/semmle/code/cpp/internal/Overlay.qll | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll b/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll index 571f034d85b..adc040c5cff 100644 --- a/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll +++ b/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll @@ -20,9 +20,13 @@ private string getLocationFilePath(@location_default loc) { */ overlay[local] private string getSingleLocationFilePath(@element e) { - // @var_decl has a direct location in the var_decls relation - exists(@location_default loc | var_decls(e, _, _, _, loc) | result = getLocationFilePath(loc)) - //TODO: add other kinds of elements with single locations + exists(@location_default loc | + var_decls(e, _, _, _, loc) + or + fun_decls(e, _, _, _, loc) + | + result = getLocationFilePath(loc) + ) } /** @@ -30,11 +34,13 @@ private string getSingleLocationFilePath(@element e) { */ overlay[local] private string getMultiLocationFilePath(@element e) { - // @variable gets its location(s) from its @var_decl(s) - exists(@var_decl vd, @location_default loc | var_decls(vd, e, _, _, loc) | + exists(@location_default loc | + exists(@var_decl vd | var_decls(vd, e, _, _, loc)) + or + exists(@fun_decl fd | fun_decls(fd, e, _, _, loc)) + | result = getLocationFilePath(loc) ) - //TODO: add other kinds of elements with multiple locations } /** From c34456e3a04e53c5822655d5347222ffa97cc352 Mon Sep 17 00:00:00 2001 From: idrissrio Date: Mon, 8 Dec 2025 16:08:56 +0100 Subject: [PATCH 2/4] C/C++ overlay: Add overlay support for discarding user types --- cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll b/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll index adc040c5cff..61466946070 100644 --- a/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll +++ b/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll @@ -24,6 +24,8 @@ private string getSingleLocationFilePath(@element e) { var_decls(e, _, _, _, loc) or fun_decls(e, _, _, _, loc) + or + type_decls(e, _, loc) | result = getLocationFilePath(loc) ) @@ -38,6 +40,8 @@ private string getMultiLocationFilePath(@element e) { exists(@var_decl vd | var_decls(vd, e, _, _, loc)) or exists(@fun_decl fd | fun_decls(fd, e, _, _, loc)) + or + exists(@type_decl td | type_decls(td, e, loc)) | result = getLocationFilePath(loc) ) From 1286ca6683a39e83fcb2f5f117bf4c93134b2511 Mon Sep 17 00:00:00 2001 From: idrissrio Date: Mon, 8 Dec 2025 16:09:26 +0100 Subject: [PATCH 3/4] C/C++ overlay: Add overlay support for discarding namespaces --- cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll b/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll index 61466946070..9bc9ace89fe 100644 --- a/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll +++ b/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll @@ -26,6 +26,8 @@ private string getSingleLocationFilePath(@element e) { fun_decls(e, _, _, _, loc) or type_decls(e, _, loc) + or + namespace_decls(e, _, loc, _) | result = getLocationFilePath(loc) ) @@ -42,6 +44,8 @@ private string getMultiLocationFilePath(@element e) { exists(@fun_decl fd | fun_decls(fd, e, _, _, loc)) or exists(@type_decl td | type_decls(td, e, loc)) + or + exists(@namespace_decl nd | namespace_decls(nd, e, loc, _)) | result = getLocationFilePath(loc) ) From 3f372d2658de7e2da7a3deca6e7587f84c309112 Mon Sep 17 00:00:00 2001 From: idrissrio Date: Mon, 8 Dec 2025 16:09:50 +0100 Subject: [PATCH 4/4] C/C++ overlay: Add overlay support for discarding macro invocations --- cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll b/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll index 9bc9ace89fe..64bfb7a8f17 100644 --- a/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll +++ b/cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll @@ -28,6 +28,10 @@ private string getSingleLocationFilePath(@element e) { type_decls(e, _, loc) or namespace_decls(e, _, loc, _) + or + macroinvocations(e, _, loc, _) + or + preprocdirects(e, _, loc) | result = getLocationFilePath(loc) )