diff --git a/cpp/ql/lib/semmle/code/cpp/Compilation.qll b/cpp/ql/lib/semmle/code/cpp/Compilation.qll index c4b3796dec86..6f19be0481a2 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 @@ -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