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:
Jonas Jensen
2018-09-27 09:30:11 +02:00
parent 40c29263c4
commit c61b311682
2 changed files with 6 additions and 5 deletions

View File

@@ -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() }

View File

@@ -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)
}
}
/**