Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions cpp/ql/src/semmle/code/cpp/Class.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
31 changes: 6 additions & 25 deletions cpp/ql/src/semmle/code/cpp/Element.qll
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ private import semmle.code.cpp.internal.ResolveClass
*/
pragma[inline]
Element mkElement(@element e) {
result.unresolve() = e
unresolveElement(result) = e
}

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

/**
Expand All @@ -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`,
Expand All @@ -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 }
}

/**
Expand Down
2 changes: 1 addition & 1 deletion cpp/ql/src/semmle/code/cpp/Type.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cpp/ql/src/semmle/code/cpp/pointsto/PointsTo.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down