Skip to content

Commit 4765772

Browse files
committed
C++: Fix performance of 'cpp/unused-static-function'.
1 parent 6b1ac73 commit 4765772

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cpp/ql/src/Best Practices/Unused Entities/UnusedStaticFunctions.ql

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ predicate reachableThing(Thing t) {
5050
exists(Thing mid | reachableThing(mid) and mid.callsOrAccesses() = t)
5151
}
5252

53+
pragma[nomagic]
54+
predicate callsOrAccessesPlus(Thing thing1, FunctionToRemove thing2) {
55+
thing1.callsOrAccesses() = thing2
56+
or
57+
exists(Thing mid |
58+
thing1.callsOrAccesses() = mid and
59+
callsOrAccessesPlus(mid, thing2)
60+
)
61+
}
62+
5363
class Thing extends Locatable {
5464
Thing() {
5565
this instanceof Function or
@@ -81,7 +91,7 @@ class FunctionToRemove extends Function {
8191
}
8292

8393
Thing getOther() {
84-
result.callsOrAccesses+() = this and
94+
callsOrAccessesPlus(result, this) and
8595
this != result and
8696
// We will already be reporting the enclosing function of a
8797
// local variable, so don't also report the variable

0 commit comments

Comments
 (0)