mirror of
https://github.com/github/codeql.git
synced 2025-12-23 04:06:37 +01:00
C++: Introduce ElementBase class
By extending this class, a class can define its own `getLocation` predicate without participating in the dispatch hierarchy of `getLocation` as defined on `Element`. Classes wanting to override their location previously had to define `getURL` or `hasLocationInfo` instead and rely on these predicates not being defined on future versions of `Element`.
This commit is contained in:
@@ -46,8 +46,9 @@ predicate masterVde(VariableDeclarationEntry master, VariableDeclarationEntry vd
|
||||
exists(VariableDeclarationEntry previous | previousVde(previous, vde) and masterVde(master, previous))
|
||||
}
|
||||
|
||||
class VariableDeclarationGroup extends VariableDeclarationEntry {
|
||||
class VariableDeclarationGroup extends ElementBase {
|
||||
VariableDeclarationGroup() {
|
||||
this instanceof VariableDeclarationEntry and
|
||||
not previousVde(_, this)
|
||||
}
|
||||
Class getClass() {
|
||||
@@ -62,7 +63,7 @@ class VariableDeclarationGroup extends VariableDeclarationEntry {
|
||||
masterVde(this, last) and
|
||||
this instanceof VariableDeclarationGroup and
|
||||
not previousVde(last, _) and
|
||||
this.getLocation() = lstart and
|
||||
exists(VariableDeclarationEntry vde | vde=this and vde instanceof VariableDeclarationEntry and vde.getLocation() = lstart) and
|
||||
last.getLocation() = lend and
|
||||
lstart.hasLocationInfo(path, startline, startcol, _, _) and
|
||||
lend.hasLocationInfo(path, _, _, endline, endcol)
|
||||
@@ -78,7 +79,7 @@ class VariableDeclarationGroup extends VariableDeclarationEntry {
|
||||
name = vde.getName()))
|
||||
+ " fields here"
|
||||
else
|
||||
result = "declaration of " + this.getVariable().getName()
|
||||
result = "declaration of " + this.(VariableDeclarationEntry).getVariable().getName()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user