Skip to content

Commit 10d6803

Browse files
authored
Merge pull request github#6880 from hvitved/csharp/explicit-this
C#: Add explicit `this` qualifiers
2 parents a237137 + f542033 commit 10d6803

File tree

135 files changed

+2567
-2332
lines changed

Some content is hidden

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

135 files changed

+2567
-2332
lines changed

cpp/ql/lib/semmle/code/cpp/XML.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class XMLParent extends @xmlparent {
108108
}
109109

110110
/** Gets the text value contained in this XML parent. */
111-
string getTextValue() { result = allCharactersString() }
111+
string getTextValue() { result = this.allCharactersString() }
112112

113113
/** Gets a printable representation of this XML parent. */
114114
string toString() { result = this.getName() }
@@ -119,7 +119,7 @@ class XMLFile extends XMLParent, File {
119119
XMLFile() { xmlEncoding(this, _) }
120120

121121
/** Gets a printable representation of this XML file. */
122-
override string toString() { result = getName() }
122+
override string toString() { result = this.getName() }
123123

124124
/** Gets the name of this XML file. */
125125
override string getName() { result = File.super.getAbsolutePath() }
@@ -129,14 +129,14 @@ class XMLFile extends XMLParent, File {
129129
*
130130
* Gets the path of this XML file.
131131
*/
132-
deprecated string getPath() { result = getAbsolutePath() }
132+
deprecated string getPath() { result = this.getAbsolutePath() }
133133

134134
/**
135135
* DEPRECATED: Use `getParentContainer().getAbsolutePath()` instead.
136136
*
137137
* Gets the path of the folder that contains this XML file.
138138
*/
139-
deprecated string getFolder() { result = getParentContainer().getAbsolutePath() }
139+
deprecated string getFolder() { result = this.getParentContainer().getAbsolutePath() }
140140

141141
/** Gets the encoding of this XML file. */
142142
string getEncoding() { xmlEncoding(this, result) }
@@ -200,7 +200,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
200200
*/
201201
class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
202202
/** Holds if this XML element has the given `name`. */
203-
predicate hasName(string name) { name = getName() }
203+
predicate hasName(string name) { name = this.getName() }
204204

205205
/** Gets the name of this XML element. */
206206
override string getName() { xmlElements(this, result, _, _, _) }
@@ -239,7 +239,7 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
239239
string getAttributeValue(string name) { result = this.getAttribute(name).getValue() }
240240

241241
/** Gets a printable representation of this XML element. */
242-
override string toString() { result = getName() }
242+
override string toString() { result = this.getName() }
243243
}
244244

245245
/**

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ class CallContextSpecificCall extends CallContextCall, TSpecificCall {
937937
}
938938

939939
override predicate relevantFor(DataFlowCallable callable) {
940-
recordDataFlowCallSite(getCall(), callable)
940+
recordDataFlowCallSite(this.getCall(), callable)
941941
}
942942

943943
override predicate matchesCall(DataFlowCall call) { call = this.getCall() }
@@ -1257,7 +1257,7 @@ abstract class AccessPathFront extends TAccessPathFront {
12571257

12581258
TypedContent getHead() { this = TFrontHead(result) }
12591259

1260-
predicate isClearedAt(Node n) { clearsContentCached(n, getHead().getContent()) }
1260+
predicate isClearedAt(Node n) { clearsContentCached(n, this.getHead().getContent()) }
12611261
}
12621262

12631263
class AccessPathFrontNil extends AccessPathFront, TFrontNil {

cpp/ql/lib/semmle/code/cpp/dataflow/internal/tainttracking1/TaintTrackingImpl.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,26 @@ abstract class Configuration extends DataFlow::Configuration {
7575
predicate isSanitizer(DataFlow::Node node) { none() }
7676

7777
final override predicate isBarrier(DataFlow::Node node) {
78-
isSanitizer(node) or
78+
this.isSanitizer(node) or
7979
defaultTaintSanitizer(node)
8080
}
8181

8282
/** Holds if taint propagation into `node` is prohibited. */
8383
predicate isSanitizerIn(DataFlow::Node node) { none() }
8484

85-
final override predicate isBarrierIn(DataFlow::Node node) { isSanitizerIn(node) }
85+
final override predicate isBarrierIn(DataFlow::Node node) { this.isSanitizerIn(node) }
8686

8787
/** Holds if taint propagation out of `node` is prohibited. */
8888
predicate isSanitizerOut(DataFlow::Node node) { none() }
8989

90-
final override predicate isBarrierOut(DataFlow::Node node) { isSanitizerOut(node) }
90+
final override predicate isBarrierOut(DataFlow::Node node) { this.isSanitizerOut(node) }
9191

9292
/** Holds if taint propagation through nodes guarded by `guard` is prohibited. */
9393
predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { none() }
9494

95-
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) { isSanitizerGuard(guard) }
95+
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) {
96+
this.isSanitizerGuard(guard)
97+
}
9698

9799
/**
98100
* Holds if the additional taint propagation step from `node1` to `node2`
@@ -101,7 +103,7 @@ abstract class Configuration extends DataFlow::Configuration {
101103
predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { none() }
102104

103105
final override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
104-
isAdditionalTaintStep(node1, node2) or
106+
this.isAdditionalTaintStep(node1, node2) or
105107
defaultAdditionalTaintStep(node1, node2)
106108
}
107109

cpp/ql/lib/semmle/code/cpp/dataflow/internal/tainttracking2/TaintTrackingImpl.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,26 @@ abstract class Configuration extends DataFlow::Configuration {
7575
predicate isSanitizer(DataFlow::Node node) { none() }
7676

7777
final override predicate isBarrier(DataFlow::Node node) {
78-
isSanitizer(node) or
78+
this.isSanitizer(node) or
7979
defaultTaintSanitizer(node)
8080
}
8181

8282
/** Holds if taint propagation into `node` is prohibited. */
8383
predicate isSanitizerIn(DataFlow::Node node) { none() }
8484

85-
final override predicate isBarrierIn(DataFlow::Node node) { isSanitizerIn(node) }
85+
final override predicate isBarrierIn(DataFlow::Node node) { this.isSanitizerIn(node) }
8686

8787
/** Holds if taint propagation out of `node` is prohibited. */
8888
predicate isSanitizerOut(DataFlow::Node node) { none() }
8989

90-
final override predicate isBarrierOut(DataFlow::Node node) { isSanitizerOut(node) }
90+
final override predicate isBarrierOut(DataFlow::Node node) { this.isSanitizerOut(node) }
9191

9292
/** Holds if taint propagation through nodes guarded by `guard` is prohibited. */
9393
predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { none() }
9494

95-
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) { isSanitizerGuard(guard) }
95+
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) {
96+
this.isSanitizerGuard(guard)
97+
}
9698

9799
/**
98100
* Holds if the additional taint propagation step from `node1` to `node2`
@@ -101,7 +103,7 @@ abstract class Configuration extends DataFlow::Configuration {
101103
predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { none() }
102104

103105
final override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
104-
isAdditionalTaintStep(node1, node2) or
106+
this.isAdditionalTaintStep(node1, node2) or
105107
defaultAdditionalTaintStep(node1, node2)
106108
}
107109

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ class CallContextSpecificCall extends CallContextCall, TSpecificCall {
937937
}
938938

939939
override predicate relevantFor(DataFlowCallable callable) {
940-
recordDataFlowCallSite(getCall(), callable)
940+
recordDataFlowCallSite(this.getCall(), callable)
941941
}
942942

943943
override predicate matchesCall(DataFlowCall call) { call = this.getCall() }
@@ -1257,7 +1257,7 @@ abstract class AccessPathFront extends TAccessPathFront {
12571257

12581258
TypedContent getHead() { this = TFrontHead(result) }
12591259

1260-
predicate isClearedAt(Node n) { clearsContentCached(n, getHead().getContent()) }
1260+
predicate isClearedAt(Node n) { clearsContentCached(n, this.getHead().getContent()) }
12611261
}
12621262

12631263
class AccessPathFrontNil extends AccessPathFront, TFrontNil {

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/tainttracking1/TaintTrackingImpl.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,26 @@ abstract class Configuration extends DataFlow::Configuration {
7575
predicate isSanitizer(DataFlow::Node node) { none() }
7676

7777
final override predicate isBarrier(DataFlow::Node node) {
78-
isSanitizer(node) or
78+
this.isSanitizer(node) or
7979
defaultTaintSanitizer(node)
8080
}
8181

8282
/** Holds if taint propagation into `node` is prohibited. */
8383
predicate isSanitizerIn(DataFlow::Node node) { none() }
8484

85-
final override predicate isBarrierIn(DataFlow::Node node) { isSanitizerIn(node) }
85+
final override predicate isBarrierIn(DataFlow::Node node) { this.isSanitizerIn(node) }
8686

8787
/** Holds if taint propagation out of `node` is prohibited. */
8888
predicate isSanitizerOut(DataFlow::Node node) { none() }
8989

90-
final override predicate isBarrierOut(DataFlow::Node node) { isSanitizerOut(node) }
90+
final override predicate isBarrierOut(DataFlow::Node node) { this.isSanitizerOut(node) }
9191

9292
/** Holds if taint propagation through nodes guarded by `guard` is prohibited. */
9393
predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { none() }
9494

95-
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) { isSanitizerGuard(guard) }
95+
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) {
96+
this.isSanitizerGuard(guard)
97+
}
9698

9799
/**
98100
* Holds if the additional taint propagation step from `node1` to `node2`
@@ -101,7 +103,7 @@ abstract class Configuration extends DataFlow::Configuration {
101103
predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { none() }
102104

103105
final override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
104-
isAdditionalTaintStep(node1, node2) or
106+
this.isAdditionalTaintStep(node1, node2) or
105107
defaultAdditionalTaintStep(node1, node2)
106108
}
107109

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/tainttracking2/TaintTrackingImpl.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,26 @@ abstract class Configuration extends DataFlow::Configuration {
7575
predicate isSanitizer(DataFlow::Node node) { none() }
7676

7777
final override predicate isBarrier(DataFlow::Node node) {
78-
isSanitizer(node) or
78+
this.isSanitizer(node) or
7979
defaultTaintSanitizer(node)
8080
}
8181

8282
/** Holds if taint propagation into `node` is prohibited. */
8383
predicate isSanitizerIn(DataFlow::Node node) { none() }
8484

85-
final override predicate isBarrierIn(DataFlow::Node node) { isSanitizerIn(node) }
85+
final override predicate isBarrierIn(DataFlow::Node node) { this.isSanitizerIn(node) }
8686

8787
/** Holds if taint propagation out of `node` is prohibited. */
8888
predicate isSanitizerOut(DataFlow::Node node) { none() }
8989

90-
final override predicate isBarrierOut(DataFlow::Node node) { isSanitizerOut(node) }
90+
final override predicate isBarrierOut(DataFlow::Node node) { this.isSanitizerOut(node) }
9191

9292
/** Holds if taint propagation through nodes guarded by `guard` is prohibited. */
9393
predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { none() }
9494

95-
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) { isSanitizerGuard(guard) }
95+
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) {
96+
this.isSanitizerGuard(guard)
97+
}
9698

9799
/**
98100
* Holds if the additional taint propagation step from `node1` to `node2`
@@ -101,7 +103,7 @@ abstract class Configuration extends DataFlow::Configuration {
101103
predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { none() }
102104

103105
final override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
104-
isAdditionalTaintStep(node1, node2) or
106+
this.isAdditionalTaintStep(node1, node2) or
105107
defaultAdditionalTaintStep(node1, node2)
106108
}
107109

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/tainttracking3/TaintTrackingImpl.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,26 @@ abstract class Configuration extends DataFlow::Configuration {
7575
predicate isSanitizer(DataFlow::Node node) { none() }
7676

7777
final override predicate isBarrier(DataFlow::Node node) {
78-
isSanitizer(node) or
78+
this.isSanitizer(node) or
7979
defaultTaintSanitizer(node)
8080
}
8181

8282
/** Holds if taint propagation into `node` is prohibited. */
8383
predicate isSanitizerIn(DataFlow::Node node) { none() }
8484

85-
final override predicate isBarrierIn(DataFlow::Node node) { isSanitizerIn(node) }
85+
final override predicate isBarrierIn(DataFlow::Node node) { this.isSanitizerIn(node) }
8686

8787
/** Holds if taint propagation out of `node` is prohibited. */
8888
predicate isSanitizerOut(DataFlow::Node node) { none() }
8989

90-
final override predicate isBarrierOut(DataFlow::Node node) { isSanitizerOut(node) }
90+
final override predicate isBarrierOut(DataFlow::Node node) { this.isSanitizerOut(node) }
9191

9292
/** Holds if taint propagation through nodes guarded by `guard` is prohibited. */
9393
predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { none() }
9494

95-
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) { isSanitizerGuard(guard) }
95+
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) {
96+
this.isSanitizerGuard(guard)
97+
}
9698

9799
/**
98100
* Holds if the additional taint propagation step from `node1` to `node2`
@@ -101,7 +103,7 @@ abstract class Configuration extends DataFlow::Configuration {
101103
predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { none() }
102104

103105
final override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
104-
isAdditionalTaintStep(node1, node2) or
106+
this.isAdditionalTaintStep(node1, node2) or
105107
defaultAdditionalTaintStep(node1, node2)
106108
}
107109

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class IRBlockBase extends TIRBlock {
2424
final string toString() { result = getFirstInstruction(this).toString() }
2525

2626
/** Gets the source location of the first non-`Phi` instruction in this block. */
27-
final Language::Location getLocation() { result = getFirstInstruction().getLocation() }
27+
final Language::Location getLocation() { result = this.getFirstInstruction().getLocation() }
2828

2929
/**
3030
* INTERNAL: Do not use.
@@ -39,7 +39,7 @@ class IRBlockBase extends TIRBlock {
3939
) and
4040
this =
4141
rank[result + 1](IRBlock funcBlock, int sortOverride, int sortKey1, int sortKey2 |
42-
funcBlock.getEnclosingFunction() = getEnclosingFunction() and
42+
funcBlock.getEnclosingFunction() = this.getEnclosingFunction() and
4343
funcBlock.getFirstInstruction().hasSortKeys(sortKey1, sortKey2) and
4444
// Ensure that the block containing `EnterFunction` always comes first.
4545
if funcBlock.getFirstInstruction() instanceof EnterFunctionInstruction
@@ -59,15 +59,15 @@ class IRBlockBase extends TIRBlock {
5959
* Get the `Phi` instructions that appear at the start of this block.
6060
*/
6161
final PhiInstruction getAPhiInstruction() {
62-
Construction::getPhiInstructionBlockStart(result) = getFirstInstruction()
62+
Construction::getPhiInstructionBlockStart(result) = this.getFirstInstruction()
6363
}
6464

6565
/**
6666
* Gets an instruction in this block. This includes `Phi` instructions.
6767
*/
6868
final Instruction getAnInstruction() {
69-
result = getInstruction(_) or
70-
result = getAPhiInstruction()
69+
result = this.getInstruction(_) or
70+
result = this.getAPhiInstruction()
7171
}
7272

7373
/**
@@ -78,7 +78,9 @@ class IRBlockBase extends TIRBlock {
7878
/**
7979
* Gets the last instruction in this block.
8080
*/
81-
final Instruction getLastInstruction() { result = getInstruction(getInstructionCount() - 1) }
81+
final Instruction getLastInstruction() {
82+
result = this.getInstruction(this.getInstructionCount() - 1)
83+
}
8284

8385
/**
8486
* Gets the number of non-`Phi` instructions in this block.
@@ -149,7 +151,7 @@ class IRBlock extends IRBlockBase {
149151
* Block `A` dominates block `B` if any control flow path from the entry block of the function to
150152
* block `B` must pass through block `A`. A block always dominates itself.
151153
*/
152-
final predicate dominates(IRBlock block) { strictlyDominates(block) or this = block }
154+
final predicate dominates(IRBlock block) { this.strictlyDominates(block) or this = block }
153155

154156
/**
155157
* Gets a block on the dominance frontier of this block.
@@ -159,8 +161,8 @@ class IRBlock extends IRBlockBase {
159161
*/
160162
pragma[noinline]
161163
final IRBlock dominanceFrontier() {
162-
dominates(result.getAPredecessor()) and
163-
not strictlyDominates(result)
164+
this.dominates(result.getAPredecessor()) and
165+
not this.strictlyDominates(result)
164166
}
165167

166168
/**
@@ -189,7 +191,7 @@ class IRBlock extends IRBlockBase {
189191
* Block `A` post-dominates block `B` if any control flow path from `B` to the exit block of the
190192
* function must pass through block `A`. A block always post-dominates itself.
191193
*/
192-
final predicate postDominates(IRBlock block) { strictlyPostDominates(block) or this = block }
194+
final predicate postDominates(IRBlock block) { this.strictlyPostDominates(block) or this = block }
193195

194196
/**
195197
* Gets a block on the post-dominance frontier of this block.
@@ -199,16 +201,16 @@ class IRBlock extends IRBlockBase {
199201
*/
200202
pragma[noinline]
201203
final IRBlock postPominanceFrontier() {
202-
postDominates(result.getASuccessor()) and
203-
not strictlyPostDominates(result)
204+
this.postDominates(result.getASuccessor()) and
205+
not this.strictlyPostDominates(result)
204206
}
205207

206208
/**
207209
* Holds if this block is reachable from the entry block of its function.
208210
*/
209211
final predicate isReachableFromFunctionEntry() {
210-
this = getEnclosingIRFunction().getEntryBlock() or
211-
getAPredecessor().isReachableFromFunctionEntry()
212+
this = this.getEnclosingIRFunction().getEntryBlock() or
213+
this.getAPredecessor().isReachableFromFunctionEntry()
212214
}
213215
}
214216

0 commit comments

Comments
 (0)