Skip to content

Commit c5360ba

Browse files
tausbnMathiasVP
andcommitted
Python: Fix bad join in method call order computation
This join had badness 1127 on the project FiacreT/M-moire, producing ~31 million tuples in order to end up with only ~27k tuples later in the pipeline. With the fix, we reduce this by roughly the full 31 million (the new materialised helper predicate accounting for roughly 130k tuples on its own). Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
1 parent be9c1d0 commit c5360ba

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

python/ql/src/Classes/CallsToInitDel/MethodCallOrder.qll

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,23 @@ predicate missingCallToSuperclassMethod(Class base, Function shouldCall, string
152152
*/
153153
predicate missingCallToSuperclassMethodRestricted(Class base, Function shouldCall, string name) {
154154
missingCallToSuperclassMethod(base, shouldCall, name) and
155-
not exists(Class superBase |
156-
// Alert only on the highest base class that has the issue
157-
superBase = getADirectSuperclass+(base) and
158-
missingCallToSuperclassMethod(superBase, shouldCall, name)
159-
) and
155+
not superclassAlsoMissesCall(base, shouldCall, name) and
160156
not exists(Function subShouldCall |
161157
// Mention in the alert only the lowest method we're missing the call to
162158
subShouldCall.getScope() = getADirectSubclass+(shouldCall.getScope()) and
163159
missingCallToSuperclassMethod(base, subShouldCall, name)
164160
)
165161
}
166162

163+
/**
164+
* Holds if a strict superclass of `base` is also missing a call to `shouldCall` named `name`,
165+
* indicating that `base` is not the highest class in the hierarchy with this issue.
166+
*/
167+
pragma[nomagic]
168+
private predicate superclassAlsoMissesCall(Class base, Function shouldCall, string name) {
169+
missingCallToSuperclassMethod(getADirectSuperclass+(base), shouldCall, name)
170+
}
171+
167172
/**
168173
* If `base` contains a `super()` call, gets a method in the inheritance hierarchy of `name` in the MRO of `base`
169174
* that does not contain a `super()` call, but would call `shouldCall` if it did, which does not otherwise get called

0 commit comments

Comments
 (0)