Skip to content

Commit c61b311

Browse files
committed
C++: Make unresolve dispatch on result, not this
This change means that there are no results for `unresolveElement(t)` where `t` is a "junk type" -- a class definition that is not in the image of `resolveClass`. These "junk types" still exist as `Element`s, but they will never be returned by any predicate that goes through `unresolveElement` to query the db. We get a small reduction in DIL size and a significant speed improvement. The DIL for `NewArrayDeleteMismatch.ql` is reduced from 27,630 lines to 27,507 lines, and the total analysis time for the LGTM suite on jdk8u is reduced from 1158s to 984s.
1 parent 40c2926 commit c61b311

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

cpp/ql/src/semmle/code/cpp/Class.qll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ class Class extends UserType {
1515
isClass(this.underlying())
1616
}
1717

18-
override @element unresolve() {
19-
resolveClass(result) = this
20-
}
21-
2218
/** Gets a child declaration of this class. */
2319
override Declaration getADeclaration() { result = this.getAMember() }
2420

cpp/ql/src/semmle/code/cpp/Element.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ class ElementBase extends @element {
7070
* See `underlying` for when the qualifier is `this`.
7171
*/
7272
pragma[inline]
73-
@element unresolve() { result = this }
73+
final @element unresolve() {
74+
not result instanceof @usertype and
75+
result = this
76+
or
77+
this = resolveClass(result)
78+
}
7479
}
7580

7681
/**

0 commit comments

Comments
 (0)