mirror of
https://github.com/github/codeql.git
synced 2026-05-04 05:05:12 +02:00
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.
This commit is contained in:
@@ -15,10 +15,6 @@ class Class extends UserType {
|
||||
isClass(this.underlying())
|
||||
}
|
||||
|
||||
override @element unresolve() {
|
||||
resolveClass(result) = this
|
||||
}
|
||||
|
||||
/** Gets a child declaration of this class. */
|
||||
override Declaration getADeclaration() { result = this.getAMember() }
|
||||
|
||||
|
||||
@@ -70,7 +70,12 @@ class ElementBase extends @element {
|
||||
* See `underlying` for when the qualifier is `this`.
|
||||
*/
|
||||
pragma[inline]
|
||||
@element unresolve() { result = this }
|
||||
final @element unresolve() {
|
||||
not result instanceof @usertype and
|
||||
result = this
|
||||
or
|
||||
this = resolveClass(result)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user