mirror of
https://github.com/github/codeql.git
synced 2025-12-23 04:06:37 +01:00
C++: fix implicit this
This commit is contained in:
committed by
Mathias Vorreiter Pedersen
parent
b2e4276bc8
commit
fe891746bf
@@ -68,12 +68,12 @@ class VariableDeclarationLine extends TVariableDeclarationInfo {
|
||||
/**
|
||||
* Gets the start column of the first `VariableDeclarationEntry` on this line.
|
||||
*/
|
||||
int getStartColumn() { result = min(getAVDE().getLocation().getStartColumn()) }
|
||||
int getStartColumn() { result = min(this.getAVDE().getLocation().getStartColumn()) }
|
||||
|
||||
/**
|
||||
* Gets the end column of the last `VariableDeclarationEntry` on this line.
|
||||
*/
|
||||
int getEndColumn() { result = max(getAVDE().getLocation().getEndColumn()) }
|
||||
int getEndColumn() { result = max(this.getAVDE().getLocation().getEndColumn()) }
|
||||
|
||||
/**
|
||||
* Gets the rank of this `VariableDeclarationLine` in its file and class
|
||||
@@ -89,14 +89,14 @@ class VariableDeclarationLine extends TVariableDeclarationInfo {
|
||||
*/
|
||||
VariableDeclarationLine getNext() {
|
||||
result = TVariableDeclarationLine(c, f, _) and
|
||||
result.getRank() = getRank() + 1
|
||||
result.getRank() = this.getRank() + 1
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the `VariableDeclarationLine` following this one, if it is nearby.
|
||||
*/
|
||||
VariableDeclarationLine getProximateNext() {
|
||||
result = getNext() and
|
||||
result = this.getNext() and
|
||||
result.getLine() <= this.getLine() + 3
|
||||
}
|
||||
|
||||
@@ -114,14 +114,14 @@ class VariableDeclarationGroup extends VariableDeclarationLine {
|
||||
// there is no `VariableDeclarationLine` within three lines previously
|
||||
not any(VariableDeclarationLine prev).getProximateNext() = this and
|
||||
// `end` is the last transitively proximate line
|
||||
end = getProximateNext*() and
|
||||
end = this.getProximateNext*() and
|
||||
not exists(end.getProximateNext())
|
||||
}
|
||||
|
||||
predicate hasLocationInfo(string path, int startline, int startcol, int endline, int endcol) {
|
||||
path = f.getAbsolutePath() and
|
||||
startline = getLine() and
|
||||
startcol = getStartColumn() and
|
||||
startline = this.getLine() and
|
||||
startcol = this.getStartColumn() and
|
||||
endline = end.getLine() and
|
||||
endcol = end.getEndColumn()
|
||||
}
|
||||
@@ -132,18 +132,18 @@ class VariableDeclarationGroup extends VariableDeclarationLine {
|
||||
int getCount() {
|
||||
result =
|
||||
count(VariableDeclarationLine l |
|
||||
l = getProximateNext*()
|
||||
l = this.getProximateNext*()
|
||||
|
|
||||
l.getAVDE().getVariable().getName()
|
||||
)
|
||||
}
|
||||
|
||||
override string toString() {
|
||||
getCount() = 1 and
|
||||
result = "declaration of " + getAVDE().getVariable().getName()
|
||||
this.getCount() = 1 and
|
||||
result = "declaration of " + this.getAVDE().getVariable().getName()
|
||||
or
|
||||
getCount() > 1 and
|
||||
result = "group of " + getCount() + " fields here"
|
||||
this.getCount() > 1 and
|
||||
result = "group of " + this.getCount() + " fields here"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user