Skip to content

Commit 5e2883f

Browse files
committed
add explicit this
1 parent d1747c0 commit 5e2883f

File tree

17 files changed

+134
-110
lines changed

17 files changed

+134
-110
lines changed

cpp/ql/lib/semmle/code/cpp/commons/Printf.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ class FormatLiteral extends Literal {
10601060
* conversion specifier of this format string; has no result if this cannot
10611061
* be determined.
10621062
*/
1063-
int getMaxConvertedLength(int n) { result = max(getMaxConvertedLength(n, _)) }
1063+
int getMaxConvertedLength(int n) { result = max(this.getMaxConvertedLength(n, _)) }
10641064

10651065
/**
10661066
* Gets the maximum length of the string that can be produced by the nth
@@ -1280,7 +1280,7 @@ class FormatLiteral extends Literal {
12801280
* determining whether a buffer overflow is caused by long float to string
12811281
* conversions.
12821282
*/
1283-
int getMaxConvertedLengthLimited(int n) { result = max(getMaxConvertedLengthLimited(n, _)) }
1283+
int getMaxConvertedLengthLimited(int n) { result = max(this.getMaxConvertedLengthLimited(n, _)) }
12841284

12851285
/**
12861286
* Gets the maximum length of the string that can be produced by the nth

cpp/ql/lib/semmle/code/cpp/security/BufferWrite.qll

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ abstract class BufferWrite extends Expr {
7676
* can be found), specifying the reason for the estimation.
7777
*/
7878
int getMaxData(BufferWriteEstimationReason reason) {
79-
reason instanceof NoSpecifiedEstimateReason and result = getMaxData()
79+
reason instanceof NoSpecifiedEstimateReason and result = this.getMaxData()
8080
}
8181

8282
/**
@@ -85,7 +85,7 @@ abstract class BufferWrite extends Expr {
8585
* much smaller (8 bytes) than their true maximum length. This can be
8686
* helpful in determining the cause of a buffer overflow issue.
8787
*/
88-
int getMaxDataLimited() { result = getMaxData() }
88+
int getMaxDataLimited() { result = this.getMaxData() }
8989

9090
/**
9191
* Gets an upper bound to the amount of data that's being written (if one
@@ -94,7 +94,7 @@ abstract class BufferWrite extends Expr {
9494
* than their true maximum length. This can be helpful in determining the
9595
* cause of a buffer overflow issue.
9696
*/
97-
int getMaxDataLimited(BufferWriteEstimationReason reason) { result = getMaxData(reason) }
97+
int getMaxDataLimited(BufferWriteEstimationReason reason) { result = this.getMaxData(reason) }
9898

9999
/**
100100
* Gets the size of a single character of the type this
@@ -159,9 +159,11 @@ class StrCopyBW extends BufferWriteCall {
159159
this.getArgument(this.getParamSrc()).(AnalysedString).getMaxLength() * this.getCharSize()
160160
}
161161

162-
override int getMaxData(BufferWriteEstimationReason reason) { result = getMaxDataImpl(reason) }
162+
override int getMaxData(BufferWriteEstimationReason reason) {
163+
result = this.getMaxDataImpl(reason)
164+
}
163165

164-
override int getMaxData() { result = max(getMaxDataImpl(_)) }
166+
override int getMaxData() { result = max(this.getMaxDataImpl(_)) }
165167
}
166168

167169
/**
@@ -203,9 +205,11 @@ class StrCatBW extends BufferWriteCall {
203205
this.getArgument(this.getParamSrc()).(AnalysedString).getMaxLength() * this.getCharSize()
204206
}
205207

206-
override int getMaxData(BufferWriteEstimationReason reason) { result = getMaxDataImpl(reason) }
208+
override int getMaxData(BufferWriteEstimationReason reason) {
209+
result = this.getMaxDataImpl(reason)
210+
}
207211

208-
override int getMaxData() { result = max(getMaxDataImpl(_)) }
212+
override int getMaxData() { result = max(this.getMaxDataImpl(_)) }
209213
}
210214

211215
/**
@@ -269,9 +273,11 @@ class SprintfBW extends BufferWriteCall {
269273
)
270274
}
271275

272-
override int getMaxData(BufferWriteEstimationReason reason) { result = getMaxDataImpl(reason) }
276+
override int getMaxData(BufferWriteEstimationReason reason) {
277+
result = this.getMaxDataImpl(reason)
278+
}
273279

274-
override int getMaxData() { result = max(getMaxDataImpl(_)) }
280+
override int getMaxData() { result = max(this.getMaxDataImpl(_)) }
275281

276282
private int getMaxDataLimitedImpl(BufferWriteEstimationReason reason) {
277283
exists(FormatLiteral fl |
@@ -281,10 +287,10 @@ class SprintfBW extends BufferWriteCall {
281287
}
282288

283289
override int getMaxDataLimited(BufferWriteEstimationReason reason) {
284-
result = getMaxDataLimitedImpl(reason)
290+
result = this.getMaxDataLimitedImpl(reason)
285291
}
286292

287-
override int getMaxDataLimited() { result = max(getMaxDataLimitedImpl(_)) }
293+
override int getMaxDataLimited() { result = max(this.getMaxDataLimitedImpl(_)) }
288294
}
289295

290296
/**
@@ -382,9 +388,11 @@ class SnprintfBW extends BufferWriteCall {
382388
)
383389
}
384390

385-
override int getMaxData(BufferWriteEstimationReason reason) { result = getMaxDataImpl(reason) }
391+
override int getMaxData(BufferWriteEstimationReason reason) {
392+
result = this.getMaxDataImpl(reason)
393+
}
386394

387-
override int getMaxData() { result = max(getMaxDataImpl(_)) }
395+
override int getMaxData() { result = max(this.getMaxDataImpl(_)) }
388396

389397
private int getMaxDataLimitedImpl(BufferWriteEstimationReason reason) {
390398
exists(FormatLiteral fl |
@@ -394,10 +402,10 @@ class SnprintfBW extends BufferWriteCall {
394402
}
395403

396404
override int getMaxDataLimited(BufferWriteEstimationReason reason) {
397-
result = getMaxDataLimitedImpl(reason)
405+
result = this.getMaxDataLimitedImpl(reason)
398406
}
399407

400-
override int getMaxDataLimited() { result = max(getMaxDataLimitedImpl(_)) }
408+
override int getMaxDataLimited() { result = max(this.getMaxDataLimitedImpl(_)) }
401409
}
402410

403411
/**
@@ -495,9 +503,11 @@ class ScanfBW extends BufferWrite {
495503
)
496504
}
497505

498-
override int getMaxData(BufferWriteEstimationReason reason) { result = getMaxDataImpl(reason) }
506+
override int getMaxData(BufferWriteEstimationReason reason) {
507+
result = this.getMaxDataImpl(reason)
508+
}
499509

500-
override int getMaxData() { result = max(getMaxDataImpl(_)) }
510+
override int getMaxData() { result = max(this.getMaxDataImpl(_)) }
501511

502512
override string getBWDesc() {
503513
exists(FunctionCall fc |
@@ -536,7 +546,9 @@ class RealpathBW extends BufferWriteCall {
536546
this = this // Suppress a compiler warning
537547
}
538548

539-
override int getMaxData(BufferWriteEstimationReason reason) { result = getMaxDataImpl(reason) }
549+
override int getMaxData(BufferWriteEstimationReason reason) {
550+
result = this.getMaxDataImpl(reason)
551+
}
540552

541-
override int getMaxData() { result = max(getMaxDataImpl(_)) }
553+
override int getMaxData() { result = max(this.getMaxDataImpl(_)) }
542554
}

csharp/ql/test/shared/FlowSummaries.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ abstract class IncludeSummarizedCallable extends RelevantSummarizedCallable {
3838
this.getDeclaringType().hasQualifiedName(namespace, type) and
3939
result =
4040
namespace + ";" + type + ";" + this.getCallableOverride() + ";" + this.getName() + ";" + "("
41-
+ parameterQualifiedTypeNamesToString() + ")"
41+
+ this.parameterQualifiedTypeNamesToString() + ")"
4242
)
4343
}
4444
}

java/ql/lib/semmle/code/java/security/CommandArguments.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private class CommandArgArrayImmutableFirst extends CommandArgumentArray {
153153
Expr getFirstElement() {
154154
result = this.getAWrite(0)
155155
or
156-
not exists(getAWrite(0)) and
156+
not exists(this.getAWrite(0)) and
157157
result = firstElementOf(this.getDefiningExpr())
158158
}
159159

java/ql/src/semmle/code/xml/MyBatisMapperXML.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,5 @@ class MyBatisMapperInclude extends MyBatisMapperXMLElement {
112112
* A `<foreach>` element in a `MyBatisMapperXMLElement`.
113113
*/
114114
class MyBatisMapperForeach extends MyBatisMapperXMLElement {
115-
MyBatisMapperForeach() { getName() = "foreach" }
115+
MyBatisMapperForeach() { this.getName() = "foreach" }
116116
}

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ module API {
998998
* Gets an API node where a RHS of the node is the `i`th argument to this call.
999999
*/
10001000
pragma[noinline]
1001-
private Node getAParameterCandidate(int i) { result.getARhs() = getArgument(i) }
1001+
private Node getAParameterCandidate(int i) { result.getARhs() = this.getArgument(i) }
10021002

10031003
/** Gets the API node for a parameter of this invocation. */
10041004
Node getAParameter() { result = this.getParameter(_) }

0 commit comments

Comments
 (0)