diff --git a/cpp/ql/src/semmle/code/cpp/AutogeneratedFile.qll b/cpp/ql/src/semmle/code/cpp/AutogeneratedFile.qll index 8b5aa242f9c..74f8bdd5b7d 100644 --- a/cpp/ql/src/semmle/code/cpp/AutogeneratedFile.qll +++ b/cpp/ql/src/semmle/code/cpp/AutogeneratedFile.qll @@ -35,7 +35,7 @@ class AutogeneratedFile extends File { cached AutogeneratedFile() { exists(int limit, int head | head <= 5 and - limit = max(int line | locations_default(_, unresolveElement(this), head, _, line, _)) + 5 + limit = max(int line | locations_default(_, underlyingElement(this), head, _, line, _)) + 5 | exists (Comment c | c.getFile() = this and c.getLocation().getStartLine() <= limit and isAutogeneratedComment(c)) ) diff --git a/cpp/ql/src/semmle/code/cpp/Class.qll b/cpp/ql/src/semmle/code/cpp/Class.qll index 1e06165368b..bb918a80e94 100644 --- a/cpp/ql/src/semmle/code/cpp/Class.qll +++ b/cpp/ql/src/semmle/code/cpp/Class.qll @@ -12,7 +12,7 @@ private import semmle.code.cpp.internal.Type */ class Class extends UserType { Class() { - isClass(unresolveElement(this)) + isClass(underlyingElement(this)) } /** Gets a child declaration of this class. */ @@ -75,7 +75,7 @@ class Class extends UserType { * If you also want template instantiations of results, see * `getAMember(int)`. */ - Declaration getCanonicalMember(int index) { member(unresolveElement(this),index,unresolveElement(result)) } + Declaration getCanonicalMember(int index) { member(underlyingElement(this),index,unresolveElement(result)) } /** * Gets the (zero-based) `index`th canonical member declared in this @@ -94,7 +94,7 @@ class Class extends UserType { * DEPRECATED: Use `getCanonicalMember(int)` or `getAMember(int)` instead. * Gets the `index`th member of this class. */ - deprecated Declaration getMember(int index) { member(unresolveElement(this),index,unresolveElement(result)) } + deprecated Declaration getMember(int index) { member(underlyingElement(this),index,unresolveElement(result)) } /** * DEPRECATED: As this includes a somewhat arbitrary number of @@ -416,7 +416,7 @@ class Class extends UserType { * compiled for. For this reason, the `is_pod_class` predicate is * generated by the extractor. */ - predicate isPOD() { is_pod_class(unresolveElement(this)) } + predicate isPOD() { is_pod_class(underlyingElement(this)) } /** * Holds if this class is abstract, in other words whether it declares one @@ -513,7 +513,7 @@ class Class extends UserType { * classes. */ int getVirtualBaseClassByteOffset(Class base) { - virtual_base_offsets(unresolveElement(this), unresolveElement(base), result) + virtual_base_offsets(underlyingElement(this), unresolveElement(base), result) } /** @@ -566,7 +566,7 @@ class Class extends UserType { * The alignment of this type in bytes (on the machine where facts were * extracted). */ - int getAlignment() { usertypesize(unresolveElement(this),_,result) } + int getAlignment() { usertypesize(underlyingElement(this),_,result) } /** * Holds if this class is constructed from another class as a result of @@ -574,7 +574,7 @@ class Class extends UserType { * from a class nested in a class template. */ predicate isConstructedFrom(Class c) { - class_instantiation(unresolveElement(this), unresolveElement(c)) + class_instantiation(underlyingElement(this), unresolveElement(c)) } /** @@ -597,7 +597,7 @@ class Class extends UserType { * `i`th template parameter. */ Type getTemplateArgument(int i) { - class_template_argument(unresolveElement(this),i,unresolveElement(result)) + class_template_argument(underlyingElement(this),i,unresolveElement(result)) } /** @@ -614,7 +614,7 @@ class Class extends UserType { /** Holds if this class was declared 'final'. */ predicate isFinal() { - usertype_final(unresolveElement(this)) + usertype_final(underlyingElement(this)) } /** Gets a link target which references this class. */ @@ -631,7 +631,7 @@ class Class extends UserType { * using lowercase letters (e.g. "01234567-89ab-cdef-0123-456789abcdef"). */ string getUuid() { - usertype_uuid(unresolveElement(this), result) + usertype_uuid(underlyingElement(this), result) } private Type getAFieldSubobjectType() { @@ -764,7 +764,7 @@ class ClassDerivation extends Locatable, @derivation { * struct D : T {}; */ Type getBaseType() { - derivations(unresolveElement(this),_,_,unresolveElement(result),_) + derivations(underlyingElement(this),_,_,unresolveElement(result),_) } /** @@ -775,7 +775,7 @@ class ClassDerivation extends Locatable, @derivation { * struct D : B {}; */ Class getDerivedClass() { - derivations(unresolveElement(this),unresolveElement(result),_,_,_) + derivations(underlyingElement(this),unresolveElement(result),_,_,_) } /** @@ -784,12 +784,12 @@ class ClassDerivation extends Locatable, @derivation { * derivation of B2 in "struct D : B1, B2 { ... };" would be 1. */ int getIndex() { - derivations(unresolveElement(this),_,result,_,_) + derivations(underlyingElement(this),_,result,_,_) } /** Gets a specifier (for example "public") applied to the derivation. */ Specifier getASpecifier() { - derspecifiers(unresolveElement(this),unresolveElement(result)) + derspecifiers(underlyingElement(this),unresolveElement(result)) } /** Holds if the derivation has specifier `s`. */ @@ -804,7 +804,7 @@ class ClassDerivation extends Locatable, @derivation { /** Gets the location of the derivation. */ override Location getLocation() { - derivations(unresolveElement(this),_,_,_,result) + derivations(underlyingElement(this),_,_,_,result) } /** @@ -816,7 +816,7 @@ class ClassDerivation extends Locatable, @derivation { * classes. */ int getByteOffset() { - direct_base_offsets(unresolveElement(this), result) + direct_base_offsets(underlyingElement(this), result) } override string toString() { @@ -869,7 +869,7 @@ class AbstractClass extends Class { * of class templates). */ class TemplateClass extends Class { - TemplateClass() { usertypes(unresolveElement(this),_,6) } + TemplateClass() { usertypes(underlyingElement(this),_,6) } Class getAnInstantiation() { result.isConstructedFrom(this) and exists(result.getATemplateArgument()) @@ -998,7 +998,7 @@ class VirtualBaseClass extends Class { */ class ProxyClass extends UserType { ProxyClass() { - usertypes(unresolveElement(this),_,9) + usertypes(underlyingElement(this),_,9) } /** Gets the location of the proxy class. */ @@ -1008,7 +1008,7 @@ class ProxyClass extends UserType { /** Gets the template parameter for which this is the proxy class. */ TemplateParameter getTemplateParameter() { - is_proxy_class_for(unresolveElement(this),unresolveElement(result)) + is_proxy_class_for(underlyingElement(this),unresolveElement(result)) } } diff --git a/cpp/ql/src/semmle/code/cpp/Comments.qll b/cpp/ql/src/semmle/code/cpp/Comments.qll index 4cf40ec4692..2b3add5b67b 100644 --- a/cpp/ql/src/semmle/code/cpp/Comments.qll +++ b/cpp/ql/src/semmle/code/cpp/Comments.qll @@ -6,9 +6,9 @@ import semmle.code.cpp.Element */ class Comment extends Locatable, @comment { override string toString() { result = this.getContents() } - override Location getLocation() { comments(unresolveElement(this),_,result) } - string getContents() { comments(unresolveElement(this),result,_) } - Element getCommentedElement() { commentbinding(unresolveElement(this),unresolveElement(result)) } + override Location getLocation() { comments(underlyingElement(this),_,result) } + string getContents() { comments(underlyingElement(this),result,_) } + Element getCommentedElement() { commentbinding(underlyingElement(this),unresolveElement(result)) } } /** diff --git a/cpp/ql/src/semmle/code/cpp/Diagnostics.qll b/cpp/ql/src/semmle/code/cpp/Diagnostics.qll index a8304cc1216..aaa251ada34 100644 --- a/cpp/ql/src/semmle/code/cpp/Diagnostics.qll +++ b/cpp/ql/src/semmle/code/cpp/Diagnostics.qll @@ -7,26 +7,26 @@ class Diagnostic extends Locatable, @diagnostic { * Gets the severity of the message, on a range from 1 to 5: 1=remark, * 2=warning, 3=discretionary error, 4=error, 5=catastrophic error. */ - int getSeverity() { diagnostics(unresolveElement(this), result, _, _, _, _) } + int getSeverity() { diagnostics(underlyingElement(this), result, _, _, _, _) } /** Gets the error code for this compiler message. */ - string getTag() { diagnostics(unresolveElement(this), _, result, _, _, _) } + string getTag() { diagnostics(underlyingElement(this), _, result, _, _, _) } predicate hasTag(string s) { this.getTag() = s } /** * Gets the error message text associated with this compiler * diagnostic. */ - string getMessage() { diagnostics(unresolveElement(this), _, _, result, _, _) } + string getMessage() { diagnostics(underlyingElement(this), _, _, result, _, _) } /** * Gets the full error message text associated with this compiler * diagnostic. */ - string getFullMessage() { diagnostics(unresolveElement(this), _, _, _, result, _) } + string getFullMessage() { diagnostics(underlyingElement(this), _, _, _, result, _) } /** Gets the source location corresponding to the compiler message. */ - override Location getLocation() { diagnostics(unresolveElement(this), _, _, _, _, result) } + override Location getLocation() { diagnostics(underlyingElement(this), _, _, _, _, result) } override string toString() { result = this.getMessage() } diff --git a/cpp/ql/src/semmle/code/cpp/Element.qll b/cpp/ql/src/semmle/code/cpp/Element.qll index 7b993eb7732..9fdc359aeec 100644 --- a/cpp/ql/src/semmle/code/cpp/Element.qll +++ b/cpp/ql/src/semmle/code/cpp/Element.qll @@ -16,6 +16,10 @@ cached @element unresolveElement(Element e) { resolveElement(result) = e } +cached @element underlyingElement(Element e) { + result = e +} + /** * A C/C++ element. This class is the base class for all C/C++ * elements, such as functions, classes, expressions, and so on. @@ -136,7 +140,7 @@ class Element extends @element { | this = s and result = s.getParent()) or - using_container(unresolveElement(result), unresolveElement(this)) + using_container(unresolveElement(result), underlyingElement(this)) } /** @@ -158,17 +162,17 @@ class Element extends @element { } private Element getEnclosingElementPref() { - enclosingfunction(unresolveElement(this), unresolveElement(result)) or + enclosingfunction(underlyingElement(this), unresolveElement(result)) or result.(Function) = stmtEnclosingElement(this) or this.(LocalScopeVariable).getFunction() = result or - enumconstants(unresolveElement(this), unresolveElement(result), _, _, _, _) or - derivations(unresolveElement(this), unresolveElement(result), _, _, _) or - stmtparents(unresolveElement(this), _, unresolveElement(result)) or - exprparents(unresolveElement(this), _, unresolveElement(result)) or - namequalifiers(unresolveElement(this), unresolveElement(result), _, _) or - initialisers(unresolveElement(this), unresolveElement(result), _, _) or - exprconv(unresolveElement(result), unresolveElement(this)) or - param_decl_bind(unresolveElement(this),_,unresolveElement(result)) + enumconstants(underlyingElement(this), unresolveElement(result), _, _, _, _) or + derivations(underlyingElement(this), unresolveElement(result), _, _, _) or + stmtparents(underlyingElement(this), _, unresolveElement(result)) or + exprparents(underlyingElement(this), _, unresolveElement(result)) or + namequalifiers(underlyingElement(this), unresolveElement(result), _, _) or + initialisers(underlyingElement(this), unresolveElement(result), _, _) or + exprconv(unresolveElement(result), underlyingElement(this)) or + param_decl_bind(underlyingElement(this),_,unresolveElement(result)) } /** Gets the closest `Element` enclosing this one. */ @@ -181,7 +185,7 @@ class Element extends @element { or result = exprEnclosingElement(this) or - var_decls(unresolveElement(this), unresolveElement(result), _, _, _) + var_decls(underlyingElement(this), unresolveElement(result), _, _, _) ) ) } @@ -247,7 +251,7 @@ private predicate isFromUninstantiatedTemplateRec(Element e, Element template) { */ class StaticAssert extends Locatable, @static_assert { override string toString() { result = "static_assert(..., \"" + getMessage() + "\")" } - Expr getCondition() { static_asserts(unresolveElement(this), unresolveElement(result), _, _) } - string getMessage() { static_asserts(unresolveElement(this), _, result, _) } - override Location getLocation() { static_asserts(unresolveElement(this), _, _, result) } + Expr getCondition() { static_asserts(underlyingElement(this), unresolveElement(result), _, _) } + string getMessage() { static_asserts(underlyingElement(this), _, result, _) } + override Location getLocation() { static_asserts(underlyingElement(this), _, _, result) } } diff --git a/cpp/ql/src/semmle/code/cpp/Enum.qll b/cpp/ql/src/semmle/code/cpp/Enum.qll index afdc6335223..13dd0d7802d 100644 --- a/cpp/ql/src/semmle/code/cpp/Enum.qll +++ b/cpp/ql/src/semmle/code/cpp/Enum.qll @@ -7,7 +7,7 @@ private import semmle.code.cpp.internal.Type class Enum extends UserType, IntegralOrEnumType { /** Gets an enumerator of this enumeration. */ EnumConstant getAnEnumConstant() { result.getDeclaringEnum() = this } - EnumConstant getEnumConstant(int index) { enumconstants(unresolveElement(result),unresolveElement(this),index,_,_,_) } + EnumConstant getEnumConstant(int index) { enumconstants(unresolveElement(result),underlyingElement(this),index,_,_,_) } /** * Gets a descriptive string for the enum. This method is only intended to @@ -24,7 +24,7 @@ class Enum extends UserType, IntegralOrEnumType { * For example: `enum E : int`. */ predicate hasExplicitUnderlyingType() { - derivations(_, unresolveElement(this), _, _, _) + derivations(_, underlyingElement(this), _, _, _) } /** @@ -32,7 +32,7 @@ class Enum extends UserType, IntegralOrEnumType { * For example: `int` in `enum E : int`. */ Type getExplicitUnderlyingType() { - derivations(_, unresolveElement(this), _, unresolveElement(result), _) + derivations(_, underlyingElement(this), _, unresolveElement(result), _) } } @@ -72,7 +72,7 @@ class NestedEnum extends Enum { */ class ScopedEnum extends Enum { ScopedEnum() { - usertypes(unresolveElement(this),_,13) + usertypes(underlyingElement(this),_,13) } } @@ -87,7 +87,7 @@ class EnumConstant extends Declaration, @enumconstant { /** * Gets the enumeration of which this enumerator is a member. */ - Enum getDeclaringEnum() { enumconstants(unresolveElement(this),unresolveElement(result),_,_,_,_) } + Enum getDeclaringEnum() { enumconstants(underlyingElement(this),unresolveElement(result),_,_,_,_) } override Class getDeclaringType() { result = this.getDeclaringEnum().getDeclaringType() @@ -96,7 +96,7 @@ class EnumConstant extends Declaration, @enumconstant { /** * Gets the name of this enumerator. */ - override string getName() { enumconstants(unresolveElement(this),_,_,_,result,_) } + override string getName() { enumconstants(underlyingElement(this),_,_,_,result,_) } /** * Gets the value that this enumerator is initialized to, as a @@ -106,13 +106,13 @@ class EnumConstant extends Declaration, @enumconstant { string getValue() { result = this.getInitializer().getExpr().getValue() } /** Gets the type of this enumerator. */ - Type getType() { enumconstants(unresolveElement(this),_,_,unresolveElement(result),_,_) } + Type getType() { enumconstants(underlyingElement(this),_,_,unresolveElement(result),_,_) } /** Gets the location of a declaration of this enumerator. */ override Location getADeclarationLocation() { result = this.getDefinitionLocation() } /** Gets the location of the definition of this enumerator. */ - override Location getDefinitionLocation() { enumconstants(unresolveElement(this),_,_,_,_,result) } + override Location getDefinitionLocation() { enumconstants(underlyingElement(this),_,_,_,_,result) } /** Gets the location of the definition of this enumerator. */ override Location getLocation() { result = this.getDefinitionLocation() } @@ -124,7 +124,7 @@ class EnumConstant extends Declaration, @enumconstant { EnumConstantAccess getAnAccess() { result.getTarget() = this } /** Gets a specifier of this enumerator. */ - override Specifier getASpecifier() { varspecifiers(unresolveElement(this),unresolveElement(result)) } + override Specifier getASpecifier() { varspecifiers(underlyingElement(this),unresolveElement(result)) } /** * An attribute of this enumerator. @@ -133,6 +133,6 @@ class EnumConstant extends Declaration, @enumconstant { * which is only supported by Clang. */ Attribute getAnAttribute() { - varattributes(unresolveElement(this), unresolveElement(result)) + varattributes(underlyingElement(this), unresolveElement(result)) } } diff --git a/cpp/ql/src/semmle/code/cpp/Field.qll b/cpp/ql/src/semmle/code/cpp/Field.qll index f6131955b75..69fd13e1059 100644 --- a/cpp/ql/src/semmle/code/cpp/Field.qll +++ b/cpp/ql/src/semmle/code/cpp/Field.qll @@ -8,14 +8,14 @@ import semmle.code.cpp.exprs.Access class Field extends MemberVariable { Field() { - fieldoffsets(unresolveElement(this),_,_) + fieldoffsets(underlyingElement(this),_,_) } /** * Gets the offset of this field in bytes from the start of its declaring * type (on the machine where facts were extracted). */ - int getByteOffset() { fieldoffsets(unresolveElement(this),result,_) } + int getByteOffset() { fieldoffsets(underlyingElement(this),result,_) } /** * Gets the byte offset within `mostDerivedClass` of each occurence of this @@ -70,13 +70,13 @@ class Field extends MemberVariable { * Syntactically, this looks like `int x : 3` in `struct S { int x : 3; };`. */ class BitField extends Field { - BitField() { bitfield(unresolveElement(this),_,_) } + BitField() { bitfield(underlyingElement(this),_,_) } /** * Gets the size of this bitfield in bits (on the machine where facts * were extracted). */ - int getNumBits() { bitfield(unresolveElement(this),result,_) } + int getNumBits() { bitfield(underlyingElement(this),result,_) } /** * Gets the value which appeared after the colon in the bitfield @@ -88,13 +88,13 @@ class BitField extends Field { * `getNumBits` will give 32, whereas `getDeclaredNumBits` will give * 1234. */ - int getDeclaredNumBits() { bitfield(unresolveElement(this),_,result) } + int getDeclaredNumBits() { bitfield(underlyingElement(this),_,result) } /** * Gets the offset of this bitfield in bits from the byte identified by * getByteOffset (on the machine where facts were extracted). */ - int getBitOffset() { fieldoffsets(unresolveElement(this),_,result) } + int getBitOffset() { fieldoffsets(underlyingElement(this),_,result) } predicate isAnonymous() { hasName("(unnamed bitfield)") diff --git a/cpp/ql/src/semmle/code/cpp/File.qll b/cpp/ql/src/semmle/code/cpp/File.qll index e323cef2112..701d3fe1383 100644 --- a/cpp/ql/src/semmle/code/cpp/File.qll +++ b/cpp/ql/src/semmle/code/cpp/File.qll @@ -127,7 +127,7 @@ abstract class Container extends Locatable, @container { /** Gets the parent container of this file or folder, if any. */ Container getParentContainer() { - containerparent(unresolveElement(result), unresolveElement(this)) + containerparent(unresolveElement(result), underlyingElement(this)) } /** Gets a file or sub-folder in this container. */ @@ -179,7 +179,7 @@ abstract class Container extends Locatable, @container { */ class Folder extends Container, @folder { override string getAbsolutePath() { - folders(unresolveElement(this), result, _) + folders(underlyingElement(this), result, _) } override Location getLocation() { @@ -200,7 +200,7 @@ class Folder extends Container, @folder { * Gets the name of this folder. */ deprecated - string getName() { folders(unresolveElement(this),result,_) } + string getName() { folders(underlyingElement(this),result,_) } /** * DEPRECATED: use `getAbsolutePath` instead. @@ -223,7 +223,7 @@ class Folder extends Container, @folder { deprecated string getShortName() { exists (string longnameRaw, string longname - | folders(unresolveElement(this),_,longnameRaw) and + | folders(underlyingElement(this),_,longnameRaw) and longname = longnameRaw.replaceAll("\\", "/") | exists (int index | result = longname.splitAt("/", index) and @@ -235,7 +235,7 @@ class Folder extends Container, @folder { * Gets the parent folder. */ deprecated - Folder getParent() { containerparent(unresolveElement(result),unresolveElement(this)) } + Folder getParent() { containerparent(unresolveElement(result),underlyingElement(this)) } } /** @@ -252,7 +252,7 @@ class Folder extends Container, @folder { */ class File extends Container, @file { override string getAbsolutePath() { - files(unresolveElement(this), result, _, _, _) + files(underlyingElement(this), result, _, _, _) } override string toString() { @@ -274,12 +274,12 @@ class File extends Container, @file { /** Holds if this file was compiled as C (at any point). */ predicate compiledAsC() { - fileannotations(unresolveElement(this),1,"compiled as c","1") + fileannotations(underlyingElement(this),1,"compiled as c","1") } /** Holds if this file was compiled as C++ (at any point). */ predicate compiledAsCpp() { - fileannotations(unresolveElement(this),1,"compiled as c++","1") + fileannotations(underlyingElement(this),1,"compiled as c++","1") } /** @@ -333,14 +333,14 @@ class File extends Container, @file { * Gets the folder which contains this file. */ deprecated - Folder getParent() { containerparent(unresolveElement(result),unresolveElement(this)) } + Folder getParent() { containerparent(unresolveElement(result),underlyingElement(this)) } /** * Holds if this file may be from source. This predicate holds for all files * except the dummy file, whose name is the empty string, which contains * declarations that are built into the compiler. */ - override predicate fromSource() { numlines(unresolveElement(this),_,_,_) } + override predicate fromSource() { numlines(underlyingElement(this),_,_,_) } /** * Holds if this file may be from a library. @@ -359,7 +359,7 @@ class File extends Container, @file { * "/usr/home/me/myprogram.c". */ deprecated - string getName() { files(unresolveElement(this),result,_,_,_) } + string getName() { files(underlyingElement(this),result,_,_,_) } /** * DEPRECATED: Use `getAbsolutePath` instead. @@ -391,7 +391,7 @@ class File extends Container, @file { * "tar.gz", while `getExtension` will have the result "gz". */ string getExtensions() { - files(unresolveElement(this),_,_,result,_) + files(underlyingElement(this),_,_,result,_) } /** @@ -424,7 +424,7 @@ class File extends Container, @file { * for example, for "file.tar.gz", this predicate will have the result * "file", while `getStem` will have the result "file.tar". */ - string getShortName() { files(unresolveElement(this),_,result,_,_) } + string getShortName() { files(underlyingElement(this),_,result,_,_) } } diff --git a/cpp/ql/src/semmle/code/cpp/FriendDecl.qll b/cpp/ql/src/semmle/code/cpp/FriendDecl.qll index e40e00c6c96..5cf18cb39f9 100644 --- a/cpp/ql/src/semmle/code/cpp/FriendDecl.qll +++ b/cpp/ql/src/semmle/code/cpp/FriendDecl.qll @@ -33,7 +33,7 @@ class FriendDecl extends Declaration, @frienddecl { override Location getDefinitionLocation() { result = this.getLocation() } /** Gets the location of this friend declaration. */ - override Location getLocation() { frienddecls(unresolveElement(this),_,_,result) } + override Location getLocation() { frienddecls(underlyingElement(this),_,_,result) } /** Gets a descriptive string for this friend declaration. */ override string getName() { @@ -51,13 +51,13 @@ class FriendDecl extends Declaration, @frienddecl { * Gets the target of this friend declaration. * For example: `X` in `class A { friend class X }`. */ - AccessHolder getFriend() { frienddecls(unresolveElement(this),_,unresolveElement(result),_) } + AccessHolder getFriend() { frienddecls(underlyingElement(this),_,unresolveElement(result),_) } /** * Gets the declaring class (also known as the befriending class). * For example: `A` in `class A { friend class X }`. */ - Class getDeclaringClass() { frienddecls(unresolveElement(this),unresolveElement(result),_,_) } + Class getDeclaringClass() { frienddecls(underlyingElement(this),unresolveElement(result),_,_) } /* Holds if this declaration is a top-level declaration. */ override predicate isTopLevel() { none() } diff --git a/cpp/ql/src/semmle/code/cpp/Function.qll b/cpp/ql/src/semmle/code/cpp/Function.qll index 4c8c45f2b20..4dcd4d729e3 100644 --- a/cpp/ql/src/semmle/code/cpp/Function.qll +++ b/cpp/ql/src/semmle/code/cpp/Function.qll @@ -30,7 +30,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function { * To test whether a function has a particular name in the global * namespace, use `hasGlobalName`. */ - override string getName() { functions(unresolveElement(this),result,_) } + override string getName() { functions(underlyingElement(this),result,_) } /** * Gets the full signature of this function, including return type, parameter @@ -70,16 +70,16 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function { /** Gets a specifier of this function. */ override Specifier getASpecifier() { - funspecifiers(unresolveElement(this),unresolveElement(result)) + funspecifiers(underlyingElement(this),unresolveElement(result)) or result.hasName(getADeclarationEntry().getASpecifier()) } /** Gets an attribute of this function. */ - Attribute getAnAttribute() { funcattributes(unresolveElement(this), unresolveElement(result)) } + Attribute getAnAttribute() { funcattributes(underlyingElement(this), unresolveElement(result)) } /** Holds if this function is generated by the compiler. */ predicate isCompilerGenerated() { - compgenerated(unresolveElement(this)) + compgenerated(underlyingElement(this)) } /** Holds if this function is inline. */ @@ -104,7 +104,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function { * whether a class would have had those members implicitly deleted. */ predicate isDeleted() { - function_deleted(unresolveElement(this)) + function_deleted(underlyingElement(this)) } /** @@ -112,7 +112,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function { * specifier. */ predicate isDefaulted() { - function_defaulted(unresolveElement(this)) + function_defaulted(underlyingElement(this)) } /** @@ -124,13 +124,13 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function { } /** Gets the return type of this function. */ - Type getType() { function_return_type(unresolveElement(this),unresolveElement(result)) } + Type getType() { function_return_type(underlyingElement(this),unresolveElement(result)) } /** Gets the nth parameter of this function. */ - Parameter getParameter(int n) { params(unresolveElement(result),unresolveElement(this),n,_) } + Parameter getParameter(int n) { params(unresolveElement(result),underlyingElement(this),n,_) } /** Gets a parameter of this function. */ - Parameter getAParameter() { params(unresolveElement(result),unresolveElement(this),_,_) } + Parameter getAParameter() { params(unresolveElement(result),underlyingElement(this),_,_) } /** * Gets the number of parameters of this function, _not_ including any @@ -183,14 +183,14 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function { * in `Declaration.qll`. */ override FunctionDeclarationEntry getADeclarationEntry() { - if fun_decls(_,unresolveElement(this),_,_,_) then + if fun_decls(_,underlyingElement(this),_,_,_) then declEntry(result) else exists(Function f | this.isConstructedFrom(f) and fun_decls(unresolveElement(result),unresolveElement(f),_,_,_)) } private predicate declEntry(FunctionDeclarationEntry fde) { - fun_decls(unresolveElement(fde),unresolveElement(this),_,_,_) and + fun_decls(unresolveElement(fde),underlyingElement(this),_,_,_) and // If one .cpp file specializes a function, and another calls the // specialized function, then when extracting the second we only see an // instantiation, not the specialization. We Therefore need to ignore @@ -208,7 +208,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function { /** Holds if this Function is a Template specialization. */ predicate isSpecialization() { - exists(FunctionDeclarationEntry fde | fun_decls(unresolveElement(fde),unresolveElement(this),_,_,_) + exists(FunctionDeclarationEntry fde | fun_decls(unresolveElement(fde),underlyingElement(this),_,_,_) and fde.isSpecialization()) } @@ -263,7 +263,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function { * `FunctionTryStmt`. */ Stmt getEntryPoint() { - function_entry_point(unresolveElement(this), unresolveElement(result)) + function_entry_point(underlyingElement(this), unresolveElement(result)) } /** @@ -341,7 +341,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function { * function or from a function nested in a template class. */ predicate isConstructedFrom(Function f) { - function_instantiation(unresolveElement(this), unresolveElement(f)) + function_instantiation(underlyingElement(this), unresolveElement(f)) } /** @@ -357,7 +357,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function { * template class. */ Type getTemplateArgument(int index) { - function_template_argument(unresolveElement(this),index,unresolveElement(result)) + function_template_argument(underlyingElement(this),index,unresolveElement(result)) } /** @@ -496,22 +496,22 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl { override Function getDeclaration() { result = getFunction() } /** Gets the function which is being declared or defined. */ - Function getFunction() { fun_decls(unresolveElement(this),unresolveElement(result),_,_,_) } + Function getFunction() { fun_decls(underlyingElement(this),unresolveElement(result),_,_,_) } /** Gets the name of the function. */ - override string getName() { fun_decls(unresolveElement(this),_,_,result,_) } + override string getName() { fun_decls(underlyingElement(this),_,_,result,_) } /** * Gets the return type of the function which is being declared or * defined. */ - override Type getType() { fun_decls(unresolveElement(this),_,unresolveElement(result),_,_) } + override Type getType() { fun_decls(underlyingElement(this),_,unresolveElement(result),_,_) } /** Gets the location of this declaration entry. */ - override Location getLocation() { fun_decls(unresolveElement(this),_,_,_,result) } + override Location getLocation() { fun_decls(underlyingElement(this),_,_,_,result) } /** Gets a specifier associated with this declaration entry. */ - override string getASpecifier() { fun_decl_specifiers(unresolveElement(this),result) } + override string getASpecifier() { fun_decl_specifiers(underlyingElement(this),result) } /** * Implements `Element.getEnclosingElement`. A function declaration does @@ -528,7 +528,7 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl { * static Foo foo; */ TypedefType getTypedefType() { - fun_decl_typedef_type(unresolveElement(this),unresolveElement(result)) + fun_decl_typedef_type(underlyingElement(this),unresolveElement(result)) } /** @@ -578,7 +578,7 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl { * declaration. */ ParameterDeclarationEntry getParameterDeclarationEntry(int n) { - param_decl_bind(unresolveElement(result),n,unresolveElement(this)) + param_decl_bind(unresolveElement(result),n,underlyingElement(this)) } /** Gets the number of parameters of this function declaration. */ @@ -624,12 +624,12 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl { /** Holds if this declaration is also a definition of its function. */ override predicate isDefinition() { - fun_def(unresolveElement(this)) + fun_def(underlyingElement(this)) } /** Holds if this declaration is a Template specialization. */ predicate isSpecialization() { - fun_specialized(unresolveElement(this)) + fun_specialized(underlyingElement(this)) } /** @@ -637,7 +637,7 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl { * where a function is used before it is declared (under older C standards). */ predicate isImplicit() { - fun_implicit(unresolveElement(this)) + fun_implicit(underlyingElement(this)) } /** Gets a type that is specified to be thrown by the declared function. */ @@ -652,7 +652,7 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl { * `int`, and that with index 1 would be `float`. */ Type getThrownType(int i) { - fun_decl_throws(unresolveElement(this),i,unresolveElement(result)) + fun_decl_throws(underlyingElement(this),i,unresolveElement(result)) } /** @@ -660,7 +660,7 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl { * this predicate returns the argument to `noexcept` if one was given. */ Expr getNoExceptExpr() { - fun_decl_noexcept(unresolveElement(this),unresolveElement(result)) + fun_decl_noexcept(underlyingElement(this),unresolveElement(result)) } /** @@ -668,8 +668,8 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl { * 15.4]. */ predicate hasExceptionSpecification() { - fun_decl_throws(unresolveElement(this),_,_) or - fun_decl_noexcept(unresolveElement(this),_) or + fun_decl_throws(underlyingElement(this),_,_) or + fun_decl_noexcept(underlyingElement(this),_) or isNoThrow() or isNoExcept() } @@ -678,7 +678,7 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl { * Holds if the declared function has a `throw()` exception specification. */ predicate isNoThrow() { - fun_decl_empty_throws(unresolveElement(this)) + fun_decl_empty_throws(underlyingElement(this)) } /** @@ -686,7 +686,7 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl { * specification. */ predicate isNoExcept() { - fun_decl_empty_noexcept(unresolveElement(this)) + fun_decl_empty_noexcept(underlyingElement(this)) } } @@ -731,7 +731,7 @@ class MemberFunction extends Function { predicate isPublic() { this.hasSpecifier("public") } /** Holds if this function overrides that function. */ - predicate overrides(MemberFunction that) { overrides(unresolveElement(this),unresolveElement(that)) } + predicate overrides(MemberFunction that) { overrides(underlyingElement(this),unresolveElement(that)) } /** Gets a directly overridden function. */ MemberFunction getAnOverriddenFunction() { this.overrides(result) } @@ -758,7 +758,7 @@ class MemberFunction extends Function { class VirtualFunction extends MemberFunction { VirtualFunction() { - this.hasSpecifier("virtual") or purefunctions(unresolveElement(this)) + this.hasSpecifier("virtual") or purefunctions(underlyingElement(this)) } /** Holds if this virtual function is pure. */ @@ -776,7 +776,7 @@ class VirtualFunction extends MemberFunction { */ class PureVirtualFunction extends VirtualFunction { - PureVirtualFunction() { purefunctions(unresolveElement(this)) } + PureVirtualFunction() { purefunctions(underlyingElement(this)) } } @@ -796,7 +796,7 @@ class ConstMemberFunction extends MemberFunction { */ class Constructor extends MemberFunction { - Constructor() { functions(unresolveElement(this),_,2) } + Constructor() { functions(underlyingElement(this),_,2) } /** * Holds if this constructor serves as a default constructor. @@ -825,7 +825,7 @@ class Constructor extends MemberFunction { * to be evaluated. */ ConstructorInit getInitializer(int i) { - exprparents(unresolveElement(result), i, unresolveElement(this)) + exprparents(unresolveElement(result), i, underlyingElement(this)) } } @@ -976,7 +976,7 @@ class NoArgConstructor extends Constructor { * A C++ destructor [N4140 12.4]. */ class Destructor extends MemberFunction { - Destructor() { functions(unresolveElement(this),_,3) } + Destructor() { functions(underlyingElement(this),_,3) } /** * Gets a compiler-generated action which destructs a base class or member @@ -992,7 +992,7 @@ class Destructor extends MemberFunction { * be evaluated. */ DestructorDestruction getDestruction(int i) { - exprparents(unresolveElement(result), i, unresolveElement(this)) + exprparents(unresolveElement(result), i, underlyingElement(this)) } } @@ -1001,7 +1001,7 @@ class Destructor extends MemberFunction { */ class ConversionOperator extends MemberFunction, ImplicitConversionFunction { - ConversionOperator() { functions(unresolveElement(this),_,4) } + ConversionOperator() { functions(underlyingElement(this),_,4) } override Type getSourceType() { result = this.getDeclaringType() } override Type getDestType() { result = this.getType() } @@ -1013,7 +1013,7 @@ class ConversionOperator extends MemberFunction, ImplicitConversionFunction { */ class Operator extends Function { - Operator() { functions(unresolveElement(this),_,5) } + Operator() { functions(underlyingElement(this),_,5) } } @@ -1074,7 +1074,7 @@ class MoveAssignmentOperator extends Operator { * (non-empty) template argument list. */ class TemplateFunction extends Function { - TemplateFunction() { is_function_template(unresolveElement(this)) and exists(getATemplateArgument()) } + TemplateFunction() { is_function_template(underlyingElement(this)) and exists(getATemplateArgument()) } /** * Gets a compiler-generated instantiation of this function template. @@ -1146,7 +1146,7 @@ class FunctionTemplateSpecialization extends Function { */ class BuiltInFunction extends Function { BuiltInFunction() { - functions(unresolveElement(this),_,6) + functions(underlyingElement(this),_,6) } /** Gets a dummy location for the built-in function. */ diff --git a/cpp/ql/src/semmle/code/cpp/Include.qll b/cpp/ql/src/semmle/code/cpp/Include.qll index a52b9221b5b..e519baecce6 100644 --- a/cpp/ql/src/semmle/code/cpp/Include.qll +++ b/cpp/ql/src/semmle/code/cpp/Include.qll @@ -14,7 +14,7 @@ class Include extends PreprocessorDirective, @ppd_include { string getIncludeText() { result = getHead() } /** Gets the file directly included by this `#include`. */ - File getIncludedFile() { includes(unresolveElement(this), unresolveElement(result)) } + File getIncludedFile() { includes(underlyingElement(this), unresolveElement(result)) } /** * Gets a file which might be transitively included by this `#include`. diff --git a/cpp/ql/src/semmle/code/cpp/Initializer.qll b/cpp/ql/src/semmle/code/cpp/Initializer.qll index a70001f30a0..56403ffcfaf 100644 --- a/cpp/ql/src/semmle/code/cpp/Initializer.qll +++ b/cpp/ql/src/semmle/code/cpp/Initializer.qll @@ -4,7 +4,7 @@ import semmle.code.cpp.controlflow.ControlFlowGraph * A C/C++ declaration initializer. */ class Initializer extends ControlFlowNode, @initialiser { - override Location getLocation() { initialisers(unresolveElement(this),_,_,result) } + override Location getLocation() { initialisers(underlyingElement(this),_,_,result) } /** Holds if this initializer is explicit in the source. */ override predicate fromSource() { @@ -20,10 +20,10 @@ class Initializer extends ControlFlowNode, @initialiser { } /** Gets the variable or enum constant being initialized. */ - Declaration getDeclaration() { initialisers(unresolveElement(this),unresolveElement(result),_,_) } + Declaration getDeclaration() { initialisers(underlyingElement(this),unresolveElement(result),_,_) } /** Gets the initializing expression. */ - Expr getExpr() { initialisers(unresolveElement(this),_,unresolveElement(result),_) } + Expr getExpr() { initialisers(underlyingElement(this),_,unresolveElement(result),_) } /** Gets the function containing this control-flow node. */ override Function getControlFlowScope() { diff --git a/cpp/ql/src/semmle/code/cpp/Macro.qll b/cpp/ql/src/semmle/code/cpp/Macro.qll index ea6febaa225..8bf7d1c073d 100644 --- a/cpp/ql/src/semmle/code/cpp/Macro.qll +++ b/cpp/ql/src/semmle/code/cpp/Macro.qll @@ -9,13 +9,13 @@ class Macro extends PreprocessorDirective, @ppd_define { * Gets the head of this macro. For example, `MAX(x,y)` in * `#define MAX(x,y) (((x)>(y))?(x):(y))`. */ - override string getHead() { preproctext(unresolveElement(this),result,_) } + override string getHead() { preproctext(underlyingElement(this),result,_) } /** * Gets the body of this macro. For example, `(((x)>(y))?(x):(y))` in * `#define MAX(x,y) (((x)>(y))?(x):(y))`. */ - string getBody() { preproctext(unresolveElement(this),_,result) } + string getBody() { preproctext(underlyingElement(this),_,result) } /** Gets an invocation of this macro. */ MacroInvocation getAnInvocation() { result.getMacro() = this } @@ -59,7 +59,7 @@ class Macro extends PreprocessorDirective, @ppd_define { */ class MacroAccess extends Locatable, @macroinvocation { /** Gets the macro being invoked. */ - Macro getMacro() { macroinvocations(unresolveElement(this),unresolveElement(result),_,_) } + Macro getMacro() { macroinvocations(underlyingElement(this),unresolveElement(result),_,_) } /** * Gets the location of the outermost macro access that triggered this macro @@ -78,7 +78,7 @@ class MacroAccess extends Locatable, @macroinvocation { * a `#define` directive or inside an argument to another macro. */ Location getActualLocation() { - macroinvocations(unresolveElement(this),_,result,_) + macroinvocations(underlyingElement(this),_,result,_) } /** @@ -111,7 +111,7 @@ class MacroAccess extends Locatable, @macroinvocation { * There is only a single invocation even though `c` occurs twice; this is an * optimization for efficiency. */ - MacroInvocation getParentInvocation() { macroparent(unresolveElement(this),unresolveElement(result)) } + MacroInvocation getParentInvocation() { macroparent(underlyingElement(this),unresolveElement(result)) } /** * Gets the outermost `MacroAccess` along the chain of `getParentInvocation`. @@ -137,14 +137,14 @@ class MacroAccess extends Locatable, @macroinvocation { */ class MacroInvocation extends MacroAccess { MacroInvocation() { - macroinvocations(unresolveElement(this),_,_,1) + macroinvocations(underlyingElement(this),_,_,1) } /** * Gets an element that occurs in this macro invocation or a nested macro * invocation. */ - Locatable getAnExpandedElement() { inmacroexpansion(unresolveElement(result),unresolveElement(this)) } + Locatable getAnExpandedElement() { inmacroexpansion(unresolveElement(result),underlyingElement(this)) } /** * Gets an element that is (partially) affected by a macro @@ -153,7 +153,7 @@ class MacroInvocation extends MacroAccess { * well. */ Locatable getAnAffectedElement() { - inmacroexpansion(unresolveElement(result),unresolveElement(this)) or macrolocationbind(unresolveElement(this), result.getLocation()) + inmacroexpansion(unresolveElement(result),underlyingElement(this)) or macrolocationbind(underlyingElement(this), result.getLocation()) } /** @@ -224,7 +224,7 @@ class MacroInvocation extends MacroAccess { * Use `getExpandedArgument` to get the expanded form. */ string getUnexpandedArgument(int i) { - macro_argument_unexpanded(unresolveElement(this), i, result) + macro_argument_unexpanded(underlyingElement(this), i, result) } /** @@ -238,7 +238,7 @@ class MacroInvocation extends MacroAccess { * differences between expanded and unexpanded arguments. */ string getExpandedArgument(int i) { - macro_argument_expanded(unresolveElement(this), i, result) + macro_argument_expanded(underlyingElement(this), i, result) } } diff --git a/cpp/ql/src/semmle/code/cpp/NameQualifiers.qll b/cpp/ql/src/semmle/code/cpp/NameQualifiers.qll index de00380cca1..fd64300ff03 100644 --- a/cpp/ql/src/semmle/code/cpp/NameQualifiers.qll +++ b/cpp/ql/src/semmle/code/cpp/NameQualifiers.qll @@ -14,7 +14,7 @@ class NameQualifier extends NameQualifiableElement, @namequalifier { /** Gets a location for this name qualifier. */ override Location getLocation() { - namequalifiers(unresolveElement(this),_,_,result) + namequalifiers(underlyingElement(this),_,_,result) } /** @@ -23,7 +23,7 @@ class NameQualifier extends NameQualifiableElement, @namequalifier { * `N2::` has a name qualifier `N1::` in the chain `N1::N2::f()`. */ override NameQualifier getNameQualifier() { - namequalifiers(unresolveElement(result),unresolveElement(this),_,_) + namequalifiers(unresolveElement(result),underlyingElement(this),_,_) } /** @@ -31,7 +31,7 @@ class NameQualifier extends NameQualifiableElement, @namequalifier { * in `N::f()`. */ NameQualifiableElement getQualifiedElement() { - namequalifiers(unresolveElement(this),unresolveElement(result),_,_) + namequalifiers(underlyingElement(this),unresolveElement(result),_,_) } /** @@ -40,7 +40,7 @@ class NameQualifier extends NameQualifiableElement, @namequalifier { */ NameQualifyingElement getQualifyingElement() { exists (NameQualifyingElement nqe - | namequalifiers(unresolveElement(this),_,unresolveElement(nqe),_) and + | namequalifiers(underlyingElement(this),_,unresolveElement(nqe),_) and if nqe instanceof SpecialNameQualifyingElement then (exists (Access a | a = getQualifiedElement() and @@ -54,7 +54,7 @@ class NameQualifier extends NameQualifiableElement, @namequalifier { override string toString() { exists (NameQualifyingElement nqe - | namequalifiers(unresolveElement(this),_,unresolveElement(nqe),_) + | namequalifiers(underlyingElement(this),_,unresolveElement(nqe),_) and result = nqe.getName() + "::") } } @@ -69,7 +69,7 @@ class NameQualifier extends NameQualifiableElement, @namequalifier { class NameQualifiableElement extends Element, @namequalifiableelement { /** Gets the name qualifier associated with this element. */ NameQualifier getNameQualifier() { - namequalifiers(unresolveElement(result),unresolveElement(this),_,_) + namequalifiers(unresolveElement(result),underlyingElement(this),_,_) } /** @@ -106,7 +106,7 @@ class NameQualifyingElement extends Element, @namequalifyingelement { * `NameQualifyingElement` and `X::` is the `NameQualifier`. */ NameQualifier getANameQualifier() { - namequalifiers(unresolveElement(result),_,unresolveElement(this),_) + namequalifiers(unresolveElement(result),_,underlyingElement(this),_) } /** Gets the name of this namespace or user-defined type. */ @@ -121,6 +121,6 @@ class NameQualifyingElement extends Element, @namequalifyingelement { library class SpecialNameQualifyingElement extends NameQualifyingElement, @specialnamequalifyingelement { /** Gets the name of this special qualifying element. */ override string getName() { - specialnamequalifyingelements(unresolveElement(this),result) + specialnamequalifyingelements(underlyingElement(this),result) } } diff --git a/cpp/ql/src/semmle/code/cpp/Namespace.qll b/cpp/ql/src/semmle/code/cpp/Namespace.qll index edac225c261..c1fc8df48d2 100644 --- a/cpp/ql/src/semmle/code/cpp/Namespace.qll +++ b/cpp/ql/src/semmle/code/cpp/Namespace.qll @@ -31,7 +31,7 @@ class Namespace extends NameQualifyingElement, @namespace { } /** Gets the simple name of this namespace. */ - override string getName() { namespaces(unresolveElement(this),result) } + override string getName() { namespaces(underlyingElement(this),result) } /** Holds if this element is named `name`. */ predicate hasName(string name) { name = this.getName() } @@ -56,15 +56,15 @@ class Namespace extends NameQualifyingElement, @namespace { /** Gets the parent namespace, if any. */ Namespace getParentNamespace() { - namespacembrs(unresolveElement(result),unresolveElement(this)) or - (not namespacembrs(_, unresolveElement(this)) and result instanceof GlobalNamespace) + namespacembrs(unresolveElement(result),underlyingElement(this)) or + (not namespacembrs(_, underlyingElement(this)) and result instanceof GlobalNamespace) } /** Gets a child declaration of this namespace. */ - Declaration getADeclaration() { namespacembrs(unresolveElement(this),unresolveElement(result)) } + Declaration getADeclaration() { namespacembrs(underlyingElement(this),unresolveElement(result)) } /** Gets a child namespace of this namespace. */ - Namespace getAChildNamespace() { namespacembrs(unresolveElement(this),unresolveElement(result)) } + Namespace getAChildNamespace() { namespacembrs(underlyingElement(this),unresolveElement(result)) } /** Holds if this namespace may be from source. */ override predicate fromSource() { this.getADeclaration().fromSource() } @@ -106,7 +106,7 @@ class NamespaceDeclarationEntry extends Locatable, @namespace_decl { * is a one-to-many relationship between `Namespace` and * `NamespaceDeclarationEntry`. */ - Namespace getNamespace() { namespace_decls(unresolveElement(this),unresolveElement(result),_,_) } + Namespace getNamespace() { namespace_decls(underlyingElement(this),unresolveElement(result),_,_) } override string toString() { result = this.getNamespace().toString() } @@ -120,20 +120,20 @@ class NamespaceDeclarationEntry extends Locatable, @namespace_decl { * For anonymous declarations, such as "namespace { ... }", this will * give the "namespace" token. */ - override Location getLocation() { namespace_decls(unresolveElement(this),_,result,_) } + override Location getLocation() { namespace_decls(underlyingElement(this),_,result,_) } /** * Gets the location of the namespace declaration entry's body. For * example: the "{ ... }" in "namespace N { ... }". */ - Location getBodyLocation() { namespace_decls(unresolveElement(this),_,_,result) } + Location getBodyLocation() { namespace_decls(underlyingElement(this),_,_,result) } } /** * A C++ `using` directive or `using` declaration. */ abstract class UsingEntry extends Locatable, @using { - override Location getLocation() { usings(unresolveElement(this),_,result) } + override Location getLocation() { usings(underlyingElement(this),_,result) } } /** @@ -142,13 +142,13 @@ abstract class UsingEntry extends Locatable, @using { * `using std::string;` */ class UsingDeclarationEntry extends UsingEntry { - UsingDeclarationEntry() { not exists(Namespace n | usings(unresolveElement(this),unresolveElement(n),_)) } + UsingDeclarationEntry() { not exists(Namespace n | usings(underlyingElement(this),unresolveElement(n),_)) } /** * Gets the declaration that is referenced by this using declaration. For * example, `std::string` in `using std::string`. */ - Declaration getDeclaration() { usings(unresolveElement(this),unresolveElement(result),_) } + Declaration getDeclaration() { usings(underlyingElement(this),unresolveElement(result),_) } override string toString() { result = "using " + this.getDeclaration().toString() @@ -161,13 +161,13 @@ class UsingDeclarationEntry extends UsingEntry { * `using namespace std;` */ class UsingDirectiveEntry extends UsingEntry { - UsingDirectiveEntry() { exists(Namespace n | usings(unresolveElement(this),unresolveElement(n),_)) } + UsingDirectiveEntry() { exists(Namespace n | usings(underlyingElement(this),unresolveElement(n),_)) } /** * Gets the namespace that is referenced by this using directive. For * example, `std` in `using namespace std`. */ - Namespace getNamespace() { usings(unresolveElement(this),unresolveElement(result),_) } + Namespace getNamespace() { usings(underlyingElement(this),unresolveElement(result),_) } override string toString() { result = "using namespace " + this.getNamespace().toString() diff --git a/cpp/ql/src/semmle/code/cpp/Parameter.qll b/cpp/ql/src/semmle/code/cpp/Parameter.qll index 5e537ac8f93..0794f559296 100644 --- a/cpp/ql/src/semmle/code/cpp/Parameter.qll +++ b/cpp/ql/src/semmle/code/cpp/Parameter.qll @@ -102,20 +102,20 @@ class Parameter extends LocalScopeVariable, @parameter { * Gets the function to which this parameter belongs, if it is a function * parameter. */ - override Function getFunction() { params(unresolveElement(this),unresolveElement(result),_,_) } + override Function getFunction() { params(underlyingElement(this),unresolveElement(result),_,_) } /** * Gets the catch block to which this parameter belongs, if it is a catch * block parameter. */ - Block getCatchBlock() { params(unresolveElement(this),unresolveElement(result),_,_) } + Block getCatchBlock() { params(underlyingElement(this),unresolveElement(result),_,_) } /** * Gets the zero-based index of this parameter. * * For catch block parameters, this is always zero. */ - int getIndex() { params(unresolveElement(this),_,result,_) } + int getIndex() { params(underlyingElement(this),_,result,_) } /** * Gets the type of this parameter. @@ -124,7 +124,7 @@ class Parameter extends LocalScopeVariable, @parameter { * as they are syntactic sugar for parameters of pointer type. The * result is an array type for such parameters. */ - override Type getType() { params(unresolveElement(this),_,_,unresolveElement(result)) } + override Type getType() { params(underlyingElement(this),_,_,unresolveElement(result)) } /** * Gets the canonical location, or locations, of this parameter. diff --git a/cpp/ql/src/semmle/code/cpp/Preprocessor.qll b/cpp/ql/src/semmle/code/cpp/Preprocessor.qll index c3b039b96e9..59d25df28b2 100644 --- a/cpp/ql/src/semmle/code/cpp/Preprocessor.qll +++ b/cpp/ql/src/semmle/code/cpp/Preprocessor.qll @@ -8,8 +8,8 @@ import semmle.code.cpp.Element */ class PreprocessorDirective extends Locatable, @preprocdirect { override string toString() { result = "Preprocessor directive" } - override Location getLocation() { preprocdirects(unresolveElement(this),_,result) } - string getHead() { preproctext(unresolveElement(this),result,_) } + override Location getLocation() { preprocdirects(underlyingElement(this),_,result) } + string getHead() { preproctext(underlyingElement(this),result,_) } /** * Gets a preprocessor branching directive whose condition affects @@ -49,7 +49,7 @@ abstract class PreprocessorBranchDirective extends PreprocessorDirective { result = (PreprocessorIf)this or result = (PreprocessorIfdef)this or result = (PreprocessorIfndef)this or - preprocpair(unresolveElement(result), unresolveElement(this)) + preprocpair(unresolveElement(result), underlyingElement(this)) } /** @@ -106,7 +106,7 @@ class PreprocessorBranch extends PreprocessorBranchDirective, @ppd_branch { * condition and subsequently took the branch. */ predicate wasTaken() { - preproctrue(unresolveElement(this)) + preproctrue(underlyingElement(this)) } /** @@ -117,7 +117,7 @@ class PreprocessorBranch extends PreprocessorBranchDirective, @ppd_branch { * `#else` was taken instead. */ predicate wasNotTaken() { - preprocfalse(unresolveElement(this)) + preprocfalse(underlyingElement(this)) } /** diff --git a/cpp/ql/src/semmle/code/cpp/Specifier.qll b/cpp/ql/src/semmle/code/cpp/Specifier.qll index 01ed74105c2..3dcbc1b0490 100644 --- a/cpp/ql/src/semmle/code/cpp/Specifier.qll +++ b/cpp/ql/src/semmle/code/cpp/Specifier.qll @@ -14,7 +14,7 @@ class Specifier extends Element, @specifier { } /** Gets the name of this specifier. */ - string getName() { specifiers(unresolveElement(this),result) } + string getName() { specifiers(underlyingElement(this),result) } /** Holds if the name of this specifier is `name`. */ predicate hasName(string name) { name = this.getName() } @@ -114,9 +114,9 @@ class Attribute extends Element, @attribute { * Note that the name does not include the namespace. For example, the * name of `[[clang::fallthrough]]` is "fallthrough". */ - string getName() { attributes(unresolveElement(this), _, result, _, _) } + string getName() { attributes(underlyingElement(this), _, result, _, _) } - override Location getLocation() { attributes(unresolveElement(this), _, _, _, result) } + override Location getLocation() { attributes(underlyingElement(this), _, _, _, result) } /** Holds if the name of this attribute is `name`. */ predicate hasName(string name) { name = this.getName() } @@ -152,7 +152,7 @@ class StdAttribute extends Attribute, @stdattribute { * As examples, this is "" for `[[carries_dependency]]`, and "clang" for * `[[clang::fallthrough]]`. */ - string getNamespace() { attributes(unresolveElement(this), _, _, result, _) } + string getNamespace() { attributes(underlyingElement(this), _, _, result, _) } /** * Holds if this attribute has the given namespace and name. @@ -249,7 +249,7 @@ class AttributeArgument extends Element, @attribute_arg { * have a named argument. */ string getName() { - attribute_arg_name(unresolveElement(this), result) + attribute_arg_name(underlyingElement(this), result) } /** @@ -257,7 +257,7 @@ class AttributeArgument extends Element, @attribute_arg { * a string or a number. */ string getValueText() { - attribute_arg_value(unresolveElement(this), result) + attribute_arg_value(underlyingElement(this), result) } /** @@ -271,14 +271,14 @@ class AttributeArgument extends Element, @attribute_arg { * Gets the value of this argument, if its value is a type. */ Type getValueType() { - attribute_arg_type(unresolveElement(this), unresolveElement(result)) + attribute_arg_type(underlyingElement(this), unresolveElement(result)) } /** * Gets the attribute to which this is an argument. */ Attribute getAttribute() { - attribute_args(unresolveElement(this), _, unresolveElement(result), _, _) + attribute_args(underlyingElement(this), _, unresolveElement(result), _, _) } /** @@ -286,11 +286,11 @@ class AttributeArgument extends Element, @attribute_arg { * attribute's argument list. */ int getIndex() { - attribute_args(unresolveElement(this), _, _, result, _) + attribute_args(underlyingElement(this), _, _, result, _) } override Location getLocation() { - attribute_args(unresolveElement(this), _, _, _, result) + attribute_args(underlyingElement(this), _, _, _, result) } override string toString() { diff --git a/cpp/ql/src/semmle/code/cpp/Struct.qll b/cpp/ql/src/semmle/code/cpp/Struct.qll index 18a2f9e8f1e..4aecae15278 100644 --- a/cpp/ql/src/semmle/code/cpp/Struct.qll +++ b/cpp/ql/src/semmle/code/cpp/Struct.qll @@ -6,7 +6,7 @@ import semmle.code.cpp.Class */ class Struct extends Class { - Struct() { usertypes(unresolveElement(this),_,1) or usertypes(unresolveElement(this),_,3) } + Struct() { usertypes(underlyingElement(this),_,1) or usertypes(underlyingElement(this),_,3) } override string explain() { result = "struct " + this.getName() } diff --git a/cpp/ql/src/semmle/code/cpp/Type.qll b/cpp/ql/src/semmle/code/cpp/Type.qll index 2b0c338d0ee..583bb55525e 100644 --- a/cpp/ql/src/semmle/code/cpp/Type.qll +++ b/cpp/ql/src/semmle/code/cpp/Type.qll @@ -46,7 +46,7 @@ class Type extends Locatable, @type { // inherits from both Type and Declaration and must override it to resolve // the ambiguity. Specifier getASpecifier() { - typespecifiers(unresolveElement(this),unresolveElement(result)) + typespecifiers(underlyingElement(this),unresolveElement(result)) or result = this.internal_getAnAdditionalSpecifier() } @@ -54,7 +54,7 @@ class Type extends Locatable, @type { /** * Gets an attribute of this type. */ - Attribute getAnAttribute() { typeattributes(unresolveElement(this),unresolveElement(result)) } + Attribute getAnAttribute() { typeattributes(underlyingElement(this),unresolveElement(result)) } /** * Internal -- should be `protected` when QL supports such a flag. Subtypes @@ -98,7 +98,7 @@ class Type extends Locatable, @type { * * For example, starting with `const i64* const` in the context of `typedef long long i64;`, this predicate will return `long long*`. */ - Type getUnspecifiedType() { unspecifiedtype(unresolveElement(this), unresolveElement(result)) } + Type getUnspecifiedType() { unspecifiedtype(underlyingElement(this), unresolveElement(result)) } /** * Gets this type after any top-level specifiers and typedefs have been stripped. @@ -111,18 +111,18 @@ class Type extends Locatable, @type { * Gets the size of this type in bytes. */ int getSize() { - builtintypes(unresolveElement(this), _, _, result, _, _) - or pointerishsize(unresolveElement(this), result, _) - or usertypesize(unresolveElement(this), result, _) + builtintypes(underlyingElement(this), _, _, result, _, _) + or pointerishsize(underlyingElement(this), result, _) + or usertypesize(underlyingElement(this), result, _) } /** * Gets the alignment of this type in bytes. */ int getAlignment() { - builtintypes(unresolveElement(this), _, _, _, _, result) - or pointerishsize(unresolveElement(this), _, result) - or usertypesize(unresolveElement(this), _, result) + builtintypes(underlyingElement(this), _, _, _, _, result) + or pointerishsize(underlyingElement(this), _, result) + or usertypesize(underlyingElement(this), _, result) } /** @@ -306,7 +306,7 @@ class Type extends Locatable, @type { class BuiltInType extends Type, @builtintype { override string toString() { result = this.getName() } - override string getName() { builtintypes(unresolveElement(this),result,_,_,_,_) } + override string getName() { builtintypes(underlyingElement(this),result,_,_,_,_) } override string explain() { result = this.getName() } @@ -318,7 +318,7 @@ class BuiltInType extends Type, @builtintype { */ class ErroneousType extends BuiltInType { - ErroneousType() { builtintypes(unresolveElement(this),_,1,_,_,_) } + ErroneousType() { builtintypes(underlyingElement(this),_,1,_,_,_) } } @@ -327,7 +327,7 @@ class ErroneousType extends BuiltInType { */ class UnknownType extends BuiltInType { - UnknownType() { builtintypes(unresolveElement(this),_,2,_,_,_) } + UnknownType() { builtintypes(underlyingElement(this),_,2,_,_,_) } } @@ -342,7 +342,7 @@ private predicate isArithmeticType(@builtintype type, int kind) { */ class ArithmeticType extends BuiltInType { ArithmeticType() { - isArithmeticType(unresolveElement(this), _) + isArithmeticType(underlyingElement(this), _) } } @@ -357,14 +357,14 @@ class IntegralOrEnumType extends Type { IntegralOrEnumType() { // Integral type exists(int kind | - isArithmeticType(unresolveElement(this), kind) and + isArithmeticType(underlyingElement(this), kind) and (kind < 24 or kind = 33 or (35 <= kind and kind <= 37) or kind = 43 or kind = 44) ) or // Enum type ( - usertypes(unresolveElement(this), _, 4) or - usertypes(unresolveElement(this), _, 13) + usertypes(underlyingElement(this), _, 4) or + usertypes(underlyingElement(this), _, 13) ) } } @@ -375,33 +375,33 @@ class IntegralOrEnumType extends Type { class IntegralType extends ArithmeticType, IntegralOrEnumType { /** Holds if this integral type is signed. */ predicate isSigned() { - builtintypes(unresolveElement(this),_,_,_,-1,_) + builtintypes(underlyingElement(this),_,_,_,-1,_) } /** Holds if this integral type is unsigned. */ predicate isUnsigned() { - builtintypes(unresolveElement(this),_,_,_,1,_) + builtintypes(underlyingElement(this),_,_,_,1,_) } /** Holds if this integral type is explicitly signed. */ predicate isExplicitlySigned() { - builtintypes(unresolveElement(this),_,7,_,_,_) or builtintypes(unresolveElement(this),_,10,_,_,_) or builtintypes(unresolveElement(this),_,13,_,_,_) or - builtintypes(unresolveElement(this),_,16,_,_,_) or builtintypes(unresolveElement(this),_,19,_,_,_) or - builtintypes(unresolveElement(this),_,37,_,_,_) + builtintypes(underlyingElement(this),_,7,_,_,_) or builtintypes(underlyingElement(this),_,10,_,_,_) or builtintypes(underlyingElement(this),_,13,_,_,_) or + builtintypes(underlyingElement(this),_,16,_,_,_) or builtintypes(underlyingElement(this),_,19,_,_,_) or + builtintypes(underlyingElement(this),_,37,_,_,_) } /** Holds if this integral type is explicitly unsigned. */ predicate isExplicitlyUnsigned() { - builtintypes(unresolveElement(this),_,6,_,_,_) or builtintypes(unresolveElement(this),_,9,_,_,_) or builtintypes(unresolveElement(this),_,12,_,_,_) or - builtintypes(unresolveElement(this),_,15,_,_,_) or builtintypes(unresolveElement(this),_,18,_,_,_) or - builtintypes(unresolveElement(this),_,36,_,_,_) + builtintypes(underlyingElement(this),_,6,_,_,_) or builtintypes(underlyingElement(this),_,9,_,_,_) or builtintypes(underlyingElement(this),_,12,_,_,_) or + builtintypes(underlyingElement(this),_,15,_,_,_) or builtintypes(underlyingElement(this),_,18,_,_,_) or + builtintypes(underlyingElement(this),_,36,_,_,_) } /** Holds if this integral type is implicitly signed. */ predicate isImplicitlySigned() { - builtintypes(unresolveElement(this),_,5,_,-1,_) or builtintypes(unresolveElement(this),_,8,_,-1,_) or builtintypes(unresolveElement(this),_,11,_,-1,_) or - builtintypes(unresolveElement(this),_,14,_,-1,_) or builtintypes(unresolveElement(this),_,17,_,-1,_) or - builtintypes(unresolveElement(this),_,35,_,-1,_) + builtintypes(underlyingElement(this),_,5,_,-1,_) or builtintypes(underlyingElement(this),_,8,_,-1,_) or builtintypes(underlyingElement(this),_,11,_,-1,_) or + builtintypes(underlyingElement(this),_,14,_,-1,_) or builtintypes(underlyingElement(this),_,17,_,-1,_) or + builtintypes(underlyingElement(this),_,35,_,-1,_) } /** @@ -409,12 +409,12 @@ class IntegralType extends ArithmeticType, IntegralOrEnumType { * example on a `short`, this would give the type `unsigned short`. */ IntegralType getUnsigned() { - (builtintypes(unresolveElement(this),_, 5,_,_,_) or builtintypes(unresolveElement(this),_, 6,_,_,_) or builtintypes(unresolveElement(this),_, 7,_,_,_)) and builtintypes(unresolveElement(result),_, 6,_,_,_) - or (builtintypes(unresolveElement(this),_, 8,_,_,_) or builtintypes(unresolveElement(this),_, 9,_,_,_) or builtintypes(unresolveElement(this),_,10,_,_,_)) and builtintypes(unresolveElement(result),_, 9,_,_,_) - or (builtintypes(unresolveElement(this),_,11,_,_,_) or builtintypes(unresolveElement(this),_,12,_,_,_) or builtintypes(unresolveElement(this),_,13,_,_,_)) and builtintypes(unresolveElement(result),_,12,_,_,_) - or (builtintypes(unresolveElement(this),_,14,_,_,_) or builtintypes(unresolveElement(this),_,15,_,_,_) or builtintypes(unresolveElement(this),_,16,_,_,_)) and builtintypes(unresolveElement(result),_,15,_,_,_) - or (builtintypes(unresolveElement(this),_,17,_,_,_) or builtintypes(unresolveElement(this),_,18,_,_,_) or builtintypes(unresolveElement(this),_,19,_,_,_)) and builtintypes(unresolveElement(result),_,18,_,_,_) - or (builtintypes(unresolveElement(this),_,35,_,_,_) or builtintypes(unresolveElement(this),_,36,_,_,_) or builtintypes(unresolveElement(this),_,37,_,_,_)) and builtintypes(unresolveElement(result),_,36,_,_,_) + (builtintypes(underlyingElement(this),_, 5,_,_,_) or builtintypes(underlyingElement(this),_, 6,_,_,_) or builtintypes(underlyingElement(this),_, 7,_,_,_)) and builtintypes(unresolveElement(result),_, 6,_,_,_) + or (builtintypes(underlyingElement(this),_, 8,_,_,_) or builtintypes(underlyingElement(this),_, 9,_,_,_) or builtintypes(underlyingElement(this),_,10,_,_,_)) and builtintypes(unresolveElement(result),_, 9,_,_,_) + or (builtintypes(underlyingElement(this),_,11,_,_,_) or builtintypes(underlyingElement(this),_,12,_,_,_) or builtintypes(underlyingElement(this),_,13,_,_,_)) and builtintypes(unresolveElement(result),_,12,_,_,_) + or (builtintypes(underlyingElement(this),_,14,_,_,_) or builtintypes(underlyingElement(this),_,15,_,_,_) or builtintypes(underlyingElement(this),_,16,_,_,_)) and builtintypes(unresolveElement(result),_,15,_,_,_) + or (builtintypes(underlyingElement(this),_,17,_,_,_) or builtintypes(underlyingElement(this),_,18,_,_,_) or builtintypes(underlyingElement(this),_,19,_,_,_)) and builtintypes(unresolveElement(result),_,18,_,_,_) + or (builtintypes(underlyingElement(this),_,35,_,_,_) or builtintypes(underlyingElement(this),_,36,_,_,_) or builtintypes(underlyingElement(this),_,37,_,_,_)) and builtintypes(unresolveElement(result),_,36,_,_,_) } } @@ -423,7 +423,7 @@ class IntegralType extends ArithmeticType, IntegralOrEnumType { */ class BoolType extends IntegralType { - BoolType() { builtintypes(unresolveElement(this),_,4,_,_,_) } + BoolType() { builtintypes(underlyingElement(this),_,4,_,_,_) } } @@ -437,7 +437,7 @@ abstract class CharType extends IntegralType { } */ class PlainCharType extends CharType { PlainCharType() { - builtintypes(unresolveElement(this),_,5,_,_,_) + builtintypes(underlyingElement(this),_,5,_,_,_) } } @@ -446,7 +446,7 @@ class PlainCharType extends CharType { */ class UnsignedCharType extends CharType { UnsignedCharType() { - builtintypes(unresolveElement(this),_,6,_,_,_) + builtintypes(underlyingElement(this),_,6,_,_,_) } } @@ -455,7 +455,7 @@ class UnsignedCharType extends CharType { */ class SignedCharType extends CharType { SignedCharType() { - builtintypes(unresolveElement(this),_,7,_,_,_) + builtintypes(underlyingElement(this),_,7,_,_,_) } } @@ -465,7 +465,7 @@ class SignedCharType extends CharType { class ShortType extends IntegralType { ShortType() { - builtintypes(unresolveElement(this),_,8,_,_,_) or builtintypes(unresolveElement(this),_,9,_,_,_) or builtintypes(unresolveElement(this),_,10,_,_,_) + builtintypes(underlyingElement(this),_,8,_,_,_) or builtintypes(underlyingElement(this),_,9,_,_,_) or builtintypes(underlyingElement(this),_,10,_,_,_) } } @@ -476,7 +476,7 @@ class ShortType extends IntegralType { class IntType extends IntegralType { IntType() { - builtintypes(unresolveElement(this),_,11,_,_,_) or builtintypes(unresolveElement(this),_,12,_,_,_) or builtintypes(unresolveElement(this),_,13,_,_,_) + builtintypes(underlyingElement(this),_,11,_,_,_) or builtintypes(underlyingElement(this),_,12,_,_,_) or builtintypes(underlyingElement(this),_,13,_,_,_) } } @@ -487,7 +487,7 @@ class IntType extends IntegralType { class LongType extends IntegralType { LongType() { - builtintypes(unresolveElement(this),_,14,_,_,_) or builtintypes(unresolveElement(this),_,15,_,_,_) or builtintypes(unresolveElement(this),_,16,_,_,_) + builtintypes(underlyingElement(this),_,14,_,_,_) or builtintypes(underlyingElement(this),_,15,_,_,_) or builtintypes(underlyingElement(this),_,16,_,_,_) } } @@ -498,7 +498,7 @@ class LongType extends IntegralType { class LongLongType extends IntegralType { LongLongType() { - builtintypes(unresolveElement(this),_,17,_,_,_) or builtintypes(unresolveElement(this),_,18,_,_,_) or builtintypes(unresolveElement(this),_,19,_,_,_) + builtintypes(underlyingElement(this),_,17,_,_,_) or builtintypes(underlyingElement(this),_,18,_,_,_) or builtintypes(underlyingElement(this),_,19,_,_,_) } } @@ -509,7 +509,7 @@ class LongLongType extends IntegralType { class Int128Type extends IntegralType { Int128Type() { - builtintypes(unresolveElement(this),_,35,_,_,_) or builtintypes(unresolveElement(this),_,36,_,_,_) or builtintypes(unresolveElement(this),_,37,_,_,_) + builtintypes(underlyingElement(this),_,35,_,_,_) or builtintypes(underlyingElement(this),_,36,_,_,_) or builtintypes(underlyingElement(this),_,37,_,_,_) } } @@ -520,7 +520,7 @@ class Int128Type extends IntegralType { class FloatingPointType extends ArithmeticType { FloatingPointType() { - exists(int kind | builtintypes(unresolveElement(this),_,kind,_,_,_) and ((kind >= 24 and kind <= 32) or (kind = 38))) + exists(int kind | builtintypes(underlyingElement(this),_,kind,_,_,_) and ((kind >= 24 and kind <= 32) or (kind = 38))) } } @@ -530,7 +530,7 @@ class FloatingPointType extends ArithmeticType { */ class FloatType extends FloatingPointType { - FloatType() { builtintypes(unresolveElement(this),_,24,_,_,_) } + FloatType() { builtintypes(underlyingElement(this),_,24,_,_,_) } } @@ -539,7 +539,7 @@ class FloatType extends FloatingPointType { */ class DoubleType extends FloatingPointType { - DoubleType() { builtintypes(unresolveElement(this),_,25,_,_,_) } + DoubleType() { builtintypes(underlyingElement(this),_,25,_,_,_) } } @@ -548,7 +548,7 @@ class DoubleType extends FloatingPointType { */ class LongDoubleType extends FloatingPointType { - LongDoubleType() { builtintypes(unresolveElement(this),_,26,_,_,_) } + LongDoubleType() { builtintypes(underlyingElement(this),_,26,_,_,_) } } @@ -557,7 +557,7 @@ class LongDoubleType extends FloatingPointType { */ class Float128Type extends FloatingPointType { - Float128Type() { builtintypes(unresolveElement(this),_,38,_,_,_) } + Float128Type() { builtintypes(underlyingElement(this),_,38,_,_,_) } } @@ -566,7 +566,7 @@ class Float128Type extends FloatingPointType { */ class Decimal32Type extends FloatingPointType { - Decimal32Type() { builtintypes(unresolveElement(this),_,40,_,_,_) } + Decimal32Type() { builtintypes(underlyingElement(this),_,40,_,_,_) } } @@ -575,7 +575,7 @@ class Decimal32Type extends FloatingPointType { */ class Decimal64Type extends FloatingPointType { - Decimal64Type() { builtintypes(unresolveElement(this),_,41,_,_,_) } + Decimal64Type() { builtintypes(underlyingElement(this),_,41,_,_,_) } } @@ -584,7 +584,7 @@ class Decimal64Type extends FloatingPointType { */ class Decimal128Type extends FloatingPointType { - Decimal128Type() { builtintypes(unresolveElement(this),_,42,_,_,_) } + Decimal128Type() { builtintypes(underlyingElement(this),_,42,_,_,_) } } @@ -593,7 +593,7 @@ class Decimal128Type extends FloatingPointType { */ class VoidType extends BuiltInType { - VoidType() { builtintypes(unresolveElement(this),_,3,_,_,_) } + VoidType() { builtintypes(underlyingElement(this),_,3,_,_,_) } } @@ -602,7 +602,7 @@ class VoidType extends BuiltInType { */ class WideCharType extends IntegralType { - WideCharType() { builtintypes(unresolveElement(this),_,33,_,_,_) } + WideCharType() { builtintypes(underlyingElement(this),_,33,_,_,_) } } @@ -611,7 +611,7 @@ class WideCharType extends IntegralType { */ class Char16Type extends IntegralType { - Char16Type() { builtintypes(unresolveElement(this),_,43,_,_,_) } + Char16Type() { builtintypes(underlyingElement(this),_,43,_,_,_) } } @@ -620,7 +620,7 @@ class Char16Type extends IntegralType { */ class Char32Type extends IntegralType { - Char32Type() { builtintypes(unresolveElement(this),_,44,_,_,_) } + Char32Type() { builtintypes(underlyingElement(this),_,44,_,_,_) } } @@ -634,7 +634,7 @@ class Char32Type extends IntegralType { * Instead, this is the unspeakable type given by `decltype(nullptr)`. */ class NullPointerType extends BuiltInType { - NullPointerType() { builtintypes(unresolveElement(this),_,34,_,_,_) } + NullPointerType() { builtintypes(underlyingElement(this),_,34,_,_,_) } } /** @@ -646,7 +646,7 @@ class NullPointerType extends BuiltInType { class DerivedType extends Type, @derivedtype { override string toString() { result = this.getName() } - override string getName() { derivedtypes(unresolveElement(this),result,_,_) } + override string getName() { derivedtypes(underlyingElement(this),result,_,_) } /** * Gets the base type of this derived type. @@ -654,7 +654,7 @@ class DerivedType extends Type, @derivedtype { * This predicate strips off one level of decoration from a type. For example, it returns `char*` for the PointerType `char**`, * `const int` for the ReferenceType `const int&`, and `long` for the SpecifiedType `volatile long`. */ - Type getBaseType() { derivedtypes(unresolveElement(this),_,_,unresolveElement(result)) } + Type getBaseType() { derivedtypes(underlyingElement(this),_,_,unresolveElement(result)) } override predicate refersToDirectly(Type t) { t = this.getBaseType() } @@ -700,14 +700,14 @@ class Decltype extends Type, @decltype { * The expression whose type is being obtained by this decltype. */ Expr getExpr() { - decltypes(unresolveElement(this), unresolveElement(result), _, _) + decltypes(underlyingElement(this), unresolveElement(result), _, _) } /** * The type immediately yielded by this decltype. */ Type getBaseType() { - decltypes(unresolveElement(this), _, unresolveElement(result), _) + decltypes(underlyingElement(this), _, unresolveElement(result), _) } /** @@ -721,7 +721,7 @@ class Decltype extends Type, @decltype { * Consult the C++11 standard for more details. */ predicate parenthesesWouldChangeMeaning() { - decltypes(unresolveElement(this), _, _, true) + decltypes(underlyingElement(this), _, _, true) } override Type getUnderlyingType() { @@ -794,7 +794,7 @@ class Decltype extends Type, @decltype { */ class PointerType extends DerivedType { - PointerType() { derivedtypes(unresolveElement(this),_,1,_) } + PointerType() { derivedtypes(underlyingElement(this),_,1,_) } override int getPointerIndirectionLevel() { result = 1 + this.getBaseType().getPointerIndirectionLevel() @@ -817,7 +817,7 @@ class PointerType extends DerivedType { */ class ReferenceType extends DerivedType { - ReferenceType() { derivedtypes(unresolveElement(this),_,2,_) or derivedtypes(unresolveElement(this),_,8,_) } + ReferenceType() { derivedtypes(underlyingElement(this),_,2,_) or derivedtypes(underlyingElement(this),_,8,_) } override int getPointerIndirectionLevel() { result = getBaseType().getPointerIndirectionLevel() @@ -842,14 +842,14 @@ class ReferenceType extends DerivedType { * A C++11 lvalue reference type (e.g. int&). */ class LValueReferenceType extends ReferenceType { - LValueReferenceType() { derivedtypes(unresolveElement(this),_,2,_) } + LValueReferenceType() { derivedtypes(underlyingElement(this),_,2,_) } } /** * A C++11 rvalue reference type (e.g. int&&). */ class RValueReferenceType extends ReferenceType { - RValueReferenceType() { derivedtypes(unresolveElement(this),_,8,_) } + RValueReferenceType() { derivedtypes(underlyingElement(this),_,8,_) } override string explain() { result = "rvalue " + super.explain() } } @@ -859,7 +859,7 @@ class RValueReferenceType extends ReferenceType { */ class SpecifiedType extends DerivedType { - SpecifiedType() { derivedtypes(unresolveElement(this),_,3,_) } + SpecifiedType() { derivedtypes(underlyingElement(this),_,3,_) } override int getSize() { result = this.getBaseType().getSize() } @@ -901,14 +901,14 @@ class SpecifiedType extends DerivedType { */ class ArrayType extends DerivedType { - ArrayType() { derivedtypes(unresolveElement(this),_,4,_) } + ArrayType() { derivedtypes(underlyingElement(this),_,4,_) } - predicate hasArraySize() { arraysizes(unresolveElement(this),_,_,_) } - int getArraySize() { arraysizes(unresolveElement(this),result,_,_) } + predicate hasArraySize() { arraysizes(underlyingElement(this),_,_,_) } + int getArraySize() { arraysizes(underlyingElement(this),result,_,_) } - int getByteSize() { arraysizes(unresolveElement(this),_,result,_) } + int getByteSize() { arraysizes(underlyingElement(this),_,result,_) } - override int getAlignment() { arraysizes(unresolveElement(this), _, _, result) } + override int getAlignment() { arraysizes(underlyingElement(this), _, _, result) } /** * Gets the size of this array (only valid for arrays declared to be of a constant @@ -941,7 +941,7 @@ class ArrayType extends DerivedType { */ class GNUVectorType extends DerivedType { - GNUVectorType() { derivedtypes(unresolveElement(this),_,5,_) } + GNUVectorType() { derivedtypes(underlyingElement(this),_,5,_) } /** * Get the number of elements in this vector type. @@ -952,7 +952,7 @@ class GNUVectorType extends DerivedType { * the number of elements is the value in the attribute divided by the size * of a single element. */ - int getNumElements() { arraysizes(unresolveElement(this),result,_,_) } + int getNumElements() { arraysizes(underlyingElement(this),result,_,_) } /** * Gets the size, in bytes, of this vector type. @@ -963,9 +963,9 @@ class GNUVectorType extends DerivedType { * attribute, the byte size is the value in the attribute multiplied by the * byte size of a single element. */ - override int getSize() { arraysizes(unresolveElement(this),_,result,_) } + override int getSize() { arraysizes(underlyingElement(this),_,result,_) } - override int getAlignment() { arraysizes(unresolveElement(this), _, _, result) } + override int getAlignment() { arraysizes(underlyingElement(this), _, _, result) } override string explain() { result = "GNU " + getNumElements() + " element vector of {" + this.getBaseType().explain() + "}" } @@ -978,7 +978,7 @@ class GNUVectorType extends DerivedType { */ class FunctionPointerType extends FunctionPointerIshType { FunctionPointerType() { - derivedtypes(unresolveElement(this),_,6,_) + derivedtypes(underlyingElement(this),_,6,_) } override int getPointerIndirectionLevel() { @@ -993,7 +993,7 @@ class FunctionPointerType extends FunctionPointerIshType { */ class FunctionReferenceType extends FunctionPointerIshType { FunctionReferenceType() { - derivedtypes(unresolveElement(this),_,7,_) + derivedtypes(underlyingElement(this),_,7,_) } override int getPointerIndirectionLevel() { @@ -1011,7 +1011,7 @@ class FunctionReferenceType extends FunctionPointerIshType { */ class BlockType extends FunctionPointerIshType { BlockType() { - derivedtypes(unresolveElement(this),_,10,_) + derivedtypes(underlyingElement(this),_,10,_) } override int getPointerIndirectionLevel() { @@ -1026,24 +1026,24 @@ class BlockType extends FunctionPointerIshType { */ class FunctionPointerIshType extends DerivedType { FunctionPointerIshType() { - derivedtypes(unresolveElement(this),_,6, _) or - derivedtypes(unresolveElement(this),_,7, _) or - derivedtypes(unresolveElement(this),_,10,_) + derivedtypes(underlyingElement(this),_,6, _) or + derivedtypes(underlyingElement(this),_,7, _) or + derivedtypes(underlyingElement(this),_,10,_) } /** the return type of this function pointer type */ Type getReturnType() { - exists(RoutineType t | derivedtypes(unresolveElement(this),_,_,unresolveElement(t)) and result = t.getReturnType()) + exists(RoutineType t | derivedtypes(underlyingElement(this),_,_,unresolveElement(t)) and result = t.getReturnType()) } /** the type of the ith argument of this function pointer type */ Type getParameterType(int i) { - exists(RoutineType t | derivedtypes(unresolveElement(this),_,_,unresolveElement(t)) and result = t.getParameterType(i)) + exists(RoutineType t | derivedtypes(underlyingElement(this),_,_,unresolveElement(t)) and result = t.getParameterType(i)) } /** the type of an argument of this function pointer type */ Type getAParameterType() { - exists(RoutineType t | derivedtypes(unresolveElement(this),_,_,unresolveElement(t)) and result = t.getAParameterType()) + exists(RoutineType t | derivedtypes(underlyingElement(this),_,_,unresolveElement(t)) and result = t.getAParameterType()) } /** the number of arguments of this function pointer type */ @@ -1070,10 +1070,10 @@ class PointerToMemberType extends Type, @ptrtomember { override string getName() { result = "..:: *" } /** the base type of this pointer to member type */ - Type getBaseType() { ptrtomembers(unresolveElement(this),unresolveElement(result),_) } + Type getBaseType() { ptrtomembers(underlyingElement(this),unresolveElement(result),_) } /** the class referred by this pointer to member type */ - Type getClass() { ptrtomembers(unresolveElement(this),_,unresolveElement(result)) } + Type getClass() { ptrtomembers(underlyingElement(this),_,unresolveElement(result)) } override predicate refersToDirectly(Type t) { t = this.getBaseType() or @@ -1102,11 +1102,11 @@ class RoutineType extends Type, @routinetype { override string getName() { result = "..()(..)" } - Type getParameterType(int n) { routinetypeargs(unresolveElement(this),n,unresolveElement(result)) } + Type getParameterType(int n) { routinetypeargs(underlyingElement(this),n,unresolveElement(result)) } - Type getAParameterType() { routinetypeargs(unresolveElement(this),_,unresolveElement(result)) } + Type getAParameterType() { routinetypeargs(underlyingElement(this),_,unresolveElement(result)) } - Type getReturnType() { routinetypes(unresolveElement(this), unresolveElement(result)) } + Type getReturnType() { routinetypes(underlyingElement(this), unresolveElement(result)) } override string explain() { result = "function returning {" + this.getReturnType().explain() + @@ -1153,9 +1153,9 @@ class RoutineType extends Type, @routinetype { */ class TemplateParameter extends UserType { - TemplateParameter() { usertypes(unresolveElement(this), _, 7) or usertypes(unresolveElement(this), _, 8) } + TemplateParameter() { usertypes(underlyingElement(this), _, 7) or usertypes(underlyingElement(this), _, 8) } - override string getName() { usertypes(unresolveElement(this), result, _) } + override string getName() { usertypes(underlyingElement(this), result, _) } override predicate involvesTemplateParameter() { any() @@ -1166,7 +1166,7 @@ class TemplateParameter extends UserType class TemplateTemplateParameter extends TemplateParameter { TemplateTemplateParameter() { - usertypes(unresolveElement(this), _, 8) + usertypes(underlyingElement(this), _, 8) } } @@ -1175,7 +1175,7 @@ class TemplateTemplateParameter extends TemplateParameter */ class AutoType extends TemplateParameter { - AutoType() { usertypes(unresolveElement(this), "auto", 7) } + AutoType() { usertypes(underlyingElement(this), "auto", 7) } override Location getLocation() { suppressUnusedThis(this) and @@ -1209,8 +1209,8 @@ class TypeMention extends Locatable, @type_mention { /** * Gets the type being referenced by this type mention. */ - Type getMentionedType() { type_mentions(unresolveElement(this), unresolveElement(result), _, _) } + Type getMentionedType() { type_mentions(underlyingElement(this), unresolveElement(result), _, _) } - override Location getLocation() { type_mentions(unresolveElement(this), _, result, _)} + override Location getLocation() { type_mentions(underlyingElement(this), _, result, _)} } diff --git a/cpp/ql/src/semmle/code/cpp/TypedefType.qll b/cpp/ql/src/semmle/code/cpp/TypedefType.qll index 751a14717f8..d10ac268a6e 100644 --- a/cpp/ql/src/semmle/code/cpp/TypedefType.qll +++ b/cpp/ql/src/semmle/code/cpp/TypedefType.qll @@ -6,12 +6,12 @@ private import semmle.code.cpp.internal.Type */ class TypedefType extends UserType { - TypedefType() { usertypes(unresolveElement(this),_,5) } + TypedefType() { usertypes(underlyingElement(this),_,5) } /** * Gets the base type of this typedef type. */ - Type getBaseType() { typedefbase(unresolveElement(this),unresolveElement(result)) } + Type getBaseType() { typedefbase(underlyingElement(this),unresolveElement(result)) } override Type getUnderlyingType() { result = this.getBaseType().getUnderlyingType() } diff --git a/cpp/ql/src/semmle/code/cpp/Union.qll b/cpp/ql/src/semmle/code/cpp/Union.qll index b0fa68a4211..2f1f55d73ea 100644 --- a/cpp/ql/src/semmle/code/cpp/Union.qll +++ b/cpp/ql/src/semmle/code/cpp/Union.qll @@ -6,7 +6,7 @@ import semmle.code.cpp.Struct */ class Union extends Struct { - Union() { usertypes(unresolveElement(this),_,3) } + Union() { usertypes(underlyingElement(this),_,3) } override string explain() { result = "union " + this.getName() } diff --git a/cpp/ql/src/semmle/code/cpp/UserType.qll b/cpp/ql/src/semmle/code/cpp/UserType.qll index 2c825ad2654..9121ceb8e69 100644 --- a/cpp/ql/src/semmle/code/cpp/UserType.qll +++ b/cpp/ql/src/semmle/code/cpp/UserType.qll @@ -10,7 +10,7 @@ private import semmle.code.cpp.internal.Type */ class UserType extends Type, Declaration, NameQualifyingElement, AccessHolder, @usertype { /** the name of this type */ - override string getName() { usertypes(unresolveElement(this),result,_) } + override string getName() { usertypes(underlyingElement(this),result,_) } /** the simple name of this type, without any template parameters */ string getSimpleName() { @@ -18,7 +18,7 @@ class UserType extends Type, Declaration, NameQualifyingElement, AccessHolder, @ } override predicate hasName(string name) { - usertypes(unresolveElement(this),name,_) + usertypes(underlyingElement(this),name,_) } predicate isAnonymous() { getName().matches("(unnamed%") @@ -39,8 +39,8 @@ class UserType extends Type, Declaration, NameQualifyingElement, AccessHolder, @ } override TypeDeclarationEntry getADeclarationEntry() { - if type_decls(_, unresolveElement(this), _) then - type_decls(unresolveElement(result), unresolveElement(this), _) + if type_decls(_, underlyingElement(this), _) then + type_decls(unresolveElement(result), underlyingElement(this), _) else exists(Class t | this.(Class).isConstructedFrom(t) and result = t.getADeclarationEntry()) } @@ -64,7 +64,7 @@ class UserType extends Type, Declaration, NameQualifyingElement, AccessHolder, @ /** Gets the function that directly encloses this type (if any). */ Function getEnclosingFunction() { - enclosingfunction(unresolveElement(this),unresolveElement(result)) + enclosingfunction(underlyingElement(this),unresolveElement(result)) } /** Whether this is a local type (i.e. a type that has a directly-enclosing function). */ @@ -96,15 +96,15 @@ class TypeDeclarationEntry extends DeclarationEntry, @type_decl { /** * The type which is being declared or defined. */ - override Type getType() { type_decls(unresolveElement(this),unresolveElement(result),_) } + override Type getType() { type_decls(underlyingElement(this),unresolveElement(result),_) } - override Location getLocation() { type_decls(unresolveElement(this),_,result) } - override predicate isDefinition() { type_def(unresolveElement(this)) } + override Location getLocation() { type_decls(underlyingElement(this),_,result) } + override predicate isDefinition() { type_def(underlyingElement(this)) } override string getASpecifier() { none() } /** * A top level type declaration entry is not declared within a function, function declaration, * class or typedef. */ - predicate isTopLevel() { type_decl_top(unresolveElement(this)) } + predicate isTopLevel() { type_decl_top(underlyingElement(this)) } } diff --git a/cpp/ql/src/semmle/code/cpp/Variable.qll b/cpp/ql/src/semmle/code/cpp/Variable.qll index 73b31f56734..4bfa55467fe 100644 --- a/cpp/ql/src/semmle/code/cpp/Variable.qll +++ b/cpp/ql/src/semmle/code/cpp/Variable.qll @@ -30,10 +30,10 @@ class Variable extends Declaration, @variable { * this variable, such as `const` and `volatile`, are instead accessed * through `this.getType().getASpecifier()`. */ - override Specifier getASpecifier() { varspecifiers(unresolveElement(this),unresolveElement(result)) } + override Specifier getASpecifier() { varspecifiers(underlyingElement(this),unresolveElement(result)) } /** Gets an attribute of this variable. */ - Attribute getAnAttribute() { varattributes(unresolveElement(this),unresolveElement(result)) } + Attribute getAnAttribute() { varattributes(underlyingElement(this),unresolveElement(result)) } /** Holds if this variable is `const`. */ predicate isConst() { this.getType().isConst() } @@ -67,13 +67,13 @@ class Variable extends Declaration, @variable { * * `const auto& c = container;` */ - Type getTypeWithAuto() { autoderivation(unresolveElement(this), unresolveElement(result)) } + Type getTypeWithAuto() { autoderivation(underlyingElement(this), unresolveElement(result)) } /** * Holds if the type of this variable is declared using the C++ `auto` * keyword. */ - predicate declaredUsingAutoType() { autoderivation(unresolveElement(this), _) } + predicate declaredUsingAutoType() { autoderivation(underlyingElement(this), _) } override VariableDeclarationEntry getADeclarationEntry() { result.getDeclaration() = this @@ -127,7 +127,7 @@ class Variable extends Declaration, @variable { * variable or from a variable nested in a template class. */ predicate isConstructedFrom(Variable v) { - variable_instantiation(unresolveElement(this), unresolveElement(v)) + variable_instantiation(underlyingElement(this), unresolveElement(v)) } /** @@ -143,7 +143,7 @@ class Variable extends Declaration, @variable { * template variable. */ Type getTemplateArgument(int index) { - variable_template_argument(unresolveElement(this), index, unresolveElement(result)) + variable_template_argument(underlyingElement(this), index, unresolveElement(result)) } /** @@ -154,7 +154,7 @@ class Variable extends Declaration, @variable { * * `for (char c : str) { ... }` */ - predicate isCompilerGenerated() { compgenerated(unresolveElement(this)) } + predicate isCompilerGenerated() { compgenerated(underlyingElement(this)) } } /** @@ -166,7 +166,7 @@ class VariableDeclarationEntry extends DeclarationEntry, @var_decl { /** * Gets the variable which is being declared or defined. */ - Variable getVariable() { var_decls(unresolveElement(this),unresolveElement(result),_,_,_) } + Variable getVariable() { var_decls(underlyingElement(this),unresolveElement(result),_,_,_) } /** * Gets the name, if any, used for the variable at this declaration or @@ -185,14 +185,14 @@ class VariableDeclarationEntry extends DeclarationEntry, @var_decl { * int f(int y) { return y; } * ``` */ - override string getName() { var_decls(unresolveElement(this),_,_,result,_) and result != "" } + override string getName() { var_decls(underlyingElement(this),_,_,result,_) and result != "" } /** * Gets the type of the variable which is being declared or defined. */ - override Type getType() { var_decls(unresolveElement(this),_,unresolveElement(result),_,_) } + override Type getType() { var_decls(underlyingElement(this),_,unresolveElement(result),_,_) } - override Location getLocation() { var_decls(unresolveElement(this),_,_,_,result) } + override Location getLocation() { var_decls(underlyingElement(this),_,_,_,result) } /** * Holds if this is a definition of a variable. @@ -202,9 +202,9 @@ class VariableDeclarationEntry extends DeclarationEntry, @var_decl { * this holds precisely when the enclosing `FunctionDeclarationEntry` is * a definition. */ - override predicate isDefinition() { var_def(unresolveElement(this)) } + override predicate isDefinition() { var_def(underlyingElement(this)) } - override string getASpecifier() { var_decl_specifiers(unresolveElement(this),result) } + override string getASpecifier() { var_decl_specifiers(underlyingElement(this),result) } } /** @@ -212,20 +212,20 @@ class VariableDeclarationEntry extends DeclarationEntry, @var_decl { * of a C/C++ function. */ class ParameterDeclarationEntry extends VariableDeclarationEntry { - ParameterDeclarationEntry() { param_decl_bind(unresolveElement(this),_,_) } + ParameterDeclarationEntry() { param_decl_bind(underlyingElement(this),_,_) } /** * Gets the function declaration or definition which this parameter * description is part of. */ FunctionDeclarationEntry getFunctionDeclarationEntry() { - param_decl_bind(unresolveElement(this),_,unresolveElement(result)) + param_decl_bind(underlyingElement(this),_,unresolveElement(result)) } /** * Gets the zero-based index of this parameter. */ - int getIndex() { param_decl_bind(unresolveElement(this),result,_) } + int getIndex() { param_decl_bind(underlyingElement(this),result,_) } override string toString() { if exists(getName()) @@ -286,9 +286,9 @@ deprecated class StackVariable extends Variable { * scope [N4140 3.3.3], but is not a function parameter. */ class LocalVariable extends LocalScopeVariable, @localvariable { - override string getName() { localvariables(unresolveElement(this),_,result) } + override string getName() { localvariables(underlyingElement(this),_,result) } - override Type getType() { localvariables(unresolveElement(this),unresolveElement(result),_) } + override Type getType() { localvariables(underlyingElement(this),unresolveElement(result),_) } override Function getFunction() { exists(DeclStmt s | s.getADeclaration() = this and s.getEnclosingFunction() = result) @@ -299,9 +299,9 @@ class LocalVariable extends LocalScopeVariable, @localvariable { * A C/C++ variable which has global scope or namespace scope. */ class GlobalOrNamespaceVariable extends Variable, @globalvariable { - override string getName() { globalvariables(unresolveElement(this),_,result) } + override string getName() { globalvariables(underlyingElement(this),_,result) } - override Type getType() { globalvariables(unresolveElement(this),unresolveElement(result),_) } + override Type getType() { globalvariables(underlyingElement(this),unresolveElement(result),_) } override Element getEnclosingElement() { none() } } @@ -311,7 +311,7 @@ class GlobalOrNamespaceVariable extends Variable, @globalvariable { */ class NamespaceVariable extends GlobalOrNamespaceVariable { NamespaceVariable() { - exists(Namespace n | namespacembrs(unresolveElement(n), unresolveElement(this))) + exists(Namespace n | namespacembrs(unresolveElement(n), underlyingElement(this))) } } @@ -348,7 +348,7 @@ class MemberVariable extends Variable, @membervariable { /** Holds if this member is public. */ predicate isPublic() { this.hasSpecifier("public") } - override string getName() { membervariables(unresolveElement(this),_,result) } + override string getName() { membervariables(underlyingElement(this),_,result) } override Type getType() { if (strictcount(this.getAType()) = 1) then ( @@ -366,7 +366,7 @@ class MemberVariable extends Variable, @membervariable { getADeclarationEntry().hasSpecifier("mutable") } - private Type getAType() { membervariables(unresolveElement(this),unresolveElement(result),_) } + private Type getAType() { membervariables(underlyingElement(this),unresolveElement(result),_) } } /** @@ -391,7 +391,7 @@ class FunctionPointerMemberVariable extends MemberVariable { * A C++14 variable template. */ class TemplateVariable extends Variable { - TemplateVariable() { is_variable_template(unresolveElement(this)) } + TemplateVariable() { is_variable_template(underlyingElement(this)) } Variable getAnInstantiation() { result.isConstructedFrom(this) } } diff --git a/cpp/ql/src/semmle/code/cpp/controlflow/ControlFlowGraph.qll b/cpp/ql/src/semmle/code/cpp/controlflow/ControlFlowGraph.qll index 3af20332123..2a420647ca4 100644 --- a/cpp/ql/src/semmle/code/cpp/controlflow/ControlFlowGraph.qll +++ b/cpp/ql/src/semmle/code/cpp/controlflow/ControlFlowGraph.qll @@ -29,7 +29,7 @@ private import semmle.code.cpp.controlflow.internal.ConstantExprs */ class ControlFlowNode extends Locatable, @cfgnode { - ControlFlowNode getASuccessor() { successors_adapted(unresolveElement(this),unresolveElement(result)) } + ControlFlowNode getASuccessor() { successors_adapted(underlyingElement(this),unresolveElement(result)) } ControlFlowNode getAPredecessor() { this = result.getASuccessor() } @@ -54,7 +54,7 @@ class ControlFlowNode extends Locatable, @cfgnode { * taken when this expression is true. */ ControlFlowNode getATrueSuccessor() { - truecond(unresolveElement(this),unresolveElement(result)) and result = getASuccessor() + truecond(underlyingElement(this),unresolveElement(result)) and result = getASuccessor() } /** @@ -62,7 +62,7 @@ class ControlFlowNode extends Locatable, @cfgnode { * taken when this expression is false. */ ControlFlowNode getAFalseSuccessor() { - falsecond(unresolveElement(this),unresolveElement(result)) and result = getASuccessor() + falsecond(underlyingElement(this),unresolveElement(result)) and result = getASuccessor() } BasicBlock getBasicBlock() { diff --git a/cpp/ql/src/semmle/code/cpp/exprs/Access.qll b/cpp/ql/src/semmle/code/cpp/exprs/Access.qll index febbff95500..3acfaff9a5b 100644 --- a/cpp/ql/src/semmle/code/cpp/exprs/Access.qll +++ b/cpp/ql/src/semmle/code/cpp/exprs/Access.qll @@ -25,11 +25,11 @@ abstract class Access extends Expr, NameQualifiableElement { */ class EnumConstantAccess extends Access, @varaccess { EnumConstantAccess() { - exists(EnumConstant c | varbind(unresolveElement(this), unresolveElement(c))) + exists(EnumConstant c | varbind(underlyingElement(this), unresolveElement(c))) } /** Gets the accessed enum constant. */ - override EnumConstant getTarget() { varbind(unresolveElement(this), unresolveElement(result)) } + override EnumConstant getTarget() { varbind(underlyingElement(this), unresolveElement(result)) } /** Gets a textual representation of this enum constant access. */ override string toString() { result = this.getTarget().getName() } @@ -40,11 +40,11 @@ class EnumConstantAccess extends Access, @varaccess { */ class VariableAccess extends Access, @varaccess { VariableAccess() { - not exists(EnumConstant c | varbind(unresolveElement(this), unresolveElement(c))) + not exists(EnumConstant c | varbind(underlyingElement(this), unresolveElement(c))) } /** Gets the accessed variable. */ - override Variable getTarget() { varbind(unresolveElement(this), unresolveElement(result)) } + override Variable getTarget() { varbind(underlyingElement(this), unresolveElement(result)) } /** * Holds if this variable access is providing an LValue in a meaningful way. @@ -133,7 +133,7 @@ class VariableAccess extends Access, @varaccess { * A C/C++ field access expression. */ class FieldAccess extends VariableAccess { - FieldAccess() { exists(Field f | varbind(unresolveElement(this), unresolveElement(f))) } + FieldAccess() { exists(Field f | varbind(underlyingElement(this), unresolveElement(f))) } /** Gets the accessed field. */ override Field getTarget() { result = super.getTarget() } @@ -230,11 +230,11 @@ class ImplicitThisFieldAccess extends FieldAccess { */ class FunctionAccess extends Access, @routineexpr { FunctionAccess() { - not iscall(unresolveElement(this),_) + not iscall(underlyingElement(this),_) } /** Gets the accessed function. */ - override Function getTarget() { funbind(unresolveElement(this), unresolveElement(result)) } + override Function getTarget() { funbind(underlyingElement(this), unresolveElement(result)) } /** Gets a textual representation of this function access. */ override string toString() { diff --git a/cpp/ql/src/semmle/code/cpp/exprs/Assignment.qll b/cpp/ql/src/semmle/code/cpp/exprs/Assignment.qll index ff5a61f7e2a..ec7bbdd0f5f 100644 --- a/cpp/ql/src/semmle/code/cpp/exprs/Assignment.qll +++ b/cpp/ql/src/semmle/code/cpp/exprs/Assignment.qll @@ -152,7 +152,7 @@ class ConditionDeclExpr extends Expr, @condition_decl { Expr getExpr() { result = this.getChild(0) } /** Gets the variable that is declared. */ - Variable getVariable() { condition_decl_bind(unresolveElement(this),unresolveElement(result)) } + Variable getVariable() { condition_decl_bind(underlyingElement(this),unresolveElement(result)) } override string toString() { result = "(condition decl)" } } diff --git a/cpp/ql/src/semmle/code/cpp/exprs/Call.qll b/cpp/ql/src/semmle/code/cpp/exprs/Call.qll index be4f98bbec9..a49799ebf47 100644 --- a/cpp/ql/src/semmle/code/cpp/exprs/Call.qll +++ b/cpp/ql/src/semmle/code/cpp/exprs/Call.qll @@ -146,7 +146,7 @@ abstract class Call extends Expr, NameQualifiableElement { */ class FunctionCall extends Call, @funbindexpr { FunctionCall() { - iscall(unresolveElement(this),_) + iscall(underlyingElement(this),_) } /** Gets an explicit template argument for this call. */ @@ -167,8 +167,8 @@ class FunctionCall extends Call, @funbindexpr { /** Gets the number of explicit template arguments for this call. */ int getNumberOfExplicitTemplateArguments() { - if numtemplatearguments(unresolveElement(this),_) then - numtemplatearguments(unresolveElement(this),result) + if numtemplatearguments(underlyingElement(this),_) then + numtemplatearguments(underlyingElement(this),result) else result = 0 } @@ -193,7 +193,7 @@ class FunctionCall extends Call, @funbindexpr { /** Holds if a template argument list was provided for this call. */ predicate hasTemplateArgumentList() { - numtemplatearguments(unresolveElement(this),_) + numtemplatearguments(underlyingElement(this),_) } /** @@ -240,7 +240,7 @@ class FunctionCall extends Call, @funbindexpr { * In the case of virtual function calls, the result is the most-specific function in the override tree (as * determined by the compiler) such that the target at runtime will be one of result.getAnOverridingFunction*(). */ - override Function getTarget() { funbind(unresolveElement(this),unresolveElement(result)) } + override Function getTarget() { funbind(underlyingElement(this),unresolveElement(result)) } /** * Gets the type of this expression, that is, the return type of the function being called. @@ -253,7 +253,7 @@ class FunctionCall extends Call, @funbindexpr { * Note that this holds even in cases where a sufficiently clever compiler could perform static dispatch. */ predicate isVirtual() { - iscall(unresolveElement(this),1) + iscall(underlyingElement(this),1) } /** @@ -261,7 +261,7 @@ class FunctionCall extends Call, @funbindexpr { * found by any other means. */ predicate isOnlyFoundByADL() { - iscall(unresolveElement(this),2) + iscall(underlyingElement(this),2) } /** Gets a textual representation of this function call. */ @@ -477,7 +477,7 @@ class ConstructorDelegationInit extends ConstructorBaseInit, @ctordelegatinginit */ class ConstructorFieldInit extends ConstructorInit, @ctorfieldinit { /** Gets the field being initialized. */ - Field getTarget() { varbind(unresolveElement(this),unresolveElement(result)) } + Field getTarget() { varbind(underlyingElement(this),unresolveElement(result)) } /** * Gets the expression to which the field is initialized. @@ -536,7 +536,7 @@ class DestructorVirtualDestruction extends DestructorBaseDestruction, @dtorvirtu */ class DestructorFieldDestruction extends DestructorDestruction, @dtorfielddestruct { /** Gets the field being destructed. */ - Field getTarget() { varbind(unresolveElement(this),unresolveElement(result)) } + Field getTarget() { varbind(underlyingElement(this),unresolveElement(result)) } /** Gets the compiler-generated call to the variable's destructor. */ DestructorCall getExpr() { result = this.getChild(0) } diff --git a/cpp/ql/src/semmle/code/cpp/exprs/Cast.qll b/cpp/ql/src/semmle/code/cpp/exprs/Cast.qll index 8da41e5efd6..1c234c4950c 100644 --- a/cpp/ql/src/semmle/code/cpp/exprs/Cast.qll +++ b/cpp/ql/src/semmle/code/cpp/exprs/Cast.qll @@ -136,7 +136,7 @@ private predicate isPointerToMemberOrNullPointer(Type type) { */ class ArithmeticConversion extends Cast { ArithmeticConversion() { - conversionkinds(unresolveElement(this), 0) and + conversionkinds(underlyingElement(this), 0) and isArithmeticOrEnum(getType().getUnspecifiedType()) and isArithmeticOrEnum(getExpr().getType().getUnspecifiedType()) } @@ -210,7 +210,7 @@ class IntegralToFloatingPointConversion extends ArithmeticConversion { */ class PointerConversion extends Cast { PointerConversion() { - conversionkinds(unresolveElement(this), 0) and + conversionkinds(underlyingElement(this), 0) and isPointerOrNullPointer(getType().getUnspecifiedType()) and isPointerOrNullPointer(getExpr().getType().getUnspecifiedType()) } @@ -228,7 +228,7 @@ class PointerConversion extends Cast { */ class PointerToMemberConversion extends Cast { PointerToMemberConversion() { - conversionkinds(unresolveElement(this), 0) and + conversionkinds(underlyingElement(this), 0) and exists(Type fromType, Type toType | fromType = getExpr().getType().getUnspecifiedType() and toType = getType().getUnspecifiedType() and @@ -253,7 +253,7 @@ class PointerToMemberConversion extends Cast { */ class PointerToIntegralConversion extends Cast { PointerToIntegralConversion() { - conversionkinds(unresolveElement(this), 0) and + conversionkinds(underlyingElement(this), 0) and isIntegralOrEnum(getType().getUnspecifiedType()) and isPointerOrNullPointer(getExpr().getType().getUnspecifiedType()) } @@ -268,7 +268,7 @@ class PointerToIntegralConversion extends Cast { */ class IntegralToPointerConversion extends Cast { IntegralToPointerConversion() { - conversionkinds(unresolveElement(this), 0) and + conversionkinds(underlyingElement(this), 0) and isPointerOrNullPointer(getType().getUnspecifiedType()) and isIntegralOrEnum(getExpr().getType().getUnspecifiedType()) } @@ -284,7 +284,7 @@ class IntegralToPointerConversion extends Cast { */ class BoolConversion extends Cast { BoolConversion() { - conversionkinds(unresolveElement(this), 1) + conversionkinds(underlyingElement(this), 1) } override string getSemanticConversionString() { @@ -315,7 +315,7 @@ class VoidConversion extends Cast { */ class InheritanceConversion extends Cast { InheritanceConversion() { - conversionkinds(unresolveElement(this), 2) or conversionkinds(unresolveElement(this), 3) + conversionkinds(underlyingElement(this), 2) or conversionkinds(underlyingElement(this), 3) } /** @@ -367,7 +367,7 @@ private Class getConversionClass(Expr expr) { */ class BaseClassConversion extends InheritanceConversion { BaseClassConversion() { - conversionkinds(unresolveElement(this), 2) + conversionkinds(underlyingElement(this), 2) } override string getSemanticConversionString() { @@ -396,7 +396,7 @@ class BaseClassConversion extends InheritanceConversion { */ class DerivedClassConversion extends InheritanceConversion { DerivedClassConversion() { - conversionkinds(unresolveElement(this), 3) + conversionkinds(underlyingElement(this), 3) } override string getSemanticConversionString() { @@ -418,7 +418,7 @@ class DerivedClassConversion extends InheritanceConversion { */ class PointerToMemberBaseClassConversion extends Cast { PointerToMemberBaseClassConversion() { - conversionkinds(unresolveElement(this), 4) + conversionkinds(underlyingElement(this), 4) } override string getSemanticConversionString() { @@ -432,7 +432,7 @@ class PointerToMemberBaseClassConversion extends Cast { */ class PointerToMemberDerivedClassConversion extends Cast { PointerToMemberDerivedClassConversion() { - conversionkinds(unresolveElement(this), 5) + conversionkinds(underlyingElement(this), 5) } override string getSemanticConversionString() { @@ -447,7 +447,7 @@ class PointerToMemberDerivedClassConversion extends Cast { */ class GlvalueConversion extends Cast { GlvalueConversion() { - conversionkinds(unresolveElement(this), 6) + conversionkinds(underlyingElement(this), 6) } override string getSemanticConversionString() { @@ -471,7 +471,7 @@ class GlvalueConversion extends Cast { */ class PrvalueAdjustmentConversion extends Cast { PrvalueAdjustmentConversion() { - conversionkinds(unresolveElement(this), 7) + conversionkinds(underlyingElement(this), 7) } override string getSemanticConversionString() { @@ -503,7 +503,7 @@ class UuidofOperator extends Expr, @uuidof { /** Gets the contained type. */ Type getTypeOperand() { - uuidof_bind(unresolveElement(this), unresolveElement(result)) + uuidof_bind(underlyingElement(this), unresolveElement(result)) } } @@ -524,7 +524,7 @@ class TypeidOperator extends Expr, @type_id { * printf("the type of ptr is: %s\n", typeid(ptr).name); * ``` */ - Type getResultType() { typeid_bind(unresolveElement(this),unresolveElement(result)) } + Type getResultType() { typeid_bind(underlyingElement(this),unresolveElement(result)) } /** * DEPRECATED: Use `getResultType()` instead. @@ -605,10 +605,10 @@ class SizeofExprOperator extends SizeofOperator { * A C/C++ sizeof expression whose operand is a type name. */ class SizeofTypeOperator extends SizeofOperator { - SizeofTypeOperator() { sizeof_bind(unresolveElement(this),_) } + SizeofTypeOperator() { sizeof_bind(underlyingElement(this),_) } /** Gets the contained type. */ - Type getTypeOperand() { sizeof_bind(unresolveElement(this),unresolveElement(result)) } + Type getTypeOperand() { sizeof_bind(underlyingElement(this),unresolveElement(result)) } /** * DEPRECATED: Use `getTypeOperand()` instead @@ -657,10 +657,10 @@ class AlignofExprOperator extends AlignofOperator { * A C++11 `alignof` expression whose operand is a type name. */ class AlignofTypeOperator extends AlignofOperator { - AlignofTypeOperator() { sizeof_bind(unresolveElement(this),_) } + AlignofTypeOperator() { sizeof_bind(underlyingElement(this),_) } /** Gets the contained type. */ - Type getTypeOperand() { sizeof_bind(unresolveElement(this),unresolveElement(result)) } + Type getTypeOperand() { sizeof_bind(underlyingElement(this),unresolveElement(result)) } /** * DEPRECATED: Use `getTypeOperand()` instead. diff --git a/cpp/ql/src/semmle/code/cpp/exprs/Expr.qll b/cpp/ql/src/semmle/code/cpp/exprs/Expr.qll index fc101cd96b1..168e6f29fe8 100644 --- a/cpp/ql/src/semmle/code/cpp/exprs/Expr.qll +++ b/cpp/ql/src/semmle/code/cpp/exprs/Expr.qll @@ -8,7 +8,7 @@ private import semmle.code.cpp.internal.Type */ class Expr extends StmtParent, @expr { /** Gets the nth child of this expression. */ - Expr getChild(int n) { exprparents(unresolveElement(result),n,unresolveElement(this)) } + Expr getChild(int n) { exprparents(unresolveElement(result),n,underlyingElement(this)) } /** Gets the number of direct children of this expression. */ int getNumChild() { result = count(this.getAChild()) } @@ -38,14 +38,14 @@ class Expr extends StmtParent, @expr { Expr getAChild() { exists (int n | result = this.getChild(n)) } /** Gets the parent of this expression, if any. */ - Element getParent() { exprparents(unresolveElement(this),_,unresolveElement(result)) } + Element getParent() { exprparents(underlyingElement(this),_,unresolveElement(result)) } /** Gets the location of this expression. */ - override Location getLocation() { exprs(unresolveElement(this),_,result) } + override Location getLocation() { exprs(underlyingElement(this),_,result) } /** Holds if this is an auxiliary expression generated by the compiler. */ predicate isCompilerGenerated() { - compgenerated(unresolveElement(this)) or + compgenerated(underlyingElement(this)) or this.getParent().(ConstructorFieldInit).isCompilerGenerated() } @@ -55,7 +55,7 @@ class Expr extends StmtParent, @expr { * As the type of an expression can sometimes be a TypedefType, calling getUnderlyingType() * is often more useful than calling this predicate. */ - pragma[nomagic] Type getType() { expr_types(unresolveElement(this),unresolveElement(result),_) } + pragma[nomagic] Type getType() { expr_types(underlyingElement(this),unresolveElement(result),_) } /** * Gets the type of this expression after typedefs have been resolved. @@ -71,19 +71,19 @@ class Expr extends StmtParent, @expr { * * Consider using subclasses of `Expr` rather than relying on this predicate. */ - int getKind() { exprs(unresolveElement(this),result,_) } + int getKind() { exprs(underlyingElement(this),result,_) } /** Gets a textual representation of this expression. */ override string toString() { none() } /** Gets the value of this expression, if it is a constant. */ - string getValue() { exists(@value v | values(v,result,_) and valuebind(v,unresolveElement(this))) } + string getValue() { exists(@value v | values(v,result,_) and valuebind(v,underlyingElement(this))) } /** Gets the source text for the value of this expression, if it is a constant. */ - string getValueText() { exists(@value v | values(v,_,result) and valuebind(v,unresolveElement(this))) } + string getValueText() { exists(@value v | values(v,_,result) and valuebind(v,underlyingElement(this))) } /** Holds if this expression has a value that can be determined at compile time. */ - predicate isConstant() { valuebind(_,unresolveElement(this)) } + predicate isConstant() { valuebind(_,underlyingElement(this)) } /** * Holds if this expression is side-effect free (conservative @@ -124,7 +124,7 @@ class Expr extends StmtParent, @expr { * See [basic.lval] for more about lvalues. */ predicate isLValueCategory() { - expr_types(unresolveElement(this), _, 3) + expr_types(underlyingElement(this), _, 3) } /** @@ -134,7 +134,7 @@ class Expr extends StmtParent, @expr { * See [basic.lval] for more about xvalues. */ predicate isXValueCategory() { - expr_types(unresolveElement(this), _, 2) + expr_types(underlyingElement(this), _, 2) } /** @@ -143,7 +143,7 @@ class Expr extends StmtParent, @expr { * See [basic.lval] for more about prvalues. */ predicate isPRValueCategory() { - expr_types(unresolveElement(this), _, 1) + expr_types(underlyingElement(this), _, 1) } /** @@ -234,7 +234,7 @@ class Expr extends StmtParent, @expr { * See [conv.lval] for more about the lvalue-to-rvalue conversion */ predicate hasLValueToRValueConversion() { - expr_isload(unresolveElement(this)) + expr_isload(underlyingElement(this)) } /** @@ -303,14 +303,14 @@ class Expr extends StmtParent, @expr { * and 1 has a bool conversion, while the bool conversion itself has * an int conversion. */ - predicate hasConversion() { exists(Expr e | exprconv(unresolveElement(this),unresolveElement(e))) } + predicate hasConversion() { exists(Expr e | exprconv(underlyingElement(this),unresolveElement(e))) } /** * Holds if this expression has an implicit conversion. * * For example in `char *str = 0`, the `0` has an implicit conversion to type `char *`. */ - predicate hasImplicitConversion() { exists(Expr e | exprconv(unresolveElement(this),unresolveElement(e)) and e.(Cast).isImplicit()) } + predicate hasImplicitConversion() { exists(Expr e | exprconv(underlyingElement(this),unresolveElement(e)) and e.(Cast).isImplicit()) } /** * Holds if this expression has an explicit conversion. @@ -318,12 +318,12 @@ class Expr extends StmtParent, @expr { * For example in `(MyClass *)ptr`, the `ptr` has an explicit * conversion to type `MyClass *`. */ - predicate hasExplicitConversion() { exists(Expr e | exprconv(unresolveElement(this),unresolveElement(e)) and not e.(Cast).isImplicit()) } + predicate hasExplicitConversion() { exists(Expr e | exprconv(underlyingElement(this),unresolveElement(e)) and not e.(Cast).isImplicit()) } /** * Gets the conversion associated with this expression, if any. */ - Expr getConversion() { exprconv(unresolveElement(this),unresolveElement(result)) } + Expr getConversion() { exprconv(underlyingElement(this),unresolveElement(result)) } /** * Gets a string describing the conversion associated with this expression, @@ -594,14 +594,14 @@ class NewExpr extends Expr, @new_expr { * For example, for `new int` the result is `int`. */ Type getAllocatedType() { - new_allocated_type(unresolveElement(this), unresolveElement(result)) + new_allocated_type(underlyingElement(this), unresolveElement(result)) } /** * Gets the `operator new` that allocates storage. */ Function getAllocator() { - expr_allocator(unresolveElement(this), unresolveElement(result), _) + expr_allocator(underlyingElement(this), unresolveElement(result), _) } /** @@ -609,7 +609,7 @@ class NewExpr extends Expr, @new_expr { * argument of type `std::align_val_t`. */ predicate hasAlignedAllocation() { - expr_allocator(unresolveElement(this), _, 1) + expr_allocator(underlyingElement(this), _, 1) } /** @@ -629,7 +629,7 @@ class NewExpr extends Expr, @new_expr { * throws an exception, if any. */ Function getDeallocator() { - expr_deallocator(unresolveElement(this), unresolveElement(result), _) + expr_deallocator(underlyingElement(this), unresolveElement(result), _) } /** @@ -637,7 +637,7 @@ class NewExpr extends Expr, @new_expr { */ predicate hasSizedDeallocation() { exists(int form | - expr_deallocator(unresolveElement(this), _, form) and + expr_deallocator(underlyingElement(this), _, form) and form.bitAnd(1) != 0 // Bit zero is the "size" bit ) } @@ -647,7 +647,7 @@ class NewExpr extends Expr, @new_expr { */ predicate hasAlignedDeallocation() { exists(int form | - expr_deallocator(unresolveElement(this), _, form) and + expr_deallocator(underlyingElement(this), _, form) and form.bitAnd(2) != 0 // Bit one is the "alignment" bit ) } @@ -675,7 +675,7 @@ class NewArrayExpr extends Expr, @new_array_expr { * For example, for `new int[5]` the result is `int[5]`. */ Type getAllocatedType() { - new_array_allocated_type(unresolveElement(this), unresolveElement(result)) + new_array_allocated_type(underlyingElement(this), unresolveElement(result)) } /** @@ -689,7 +689,7 @@ class NewArrayExpr extends Expr, @new_array_expr { * Gets the `operator new[]` that allocates storage. */ Function getAllocator() { - expr_allocator(unresolveElement(this), unresolveElement(result), _) + expr_allocator(underlyingElement(this), unresolveElement(result), _) } /** @@ -697,7 +697,7 @@ class NewArrayExpr extends Expr, @new_array_expr { * argument of type `std::align_val_t`. */ predicate hasAlignedAllocation() { - expr_allocator(unresolveElement(this), _, 1) + expr_allocator(underlyingElement(this), _, 1) } /** @@ -712,7 +712,7 @@ class NewArrayExpr extends Expr, @new_array_expr { * throws an exception, if any. */ Function getDeallocator() { - expr_deallocator(unresolveElement(this), unresolveElement(result), _) + expr_deallocator(underlyingElement(this), unresolveElement(result), _) } /** @@ -720,7 +720,7 @@ class NewArrayExpr extends Expr, @new_array_expr { */ predicate hasSizedDeallocation() { exists(int form | - expr_deallocator(unresolveElement(this), _, form) and + expr_deallocator(underlyingElement(this), _, form) and form.bitAnd(1) != 0 // Bit zero is the "size" bit ) } @@ -730,7 +730,7 @@ class NewArrayExpr extends Expr, @new_array_expr { */ predicate hasAlignedDeallocation() { exists(int form | - expr_deallocator(unresolveElement(this), _, form) and + expr_deallocator(underlyingElement(this), _, form) and form.bitAnd(2) != 0 // Bit one is the "alignment" bit ) } @@ -788,7 +788,7 @@ class DeleteExpr extends Expr, @delete_expr { * dynamic type of the object. */ Function getDeallocator() { - expr_deallocator(unresolveElement(this), unresolveElement(result), _) + expr_deallocator(underlyingElement(this), unresolveElement(result), _) } /** @@ -796,7 +796,7 @@ class DeleteExpr extends Expr, @delete_expr { */ predicate hasSizedDeallocation() { exists(int form | - expr_deallocator(unresolveElement(this), _, form) and + expr_deallocator(underlyingElement(this), _, form) and form.bitAnd(1) != 0 // Bit zero is the "size" bit ) } @@ -806,7 +806,7 @@ class DeleteExpr extends Expr, @delete_expr { */ predicate hasAlignedDeallocation() { exists(int form | - expr_deallocator(unresolveElement(this), _, form) and + expr_deallocator(underlyingElement(this), _, form) and form.bitAnd(2) != 0 // Bit one is the "alignment" bit ) } @@ -856,7 +856,7 @@ class DeleteArrayExpr extends Expr, @delete_array_expr { * Gets the `operator delete[]` that deallocates storage. */ Function getDeallocator() { - expr_deallocator(unresolveElement(this), unresolveElement(result), _) + expr_deallocator(underlyingElement(this), unresolveElement(result), _) } /** @@ -864,7 +864,7 @@ class DeleteArrayExpr extends Expr, @delete_array_expr { */ predicate hasSizedDeallocation() { exists(int form | - expr_deallocator(unresolveElement(this), _, form) and + expr_deallocator(underlyingElement(this), _, form) and form.bitAnd(1) != 0 // Bit zero is the "size" bit ) } @@ -874,7 +874,7 @@ class DeleteArrayExpr extends Expr, @delete_array_expr { */ predicate hasAlignedDeallocation() { exists(int form | - expr_deallocator(unresolveElement(this), _, form) and + expr_deallocator(underlyingElement(this), _, form) and form.bitAnd(2) != 0 // Bit one is the "alignment" bit ) } @@ -944,7 +944,7 @@ class ThisExpr extends Expr, @thisaccess { */ class BlockExpr extends Literal { BlockExpr() { - code_block(unresolveElement(this), _) + code_block(underlyingElement(this), _) } override string toString() { result = "^ { ... }" } @@ -953,7 +953,7 @@ class BlockExpr extends Literal { * Gets the (anonymous) function associated with this code block expression. */ Function getFunction() { - code_block(unresolveElement(this), unresolveElement(result)) + code_block(underlyingElement(this), unresolveElement(result)) } } diff --git a/cpp/ql/src/semmle/code/cpp/exprs/Lambda.qll b/cpp/ql/src/semmle/code/cpp/exprs/Lambda.qll index a0521ed1bd5..c84c9eb8dfd 100644 --- a/cpp/ql/src/semmle/code/cpp/exprs/Lambda.qll +++ b/cpp/ql/src/semmle/code/cpp/exprs/Lambda.qll @@ -22,7 +22,7 @@ class LambdaExpression extends Expr, @lambdaexpr { * Gets the nth implicitly or explicitly captured value of this lambda expression. */ LambdaCapture getCapture(int index) { - lambda_capture(result, unresolveElement(this), index, _, _, _) + lambda_capture(result, underlyingElement(this), index, _, _, _) } /** @@ -34,14 +34,14 @@ class LambdaExpression extends Expr, @lambdaexpr { * - "=" if capture-by-value is the default for implicit captures. */ string getDefaultCaptureMode() { - lambdas(unresolveElement(this), result, _) + lambdas(underlyingElement(this), result, _) } /** * Holds if the return type (of the call operator of the resulting object) was explicitly specified. */ predicate returnTypeIsExplicit() { - lambdas(unresolveElement(this), _, true) + lambdas(underlyingElement(this), _, true) } /** diff --git a/cpp/ql/src/semmle/code/cpp/exprs/Literal.qll b/cpp/ql/src/semmle/code/cpp/exprs/Literal.qll index cca15b00c3a..800300052ef 100644 --- a/cpp/ql/src/semmle/code/cpp/exprs/Literal.qll +++ b/cpp/ql/src/semmle/code/cpp/exprs/Literal.qll @@ -36,12 +36,12 @@ class Literal extends Expr, @literal { */ class LabelLiteral extends Literal { LabelLiteral() { - jumpinfo(unresolveElement(this),_,_) + jumpinfo(underlyingElement(this),_,_) } /** Gets the corresponding label statement. */ LabelStmt getLabel() { - jumpinfo(unresolveElement(this),_,unresolveElement(result)) + jumpinfo(underlyingElement(this),_,unresolveElement(result)) } } diff --git a/cpp/ql/src/semmle/code/cpp/metrics/MetricFile.qll b/cpp/ql/src/semmle/code/cpp/metrics/MetricFile.qll index bc8e45ccbe2..b71eff4e0e9 100644 --- a/cpp/ql/src/semmle/code/cpp/metrics/MetricFile.qll +++ b/cpp/ql/src/semmle/code/cpp/metrics/MetricFile.qll @@ -22,17 +22,17 @@ class MetricFile extends File { /** Gets the number of lines in this file. */ int getNumberOfLines() { - numlines(unresolveElement(this),result,_,_) + numlines(underlyingElement(this),result,_,_) } /** Gets the number of lines of code in this file. */ int getNumberOfLinesOfCode() { - numlines(unresolveElement(this),_,result,_) + numlines(underlyingElement(this),_,result,_) } /** Gets the number of lines of comments in this file. */ int getNumberOfLinesOfComments() { - numlines(unresolveElement(this),_,_,result) + numlines(underlyingElement(this),_,_,result) } /** Gets the number of incoming file dependencies. */ diff --git a/cpp/ql/src/semmle/code/cpp/metrics/MetricFunction.qll b/cpp/ql/src/semmle/code/cpp/metrics/MetricFunction.qll index 19db5918a1b..3eafe0ab9ed 100644 --- a/cpp/ql/src/semmle/code/cpp/metrics/MetricFunction.qll +++ b/cpp/ql/src/semmle/code/cpp/metrics/MetricFunction.qll @@ -12,17 +12,17 @@ class MetricFunction extends Function { /** Gets the number of lines in this function. */ int getNumberOfLines() { - numlines(unresolveElement(this),result,_,_) + numlines(underlyingElement(this),result,_,_) } /** Gets the number of lines of code in this function. */ int getNumberOfLinesOfCode() { - numlines(unresolveElement(this),_,result,_) + numlines(underlyingElement(this),_,result,_) } /** Gets the number of lines of comments in this function. */ int getNumberOfLinesOfComments() { - numlines(unresolveElement(this),_,_,result) + numlines(underlyingElement(this),_,_,result) } /** Gets the ratio of lines of comments to total lines in this function (between 0.0 and 1.0). */ diff --git a/cpp/ql/src/semmle/code/cpp/pointsto/CallGraph.qll b/cpp/ql/src/semmle/code/cpp/pointsto/CallGraph.qll index 5f3d9d8a930..ac29f2dc881 100644 --- a/cpp/ql/src/semmle/code/cpp/pointsto/CallGraph.qll +++ b/cpp/ql/src/semmle/code/cpp/pointsto/CallGraph.qll @@ -23,7 +23,7 @@ class TargetPointsToExpr extends PointsToExpr { { exists(int cset, VirtualFunction static | this.interesting() and - parentSetFor(cset, unresolveElement(this)) and + parentSetFor(cset, underlyingElement(this)) and static = this.staticTarget() and childrenByElement(cset, static, result) ) diff --git a/cpp/ql/src/semmle/code/cpp/pointsto/PointsTo.qll b/cpp/ql/src/semmle/code/cpp/pointsto/PointsTo.qll index fe2106df2ce..bd4684cdfa4 100644 --- a/cpp/ql/src/semmle/code/cpp/pointsto/PointsTo.qll +++ b/cpp/ql/src/semmle/code/cpp/pointsto/PointsTo.qll @@ -633,7 +633,7 @@ class PointsToExpr extends Expr pragma[noopt] Element pointsTo() { - this.interesting() and exists(int set, @element thisEntity, @element resultEntity | thisEntity = unresolveElement(this) and pointstosets(set, thisEntity) and setlocations(set, resultEntity) and resultEntity = unresolveElement(result)) + this.interesting() and exists(int set, @element thisEntity, @element resultEntity | thisEntity = underlyingElement(this) and pointstosets(set, thisEntity) and setlocations(set, resultEntity) and resultEntity = unresolveElement(result)) } float confidence() { result = 1.0 / count(this.pointsTo()) } diff --git a/cpp/ql/src/semmle/code/cpp/stmts/Stmt.qll b/cpp/ql/src/semmle/code/cpp/stmts/Stmt.qll index 1f7243c9d77..46de2220e37 100644 --- a/cpp/ql/src/semmle/code/cpp/stmts/Stmt.qll +++ b/cpp/ql/src/semmle/code/cpp/stmts/Stmt.qll @@ -9,8 +9,8 @@ class Stmt extends StmtParent, @stmt { /** Gets the `n`th child of this statement. */ Element getChild(int n) { - stmtparents(unresolveElement(result),n,unresolveElement(this)) or - exprparents(unresolveElement(result),n,unresolveElement(this)) + stmtparents(unresolveElement(result),n,underlyingElement(this)) or + exprparents(unresolveElement(result),n,underlyingElement(this)) } /** Holds if `e` is the `n`th child of this statement. */ @@ -35,10 +35,10 @@ class Stmt extends StmtParent, @stmt { Element getAChild() { exists (int n | result = this.getChild(n)) } /** Gets the parent of this statement, if any. */ - StmtParent getParent() { stmtparents(unresolveElement(this),_,unresolveElement(result)) } + StmtParent getParent() { stmtparents(underlyingElement(this),_,unresolveElement(result)) } /** Gets the parent statement of this statement, if any. */ - Stmt getParentStmt() { stmtparents(unresolveElement(this),_,unresolveElement(result)) } + Stmt getParentStmt() { stmtparents(underlyingElement(this),_,unresolveElement(result)) } /** Gets a child statement of this statement. */ Stmt getChildStmt() { result.getParentStmt() = this } @@ -51,10 +51,10 @@ class Stmt extends StmtParent, @stmt { result = b.getStmt(i+1)) } - override Location getLocation() { stmts(unresolveElement(this),_,result) } + override Location getLocation() { stmts(underlyingElement(this),_,result) } /** Gets an int indicating the type of statement that this represents. */ - int getKind() { stmts(unresolveElement(this),result,_) } + int getKind() { stmts(underlyingElement(this),result,_) } override string toString() { none() } @@ -108,7 +108,7 @@ class Stmt extends StmtParent, @stmt { * `[[clang::fallthrough]]`. */ Attribute getAnAttribute() { - stmtattributes(unresolveElement(this), unresolveElement(result)) + stmtattributes(underlyingElement(this), unresolveElement(result)) } /** @@ -135,7 +135,7 @@ class Stmt extends StmtParent, @stmt { /** Holds if this statement was generated by the compiler. */ predicate isCompilerGenerated() { - compgenerated(unresolveElement(this)) + compgenerated(underlyingElement(this)) } } @@ -233,7 +233,7 @@ class IfStmt extends ConditionalStmt, @stmt_if { * ``` * the result is the `Block` `{ x = 1; }`. */ - Stmt getThen() { if_then(unresolveElement(this), unresolveElement(result)) } + Stmt getThen() { if_then(underlyingElement(this), unresolveElement(result)) } /** * Gets the 'else' statement of this 'if' statement, if any. @@ -248,7 +248,7 @@ class IfStmt extends ConditionalStmt, @stmt_if { * ``` * there is no result. */ - Stmt getElse() { if_else(unresolveElement(this), unresolveElement(result)) } + Stmt getElse() { if_else(underlyingElement(this), unresolveElement(result)) } /** * Holds if this 'if' statement has an 'else' statement. @@ -306,7 +306,7 @@ abstract class Loop extends ControlStructure { class WhileStmt extends Loop, @stmt_while { override Expr getCondition() { result = this.getChild(0) } override Expr getControllingExpr() { result = this.getCondition() } - override Stmt getStmt() { while_body(unresolveElement(this), unresolveElement(result)) } + override Stmt getStmt() { while_body(underlyingElement(this), unresolveElement(result)) } override string toString() { result = "while (...) ..." } @@ -371,7 +371,7 @@ class WhileStmt extends Loop, @stmt_while { abstract class JumpStmt extends Stmt, @jump { /** Gets the target of this jump statement. */ - Stmt getTarget() { jumpinfo(unresolveElement(this),_,unresolveElement(result)) } + Stmt getTarget() { jumpinfo(underlyingElement(this),_,unresolveElement(result)) } } /** @@ -393,10 +393,10 @@ class GotoStmt extends JumpStmt, @stmt_goto { * ``` * the result is `"someLabel"`. */ - string getName() { jumpinfo(unresolveElement(this),result,_) and result != "" } + string getName() { jumpinfo(underlyingElement(this),result,_) and result != "" } /** Holds if this 'goto' statement refers to a label. */ - predicate hasName() { exists(string s | jumpinfo(unresolveElement(this),s,_) and s != "") } + predicate hasName() { exists(string s | jumpinfo(underlyingElement(this),s,_) and s != "") } override string toString() { result = "goto ..." } @@ -534,7 +534,7 @@ private Stmt getEnclosingBreakable(Stmt s) { class LabelStmt extends Stmt, @stmt_label { /** Gets the name of this 'label' statement. */ - string getName() { jumpinfo(unresolveElement(this),result,_) and result != "" } + string getName() { jumpinfo(underlyingElement(this),result,_) and result != "" } /** Holds if this 'label' statement is named. */ predicate isNamed() { exists(this.getName()) } @@ -611,7 +611,7 @@ class DoStmt extends Loop, @stmt_end_test_while { override Expr getCondition() { result = this.getChild(0) } override Expr getControllingExpr() { result = this.getCondition() } - override Stmt getStmt() { do_body(unresolveElement(this), unresolveElement(result)) } + override Stmt getStmt() { do_body(underlyingElement(this), unresolveElement(result)) } override string toString() { result = "do (...) ..." } @@ -743,7 +743,7 @@ class ForStmt extends Loop, @stmt_for { * for (; i < 10; i++) { j++ } * ``` */ - Stmt getInitialization() { for_initialization(unresolveElement(this), unresolveElement(result)) } + Stmt getInitialization() { for_initialization(underlyingElement(this), unresolveElement(result)) } /** * Gets the condition expression of this 'for' statement. @@ -759,7 +759,7 @@ class ForStmt extends Loop, @stmt_for { * for (i = 0;; i++) { if (i >= 10) break; } * ``` */ - override Expr getCondition() { for_condition(unresolveElement(this), unresolveElement(result)) } + override Expr getCondition() { for_condition(underlyingElement(this), unresolveElement(result)) } override Expr getControllingExpr() { result = this.getCondition() } /** @@ -776,9 +776,9 @@ class ForStmt extends Loop, @stmt_for { * for (i = 0; i < 10;) { i++; } * ``` */ - Expr getUpdate() { for_update(unresolveElement(this), unresolveElement(result)) } + Expr getUpdate() { for_update(underlyingElement(this), unresolveElement(result)) } - override Stmt getStmt() { for_body(unresolveElement(this), unresolveElement(result)) } + override Stmt getStmt() { for_body(underlyingElement(this), unresolveElement(result)) } override string toString() { result = "for(...;...;...) ..." } @@ -1026,7 +1026,7 @@ class SwitchCase extends Stmt, @stmt_switch_case { * has result 2. */ int getChildNum() { - switch_case(_, result, unresolveElement(this)) + switch_case(_, result, underlyingElement(this)) } /** @@ -1360,7 +1360,7 @@ class SwitchStmt extends ConditionalStmt, @stmt_switch { * } * ``` */ - Stmt getStmt() { switch_body(unresolveElement(this), unresolveElement(result)) } + Stmt getStmt() { switch_body(underlyingElement(this), unresolveElement(result)) } /** * Gets a 'switch case' statement of this 'switch' statement. @@ -1377,7 +1377,7 @@ class SwitchStmt extends ConditionalStmt, @stmt_switch { * ``` * the results are `case 1:`, `case 2:` and `default:`. */ - SwitchCase getASwitchCase() { switch_case(unresolveElement(this), _, unresolveElement(result)) } + SwitchCase getASwitchCase() { switch_case(underlyingElement(this), _, unresolveElement(result)) } /** * Gets the 'default case' statement of this 'switch' statement, @@ -1662,7 +1662,7 @@ class FunctionTryStmt extends TryStmt { * A 'catch block', from either C++'s `catch` or Objective C's `@catch`. */ class CatchBlock extends Block { - CatchBlock() { ishandler(unresolveElement(this)) } + CatchBlock() { ishandler(underlyingElement(this)) } /** * Gets the parameter introduced by this 'catch block', if any. @@ -1752,7 +1752,7 @@ class DeclStmt extends Stmt, @stmt_decl { * the result of `getDeclarationEntry(0)` is `i`. */ DeclarationEntry getDeclarationEntry(int i) { - stmt_decl_entry_bind(unresolveElement(this), i, unresolveElement(result)) + stmt_decl_entry_bind(underlyingElement(this), i, unresolveElement(result)) } /** @@ -1788,7 +1788,7 @@ class DeclStmt extends Stmt, @stmt_decl { * ``` * the result of `getDeclaration(0)` is `i`. */ - Declaration getDeclaration(int i) { stmt_decl_bind(unresolveElement(this), i, unresolveElement(result)) } + Declaration getDeclaration(int i) { stmt_decl_bind(underlyingElement(this), i, unresolveElement(result)) } /** * Gets a declaration declared by this 'declaration' statement. @@ -1891,11 +1891,11 @@ class VlaDeclStmt extends Stmt, @stmt_vla_decl { * Gets the type that this VLA declaration statement relates to, * if any. */ - Type getType() { type_vla(unresolveElement(result), unresolveElement(this)) } + Type getType() { type_vla(unresolveElement(result), underlyingElement(this)) } /** * Gets the variable that this VLA declaration statement relates to, * if any. */ - Variable getVariable() { variable_vla(unresolveElement(result), unresolveElement(this)) } + Variable getVariable() { variable_vla(unresolveElement(result), underlyingElement(this)) } }