From e235e0473ad3ffd9a2d60febd0df14185e436f01 Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Wed, 19 Nov 2025 12:49:02 +0100 Subject: [PATCH 1/2] C++: Fix `getAnExpandedArgument` The fix was accidentially lost when rebasing the branch that introduced this predicate. --- cpp/ql/lib/semmle/code/cpp/Compilation.qll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/ql/lib/semmle/code/cpp/Compilation.qll b/cpp/ql/lib/semmle/code/cpp/Compilation.qll index c4b3796dec86..87bf586842c3 100644 --- a/cpp/ql/lib/semmle/code/cpp/Compilation.qll +++ b/cpp/ql/lib/semmle/code/cpp/Compilation.qll @@ -97,7 +97,7 @@ class Compilation extends @compilation { /** * Gets an expanded argument passed to the extractor on this invocation. */ - string getAnExpandedArgument() { result = this.getArgument(_) } + string getAnExpandedArgument() { result = this.getExpandedArgument(_) } /** * Gets the `i`th expanded argument passed to the extractor on this From fe3f90e0415b8923955aad56c89b663dfcdded08 Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Wed, 19 Nov 2025 12:49:54 +0100 Subject: [PATCH 2/2] C++: Make `getExpandedArgument` more robust This make the predicate give back sensible results on (upgraded) databases where we do not have expanded arguments, and avoid having to write case distinctions in places where we would want to use `getExpandedArgument`. --- cpp/ql/lib/semmle/code/cpp/Compilation.qll | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cpp/ql/lib/semmle/code/cpp/Compilation.qll b/cpp/ql/lib/semmle/code/cpp/Compilation.qll index 87bf586842c3..6f19be0481a2 100644 --- a/cpp/ql/lib/semmle/code/cpp/Compilation.qll +++ b/cpp/ql/lib/semmle/code/cpp/Compilation.qll @@ -107,7 +107,11 @@ class Compilation extends @compilation { * includes the arguments from that file, rather than just taking the * argument literally. */ - string getExpandedArgument(int i) { compilation_expanded_args(this, i, result) } + string getExpandedArgument(int i) { + if exists(string arg | compilation_expanded_args(this, _, arg)) + then compilation_expanded_args(this, i, result) + else result = this.getArgument(i) + } /** * Gets the total amount of CPU time spent processing all the files in the