Skip to content

Commit 0c43f2c

Browse files
authored
Merge pull request #20870 from jketema/exp-arg-fix
C++: `getExpandedArgument` fixes
2 parents 4d9ab7b + fe3f90e commit 0c43f2c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cpp/ql/lib/semmle/code/cpp/Compilation.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Compilation extends @compilation {
9797
/**
9898
* Gets an expanded argument passed to the extractor on this invocation.
9999
*/
100-
string getAnExpandedArgument() { result = this.getArgument(_) }
100+
string getAnExpandedArgument() { result = this.getExpandedArgument(_) }
101101

102102
/**
103103
* Gets the `i`th expanded argument passed to the extractor on this
@@ -107,7 +107,11 @@ class Compilation extends @compilation {
107107
* includes the arguments from that file, rather than just taking the
108108
* argument literally.
109109
*/
110-
string getExpandedArgument(int i) { compilation_expanded_args(this, i, result) }
110+
string getExpandedArgument(int i) {
111+
if exists(string arg | compilation_expanded_args(this, _, arg))
112+
then compilation_expanded_args(this, i, result)
113+
else result = this.getArgument(i)
114+
}
111115

112116
/**
113117
* Gets the total amount of CPU time spent processing all the files in the

0 commit comments

Comments
 (0)