Skip to content

Commit 6ff8d4d

Browse files
committed
add all remaining explicit this
1 parent 00ee34c commit 6ff8d4d

File tree

104 files changed

+479
-451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+479
-451
lines changed

cpp/ql/lib/semmle/code/cpp/controlflow/internal/ConstantExprs.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,9 @@ library class ExprEvaluator extends int {
626626
// All assignments must have the same int value
627627
result =
628628
unique(Expr value |
629-
value = v.getAnAssignedValue() and not ignoreVariableAssignment(e, v, value)
629+
value = v.getAnAssignedValue() and not this.ignoreVariableAssignment(e, v, value)
630630
|
631-
getValueInternalNonSubExpr(value)
631+
this.getValueInternalNonSubExpr(value)
632632
)
633633
)
634634
}

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ class SsaPhiNode extends Node, TSsaPhiNode {
452452

453453
/** Holds if this phi node has input from the `rnk`'th write operation in block `block`. */
454454
final predicate hasInputAtRankInBlock(IRBlock block, int rnk) {
455-
hasInputAtRankInBlock(block, rnk, _)
455+
this.hasInputAtRankInBlock(block, rnk, _)
456456
}
457457

458458
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe
307307
final override string toString() { result = tag.toString() }
308308

309309
final override Instruction getAnyDef() {
310-
result = unique(Instruction defInstr | hasDefinition(defInstr, _))
310+
result = unique(Instruction defInstr | this.hasDefinition(defInstr, _))
311311
}
312312

313313
final override Overlap getDefinitionOverlap() { this.hasDefinition(_, result) }

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Operand.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe
307307
final override string toString() { result = tag.toString() }
308308

309309
final override Instruction getAnyDef() {
310-
result = unique(Instruction defInstr | hasDefinition(defInstr, _))
310+
result = unique(Instruction defInstr | this.hasDefinition(defInstr, _))
311311
}
312312

313313
final override Overlap getDefinitionOverlap() { this.hasDefinition(_, result) }

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe
307307
final override string toString() { result = tag.toString() }
308308

309309
final override Instruction getAnyDef() {
310-
result = unique(Instruction defInstr | hasDefinition(defInstr, _))
310+
result = unique(Instruction defInstr | this.hasDefinition(defInstr, _))
311311
}
312312

313313
final override Overlap getDefinitionOverlap() { this.hasDefinition(_, result) }

cpp/ql/src/AlertSuppression.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class SuppressionComment extends Comment {
1818
(
1919
this instanceof CppStyleComment and
2020
// strip the beginning slashes
21-
text = getContents().suffix(2)
21+
text = this.getContents().suffix(2)
2222
or
2323
this instanceof CStyleComment and
2424
// strip both the beginning /* and the end */ the comment
2525
exists(string text0 |
26-
text0 = getContents().suffix(2) and
26+
text0 = this.getContents().suffix(2) and
2727
text = text0.prefix(text0.length() - 2)
2828
) and
2929
// The /* */ comment must be a single-line comment

cpp/ql/src/Architecture/Refactoring Opportunities/ClassesWithManyFields.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ class ExtClass extends Class {
153153
}
154154

155155
predicate hasLocationInfo(string path, int startline, int startcol, int endline, int endcol) {
156-
if hasOneVariableGroup()
156+
if this.hasOneVariableGroup()
157157
then
158158
exists(VariableDeclarationGroup vdg | vdg.getClass() = this |
159159
vdg.hasLocationInfo(path, startline, startcol, endline, endcol)
160160
)
161-
else getLocation().hasLocationInfo(path, startline, startcol, endline, endcol)
161+
else this.getLocation().hasLocationInfo(path, startline, startcol, endline, endcol)
162162
}
163163
}
164164

cpp/ql/src/Critical/OverflowStatic.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ class CallWithBufferSize extends FunctionCall {
103103
// `upperBound(e)` defaults to `exprMaxVal(e)` when `e` isn't analyzable. So to get a meaningful
104104
// result in this case we pick the minimum value obtainable from dataflow and range analysis.
105105
result =
106-
upperBound(statedSizeExpr())
106+
upperBound(this.statedSizeExpr())
107107
.minimum(min(Expr statedSizeSrc |
108-
DataFlow::localExprFlow(statedSizeSrc, statedSizeExpr())
108+
DataFlow::localExprFlow(statedSizeSrc, this.statedSizeExpr())
109109
|
110110
statedSizeSrc.getValue().toInt()
111111
))

cpp/ql/src/JPL_C/LOC-2/Rule 09/Semaphores.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class LockOperation extends FunctionCall {
2222
ControlFlowNode getAReachedNode() {
2323
result = this
2424
or
25-
exists(ControlFlowNode mid | mid = getAReachedNode() |
25+
exists(ControlFlowNode mid | mid = this.getAReachedNode() |
2626
not mid != this.getMatchingUnlock() and
2727
result = mid.getASuccessor()
2828
)

cpp/ql/src/Likely Bugs/Leap Year/LeapYear.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ abstract class LeapYearFieldAccess extends YearFieldAccess {
156156
//
157157
// https://aa.usno.navy.mil/faq/docs/calendars.php
158158
this.isUsedInMod4Operation() and
159-
additionalModulusCheckForLeapYear(400) and
160-
additionalModulusCheckForLeapYear(100)
159+
this.additionalModulusCheckForLeapYear(400) and
160+
this.additionalModulusCheckForLeapYear(100)
161161
}
162162
}
163163

@@ -176,17 +176,17 @@ class StructTmLeapYearFieldAccess extends LeapYearFieldAccess {
176176

177177
override predicate isUsedInCorrectLeapYearCheck() {
178178
this.isUsedInMod4Operation() and
179-
additionalModulusCheckForLeapYear(400) and
180-
additionalModulusCheckForLeapYear(100) and
179+
this.additionalModulusCheckForLeapYear(400) and
180+
this.additionalModulusCheckForLeapYear(100) and
181181
// tm_year represents years since 1900
182182
(
183-
additionalAdditionOrSubstractionCheckForLeapYear(1900)
183+
this.additionalAdditionOrSubstractionCheckForLeapYear(1900)
184184
or
185185
// some systems may use 2000 for 2-digit year conversions
186-
additionalAdditionOrSubstractionCheckForLeapYear(2000)
186+
this.additionalAdditionOrSubstractionCheckForLeapYear(2000)
187187
or
188188
// converting from/to Unix epoch
189-
additionalAdditionOrSubstractionCheckForLeapYear(1970)
189+
this.additionalAdditionOrSubstractionCheckForLeapYear(1970)
190190
)
191191
}
192192
}

cpp/ql/src/Likely Bugs/Memory Management/AllocaInLoop.ql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,23 @@ class LoopWithAlloca extends Stmt {
5757
or
5858
// `e == 0`
5959
exists(EQExpr eq |
60-
conditionRequires(eq, truth.booleanNot()) and
60+
this.conditionRequires(eq, truth.booleanNot()) and
6161
eq.getAnOperand().getValue().toInt() = 0 and
6262
e = eq.getAnOperand() and
6363
not exists(e.getValue())
6464
)
6565
or
6666
// `e != 0`
6767
exists(NEExpr eq |
68-
conditionRequires(eq, truth) and
68+
this.conditionRequires(eq, truth) and
6969
eq.getAnOperand().getValue().toInt() = 0 and
7070
e = eq.getAnOperand() and
7171
not exists(e.getValue())
7272
)
7373
or
7474
// `(bool)e == true`
7575
exists(EQExpr eq |
76-
conditionRequires(eq, truth) and
76+
this.conditionRequires(eq, truth) and
7777
eq.getAnOperand().getValue().toInt() = 1 and
7878
e = eq.getAnOperand() and
7979
e.getUnspecifiedType() instanceof BoolType and
@@ -82,31 +82,31 @@ class LoopWithAlloca extends Stmt {
8282
or
8383
// `(bool)e != true`
8484
exists(NEExpr eq |
85-
conditionRequires(eq, truth.booleanNot()) and
85+
this.conditionRequires(eq, truth.booleanNot()) and
8686
eq.getAnOperand().getValue().toInt() = 1 and
8787
e = eq.getAnOperand() and
8888
e.getUnspecifiedType() instanceof BoolType and
8989
not exists(e.getValue())
9090
)
9191
or
9292
exists(NotExpr notExpr |
93-
conditionRequires(notExpr, truth.booleanNot()) and
93+
this.conditionRequires(notExpr, truth.booleanNot()) and
9494
e = notExpr.getOperand()
9595
)
9696
or
9797
// If the e of `this` requires `andExpr` to be true, then it
9898
// requires both of its operand to be true as well.
9999
exists(LogicalAndExpr andExpr |
100100
truth = true and
101-
conditionRequires(andExpr, truth) and
101+
this.conditionRequires(andExpr, truth) and
102102
e = andExpr.getAnOperand()
103103
)
104104
or
105105
// Dually, if the e of `this` requires `orExpr` to be false, then
106106
// it requires both of its operand to be false as well.
107107
exists(LogicalOrExpr orExpr |
108108
truth = false and
109-
conditionRequires(orExpr, truth) and
109+
this.conditionRequires(orExpr, truth) and
110110
e = orExpr.getAnOperand()
111111
)
112112
}
@@ -141,9 +141,9 @@ class LoopWithAlloca extends Stmt {
141141
* `conditionRequiresInequality`.
142142
*/
143143
private Variable getAControllingVariable() {
144-
conditionRequires(result.getAnAccess(), _)
144+
this.conditionRequires(result.getAnAccess(), _)
145145
or
146-
conditionRequiresInequality(result.getAnAccess(), _, _)
146+
this.conditionRequiresInequality(result.getAnAccess(), _, _)
147147
}
148148

149149
/**

cpp/ql/src/Likely Bugs/Memory Management/NtohlArrayNoBound.qll

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,72 +61,72 @@ class PointerArithmeticAccess extends BufferAccess, Expr {
6161
* A pair of buffer accesses through a call to memcpy.
6262
*/
6363
class MemCpy extends BufferAccess, FunctionCall {
64-
MemCpy() { getTarget().hasName("memcpy") }
64+
MemCpy() { this.getTarget().hasName("memcpy") }
6565

6666
override Expr getPointer() {
67-
result = getArgument(0) or
68-
result = getArgument(1)
67+
result = this.getArgument(0) or
68+
result = this.getArgument(1)
6969
}
7070

71-
override Expr getAccessedLength() { result = getArgument(2) }
71+
override Expr getAccessedLength() { result = this.getArgument(2) }
7272
}
7373

7474
class StrncpySizeExpr extends BufferAccess, FunctionCall {
75-
StrncpySizeExpr() { getTarget().hasName("strncpy") }
75+
StrncpySizeExpr() { this.getTarget().hasName("strncpy") }
7676

7777
override Expr getPointer() {
78-
result = getArgument(0) or
79-
result = getArgument(1)
78+
result = this.getArgument(0) or
79+
result = this.getArgument(1)
8080
}
8181

82-
override Expr getAccessedLength() { result = getArgument(2) }
82+
override Expr getAccessedLength() { result = this.getArgument(2) }
8383
}
8484

8585
class RecvSizeExpr extends BufferAccess, FunctionCall {
86-
RecvSizeExpr() { getTarget().hasName("recv") }
86+
RecvSizeExpr() { this.getTarget().hasName("recv") }
8787

88-
override Expr getPointer() { result = getArgument(1) }
88+
override Expr getPointer() { result = this.getArgument(1) }
8989

90-
override Expr getAccessedLength() { result = getArgument(2) }
90+
override Expr getAccessedLength() { result = this.getArgument(2) }
9191
}
9292

9393
class SendSizeExpr extends BufferAccess, FunctionCall {
94-
SendSizeExpr() { getTarget().hasName("send") }
94+
SendSizeExpr() { this.getTarget().hasName("send") }
9595

96-
override Expr getPointer() { result = getArgument(1) }
96+
override Expr getPointer() { result = this.getArgument(1) }
9797

98-
override Expr getAccessedLength() { result = getArgument(2) }
98+
override Expr getAccessedLength() { result = this.getArgument(2) }
9999
}
100100

101101
class SnprintfSizeExpr extends BufferAccess, FunctionCall {
102-
SnprintfSizeExpr() { getTarget().hasName("snprintf") }
102+
SnprintfSizeExpr() { this.getTarget().hasName("snprintf") }
103103

104-
override Expr getPointer() { result = getArgument(0) }
104+
override Expr getPointer() { result = this.getArgument(0) }
105105

106-
override Expr getAccessedLength() { result = getArgument(1) }
106+
override Expr getAccessedLength() { result = this.getArgument(1) }
107107
}
108108

109109
class MemcmpSizeExpr extends BufferAccess, FunctionCall {
110-
MemcmpSizeExpr() { getTarget().hasName("Memcmp") }
110+
MemcmpSizeExpr() { this.getTarget().hasName("Memcmp") }
111111

112112
override Expr getPointer() {
113-
result = getArgument(0) or
114-
result = getArgument(1)
113+
result = this.getArgument(0) or
114+
result = this.getArgument(1)
115115
}
116116

117-
override Expr getAccessedLength() { result = getArgument(2) }
117+
override Expr getAccessedLength() { result = this.getArgument(2) }
118118
}
119119

120120
class MallocSizeExpr extends BufferAccess, FunctionCall {
121-
MallocSizeExpr() { getTarget().hasName("malloc") }
121+
MallocSizeExpr() { this.getTarget().hasName("malloc") }
122122

123123
override Expr getPointer() { none() }
124124

125-
override Expr getAccessedLength() { result = getArgument(0) }
125+
override Expr getAccessedLength() { result = this.getArgument(0) }
126126
}
127127

128128
class NetworkFunctionCall extends FunctionCall {
129-
NetworkFunctionCall() { getTarget().hasName(["ntohd", "ntohf", "ntohl", "ntohll", "ntohs"]) }
129+
NetworkFunctionCall() { this.getTarget().hasName(["ntohd", "ntohf", "ntohl", "ntohll", "ntohs"]) }
130130
}
131131

132132
class NetworkToBufferSizeConfiguration extends DataFlow::Configuration {

cpp/ql/src/Power of 10/Rule 4/FunctionTooLong.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import cpp
1313

1414
class MacroFunctionCall extends MacroInvocation {
1515
MacroFunctionCall() {
16-
not exists(getParentInvocation()) and
16+
not exists(this.getParentInvocation()) and
1717
this.getMacro().getHead().matches("%(%")
1818
}
1919

cpp/ql/src/Power of 10/Rule 5/AssertionDensity.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import semmle.code.cpp.commons.Assertions
1313

1414
class MacroFunctionCall extends MacroInvocation {
1515
MacroFunctionCall() {
16-
not exists(getParentInvocation()) and
16+
not exists(this.getParentInvocation()) and
1717
this.getMacro().getHead().matches("%(%")
1818
}
1919

cpp/ql/src/Security/CWE/CWE-020/ExternalAPIsSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ExternalAPIDataNode extends DataFlow::Node {
3838
int getIndex() { result = i }
3939

4040
/** Gets the description of the function being called. */
41-
string getFunctionDescription() { result = getExternalFunction().toString() }
41+
string getFunctionDescription() { result = this.getExternalFunction().toString() }
4242
}
4343

4444
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalAPIDataNode`s. */

cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIsSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ExternalAPIDataNode extends DataFlow::Node {
3838
int getIndex() { result = i }
3939

4040
/** Gets the description of the function being called. */
41-
string getFunctionDescription() { result = getExternalFunction().toString() }
41+
string getFunctionDescription() { result = this.getExternalFunction().toString() }
4242
}
4343

4444
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalAPIDataNode`s. */

cpp/ql/src/Security/CWE/CWE-121/UnterminatedVarargsCall.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class VarargsFunction extends Function {
4242
}
4343

4444
private int trailingArgValueCount(string value) {
45-
result = strictcount(FunctionCall fc | trailingArgValue(fc) = value)
45+
result = strictcount(FunctionCall fc | this.trailingArgValue(fc) = value)
4646
}
4747

4848
string nonTrailingVarArgValue(FunctionCall fc, int index) {
@@ -58,11 +58,11 @@ class VarargsFunction extends Function {
5858

5959
string normalTerminator(int cnt) {
6060
result = ["0", "-1"] and
61-
cnt = trailingArgValueCount(result) and
62-
2 * cnt > totalCount() and
61+
cnt = this.trailingArgValueCount(result) and
62+
2 * cnt > this.totalCount() and
6363
not exists(FunctionCall fc, int index |
6464
// terminator value is used in a non-terminating position
65-
nonTrailingVarArgValue(fc, index) = result
65+
this.nonTrailingVarArgValue(fc, index) = result
6666
)
6767
}
6868

0 commit comments

Comments
 (0)