Skip to content

Commit 1f4654e

Browse files
committed
RecursiveFunctions: Address performance issues with 2.20.7
Avoid cross-product on function.
1 parent df2247e commit 1f4654e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

cpp/common/src/codingstandards/cpp/rules/functionscallthemselveseitherdirectlyorindirectly/FunctionsCallThemselvesEitherDirectlyOrIndirectly.qll

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ class RecursiveCall extends FunctionCall {
1919
}
2020
}
2121

22-
query predicate problems(FunctionCall fc, string message, Function f, string f_name) {
23-
exists(RecursiveCall call |
24-
not isExcluded(call, getQuery()) and
25-
f = fc.getTarget() and
26-
f_name = fc.getTarget().getName() and
27-
fc.getTarget() = call.getTarget() and
28-
if fc.getTarget() = fc.getEnclosingFunction()
29-
then message = "This call directly invokes its containing function $@."
30-
else
31-
message =
32-
"The function " + fc.getEnclosingFunction() +
33-
" is indirectly recursive via this call to $@."
34-
)
22+
class RecursiveFunction extends Function {
23+
RecursiveFunction() { exists(RecursiveCall fc | fc.getEnclosingFunction() = this) }
24+
}
25+
26+
query predicate problems(FunctionCall fc, string message, RecursiveFunction f, string functionName) {
27+
not isExcluded(fc, getQuery()) and
28+
f = fc.getTarget() and
29+
functionName = f.getName() and
30+
if f = fc.getEnclosingFunction()
31+
then message = "This call directly invokes its containing function $@."
32+
else
33+
message =
34+
"The function " + fc.getEnclosingFunction() + " is indirectly recursive via this call to $@."
3535
}

0 commit comments

Comments
 (0)