diff --git a/cpp/ql/src/semmle/code/cpp/Class.qll b/cpp/ql/src/semmle/code/cpp/Class.qll index e2364744b145..8d4414f03f38 100644 --- a/cpp/ql/src/semmle/code/cpp/Class.qll +++ b/cpp/ql/src/semmle/code/cpp/Class.qll @@ -12,11 +12,7 @@ private import semmle.code.cpp.internal.ResolveClass */ class Class extends UserType { Class() { - isClass(this.underlying()) - } - - override @element unresolve() { - resolveClass(result) = this + isClass(underlyingElement(this)) } /** Gets a child declaration of this class. */ diff --git a/cpp/ql/src/semmle/code/cpp/Element.qll b/cpp/ql/src/semmle/code/cpp/Element.qll index 13f554960093..10ad7135b0a6 100644 --- a/cpp/ql/src/semmle/code/cpp/Element.qll +++ b/cpp/ql/src/semmle/code/cpp/Element.qll @@ -10,7 +10,7 @@ private import semmle.code.cpp.internal.ResolveClass */ pragma[inline] Element mkElement(@element e) { - result.unresolve() = e + unresolveElement(result) = e } /** @@ -24,7 +24,10 @@ Element mkElement(@element e) { */ pragma[inline] @element unresolveElement(Element e) { - result = e.unresolve() + not result instanceof @usertype and + result = e + or + e = resolveClass(result) } /** @@ -35,13 +38,12 @@ pragma[inline] * need the result for an argument to a database extensional. * See `unresolveElement` for when `e` is not `this`. */ -pragma[inline] @element underlyingElement(Element e) { result = e } /** - * A C/C++ element with a minimal set of member predicates. Not for + * A C/C++ element with no member predicates other than `toString`. Not for * general use. This class does not define a location, so classes wanting to * change their location without affecting other classes can extend * `ElementBase` instead of `Element` to create a new rootdef for `getURL`, @@ -50,27 +52,6 @@ pragma[inline] class ElementBase extends @element { /** Gets a textual representation of this element. */ string toString() { none() } - - /** - * INTERNAL: Do not use. - * - * Gets the `@element` that this `Element` extends. This should normally only - * be called from member predicates on `this` where you need the result for - * an argument to a database extensional. - * See `unresolve` for when the qualifier is not `this`. - */ - final @element underlying() { result = this } - - /** - * INTERNAL: Do not use. - * - * Gets an `@element` that resolves to the `Element`. This should normally - * only be called from member predicates, where the qualifier is not `this` - * and you need the result for an argument to a database extensional. - * See `underlying` for when the qualifier is `this`. - */ - pragma[inline] - @element unresolve() { result = this } } /** diff --git a/cpp/ql/src/semmle/code/cpp/Type.qll b/cpp/ql/src/semmle/code/cpp/Type.qll index 3a78e6c7cf94..552e12369283 100644 --- a/cpp/ql/src/semmle/code/cpp/Type.qll +++ b/cpp/ql/src/semmle/code/cpp/Type.qll @@ -7,7 +7,7 @@ private import semmle.code.cpp.internal.ResolveClass * A C/C++ type. */ class Type extends Locatable, @type { - Type() { isType(this.underlying()) } + Type() { isType(underlyingElement(this)) } /** * Gets the name of this type. diff --git a/cpp/ql/src/semmle/code/cpp/pointsto/PointsTo.qll b/cpp/ql/src/semmle/code/cpp/pointsto/PointsTo.qll index 7c70fd50d505..6f1ab3758262 100644 --- a/cpp/ql/src/semmle/code/cpp/pointsto/PointsTo.qll +++ b/cpp/ql/src/semmle/code/cpp/pointsto/PointsTo.qll @@ -635,7 +635,7 @@ class PointsToExpr extends Expr { this.interesting() and exists(int set, @element thisEntity, @element resultEntity | - thisEntity = this.underlying() and + thisEntity = underlyingElement(this) and pointstosets(set, thisEntity) and setlocations(set, resultEntity) and resultEntity = localUnresolveElement(result)