mirror of
https://github.com/github/codeql.git
synced 2025-12-17 09:13:20 +01:00
C++: Use underlyingElement for QualifiedName calls
Since the types in `QualifiedName.qll` are raw db types, callers need to use `underlyingElement` and `unresolveElement` as appropriate. This has no effect right now but will be needed when we switch the AST type hierarchy to `newtype`s.
This commit is contained in:
@@ -31,7 +31,7 @@ abstract class Declaration extends Locatable, @declaration {
|
||||
* namespace of the structure.
|
||||
*/
|
||||
Namespace getNamespace() {
|
||||
result = this.(Q::Declaration).getNamespace()
|
||||
result = underlyingElement(this).(Q::Declaration).getNamespace()
|
||||
or
|
||||
exists (Parameter p
|
||||
| p = this and result = p.getFunction().getNamespace())
|
||||
@@ -53,7 +53,7 @@ abstract class Declaration extends Locatable, @declaration {
|
||||
* "namespace1::namespace2::TemplateClass1<int>::Class2::memberName"`.
|
||||
*/
|
||||
string getQualifiedName() {
|
||||
result = this.(Q::Declaration).getQualifiedName()
|
||||
result = underlyingElement(this).(Q::Declaration).getQualifiedName()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,8 @@ abstract class Declaration extends Locatable, @declaration {
|
||||
* `hasQualifiedName("std", "vector", "size")`.
|
||||
*/
|
||||
predicate hasQualifiedName(string namespaceQualifier, string typeQualifier, string baseName) {
|
||||
this.(Q::Declaration).hasQualifiedName(namespaceQualifier, typeQualifier, baseName)
|
||||
underlyingElement(this).(Q::Declaration)
|
||||
.hasQualifiedName(namespaceQualifier, typeQualifier, baseName)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +116,7 @@ abstract class Declaration extends Locatable, @declaration {
|
||||
* To test whether this declaration has a particular name in the global
|
||||
* namespace, use `hasGlobalName`.
|
||||
*/
|
||||
string getName() { result = this.(Q::Declaration).getName() }
|
||||
string getName() { result = underlyingElement(this).(Q::Declaration).getName() }
|
||||
|
||||
/** Holds if this declaration has the given name. */
|
||||
predicate hasName(string name) { name = this.getName() }
|
||||
|
||||
@@ -55,7 +55,9 @@ class Parameter extends LocalScopeVariable, @parameter {
|
||||
* In other words, this predicate holds precisely when the result of
|
||||
* `getName()` is not "p#i" (where `i` is the index of the parameter).
|
||||
*/
|
||||
predicate isNamed() { exists(this.(Q::Parameter).getANamedDeclarationEntry()) }
|
||||
predicate isNamed() {
|
||||
exists(underlyingElement(this).(Q::Parameter).getANamedDeclarationEntry())
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function to which this parameter belongs, if it is a function
|
||||
@@ -96,12 +98,12 @@ class Parameter extends LocalScopeVariable, @parameter {
|
||||
*/
|
||||
override Location getLocation() {
|
||||
exists(VariableDeclarationEntry vde |
|
||||
vde = this.(Q::Parameter).getAnEffectiveDeclarationEntry() and
|
||||
vde = underlyingElement(this).(Q::Parameter).getAnEffectiveDeclarationEntry() and
|
||||
result = vde.getLocation()
|
||||
|
|
||||
vde.isDefinition()
|
||||
or
|
||||
not this.(Q::Parameter).getAnEffectiveDeclarationEntry().isDefinition()
|
||||
not underlyingElement(this).(Q::Parameter).getAnEffectiveDeclarationEntry().isDefinition()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user