Skip to content

Commit fe3f90e

Browse files
committed
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`.
1 parent e235e04 commit fe3f90e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)