Skip to content

Commit a358a19

Browse files
committed
add explicit this to all calls to class predicates
1 parent a237137 commit a358a19

File tree

111 files changed

+1663
-1515
lines changed

Some content is hidden

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

111 files changed

+1663
-1515
lines changed

csharp/ql/lib/semmle/code/asp/WebConfig.qll

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import csharp
88
* A `Web.config` file.
99
*/
1010
class WebConfigXML extends XMLFile {
11-
WebConfigXML() { getName().matches("%Web.config") }
11+
WebConfigXML() { this.getName().matches("%Web.config") }
1212
}
1313

1414
/** A `<configuration>` tag in an ASP.NET configuration file. */
@@ -73,12 +73,14 @@ class FormsElement extends XMLElement {
7373
/**
7474
* Gets attribute's `requireSSL` value.
7575
*/
76-
string getRequireSSL() { result = getAttribute("requireSSL").getValue().trim().toLowerCase() }
76+
string getRequireSSL() {
77+
result = this.getAttribute("requireSSL").getValue().trim().toLowerCase()
78+
}
7779

7880
/**
7981
* Holds if `requireSSL` value is true.
8082
*/
81-
predicate isRequireSSL() { getRequireSSL() = "true" }
83+
predicate isRequireSSL() { this.getRequireSSL() = "true" }
8284
}
8385

8486
/** A `<httpCookies>` tag in an ASP.NET configuration file. */
@@ -89,26 +91,28 @@ class HttpCookiesElement extends XMLElement {
8991
* Gets attribute's `httpOnlyCookies` value.
9092
*/
9193
string getHttpOnlyCookies() {
92-
result = getAttribute("httpOnlyCookies").getValue().trim().toLowerCase()
94+
result = this.getAttribute("httpOnlyCookies").getValue().trim().toLowerCase()
9395
}
9496

9597
/**
9698
* Holds if there is any chance that `httpOnlyCookies` is set to `true`.
9799
*/
98-
predicate isHttpOnlyCookies() { getHttpOnlyCookies() = "true" }
100+
predicate isHttpOnlyCookies() { this.getHttpOnlyCookies() = "true" }
99101

100102
/**
101103
* Gets attribute's `requireSSL` value.
102104
*/
103-
string getRequireSSL() { result = getAttribute("requireSSL").getValue().trim().toLowerCase() }
105+
string getRequireSSL() {
106+
result = this.getAttribute("requireSSL").getValue().trim().toLowerCase()
107+
}
104108

105109
/**
106110
* Holds if there is any chance that `requireSSL` is set to `true` either globally or for Forms.
107111
*/
108112
predicate isRequireSSL() {
109-
getRequireSSL() = "true"
113+
this.getRequireSSL() = "true"
110114
or
111-
not getRequireSSL() = "false" and // not set all, i.e. default
112-
exists(FormsElement forms | forms.getFile() = getFile() | forms.isRequireSSL())
115+
not this.getRequireSSL() = "false" and // not set all, i.e. default
116+
exists(FormsElement forms | forms.getFile() = this.getFile() | forms.isRequireSSL())
113117
}
114118
}

csharp/ql/lib/semmle/code/cil/Access.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class VariableAccess extends Access, @cil_access { }
2020

2121
/** An instruction that reads a variable. */
2222
class ReadAccess extends VariableAccess, Expr, @cil_read_access {
23-
override Type getType() { result = getTarget().getType() }
23+
override Type getType() { result = this.getTarget().getType() }
2424
}
2525

2626
/** An instruction yielding an address. */
@@ -49,7 +49,7 @@ class ParameterReadAccess extends ParameterAccess, ReadAccess {
4949
class ParameterWriteAccess extends ParameterAccess, WriteAccess {
5050
override int getPopCount() { result = 1 }
5151

52-
override Expr getExpr() { result = getOperand(0) }
52+
override Expr getExpr() { result = this.getOperand(0) }
5353
}
5454

5555
/** An access to the `this` parameter. */
@@ -71,9 +71,9 @@ class LocalVariableAccess extends StackVariableAccess, @cil_local_access {
7171
class LocalVariableWriteAccess extends LocalVariableAccess, WriteAccess {
7272
override int getPopCount() { result = 1 }
7373

74-
override Expr getExpr() { result = getOperand(0) }
74+
override Expr getExpr() { result = this.getOperand(0) }
7575

76-
override string getExtra() { result = "L" + getTarget().getIndex() }
76+
override string getExtra() { result = "L" + this.getTarget().getIndex() }
7777
}
7878

7979
/** An instruction that reads a local variable. */
@@ -85,7 +85,7 @@ class LocalVariableReadAccess extends LocalVariableAccess, ReadAccess {
8585
class FieldAccess extends VariableAccess, @cil_field_access {
8686
override Field getTarget() { result = VariableAccess.super.getTarget() }
8787

88-
override string getExtra() { result = getTarget().getName() }
88+
override string getExtra() { result = this.getTarget().getName() }
8989

9090
/** Gets the qualifier of the access, if any. */
9191
abstract Expr getQualifier();

csharp/ql/lib/semmle/code/cil/BasicBlock.qll

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ private import CIL
1010
*/
1111
class BasicBlock extends Cached::TBasicBlockStart {
1212
/** Gets an immediate successor of this basic block, if any. */
13-
BasicBlock getASuccessor() { result.getFirstNode() = getLastNode().getASuccessor() }
13+
BasicBlock getASuccessor() { result.getFirstNode() = this.getLastNode().getASuccessor() }
1414

1515
/** Gets an immediate predecessor of this basic block, if any. */
1616
BasicBlock getAPredecessor() { result.getASuccessor() = this }
@@ -31,7 +31,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
3131
* The basic block on line 2 is an immediate `true` successor of the
3232
* basic block on line 1.
3333
*/
34-
BasicBlock getATrueSuccessor() { result.getFirstNode() = getLastNode().getTrueSuccessor() }
34+
BasicBlock getATrueSuccessor() { result.getFirstNode() = this.getLastNode().getTrueSuccessor() }
3535

3636
/**
3737
* Gets an immediate `false` successor, if any.
@@ -49,22 +49,22 @@ class BasicBlock extends Cached::TBasicBlockStart {
4949
* The basic block on line 2 is an immediate `false` successor of the
5050
* basic block on line 1.
5151
*/
52-
BasicBlock getAFalseSuccessor() { result.getFirstNode() = getLastNode().getFalseSuccessor() }
52+
BasicBlock getAFalseSuccessor() { result.getFirstNode() = this.getLastNode().getFalseSuccessor() }
5353

5454
/** Gets the control flow node at a specific (zero-indexed) position in this basic block. */
55-
ControlFlowNode getNode(int pos) { Cached::bbIndex(getFirstNode(), result, pos) }
55+
ControlFlowNode getNode(int pos) { Cached::bbIndex(this.getFirstNode(), result, pos) }
5656

5757
/** Gets a control flow node in this basic block. */
58-
ControlFlowNode getANode() { result = getNode(_) }
58+
ControlFlowNode getANode() { result = this.getNode(_) }
5959

6060
/** Gets the first control flow node in this basic block. */
6161
ControlFlowNode getFirstNode() { this = Cached::TBasicBlockStart(result) }
6262

6363
/** Gets the last control flow node in this basic block. */
64-
ControlFlowNode getLastNode() { result = getNode(length() - 1) }
64+
ControlFlowNode getLastNode() { result = this.getNode(this.length() - 1) }
6565

6666
/** Gets the length of this basic block. */
67-
int length() { result = strictcount(getANode()) }
67+
int length() { result = strictcount(this.getANode()) }
6868

6969
/**
7070
* Holds if this basic block strictly dominates basic block `bb`.
@@ -114,7 +114,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
114114
*/
115115
predicate dominates(BasicBlock bb) {
116116
bb = this or
117-
strictlyDominates(bb)
117+
this.strictlyDominates(bb)
118118
}
119119

120120
/**
@@ -140,14 +140,14 @@ class BasicBlock extends Cached::TBasicBlockStart {
140140
* does not dominate the basic block on line 6.
141141
*/
142142
predicate inDominanceFrontier(BasicBlock df) {
143-
dominatesPredecessor(df) and
144-
not strictlyDominates(df)
143+
this.dominatesPredecessor(df) and
144+
not this.strictlyDominates(df)
145145
}
146146

147147
/**
148148
* Holds if this basic block dominates a predecessor of `df`.
149149
*/
150-
private predicate dominatesPredecessor(BasicBlock df) { dominates(df.getAPredecessor()) }
150+
private predicate dominatesPredecessor(BasicBlock df) { this.dominates(df.getAPredecessor()) }
151151

152152
/**
153153
* Gets the basic block that immediately dominates this basic block, if any.
@@ -226,7 +226,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
226226
* post-dominates itself.
227227
*/
228228
predicate postDominates(BasicBlock bb) {
229-
strictlyPostDominates(bb) or
229+
this.strictlyPostDominates(bb) or
230230
this = bb
231231
}
232232

@@ -239,7 +239,7 @@ class BasicBlock extends Cached::TBasicBlockStart {
239239
predicate inLoop() { this.getASuccessor+() = this }
240240

241241
/** Gets a textual representation of this basic block. */
242-
string toString() { result = getFirstNode().toString() }
242+
string toString() { result = this.getFirstNode().toString() }
243243

244244
/** Gets the location of this basic block. */
245245
Location getLocation() { result = this.getFirstNode().getLocation() }
@@ -325,16 +325,16 @@ private predicate exitBB(BasicBlock bb) { not exists(bb.getLastNode().getASucces
325325
* A basic block with more than one predecessor.
326326
*/
327327
class JoinBlock extends BasicBlock {
328-
JoinBlock() { getFirstNode().isJoin() }
328+
JoinBlock() { this.getFirstNode().isJoin() }
329329
}
330330

331331
/** A basic block that terminates in a condition, splitting the subsequent control flow. */
332332
class ConditionBlock extends BasicBlock {
333333
ConditionBlock() {
334334
exists(BasicBlock succ |
335-
succ = getATrueSuccessor()
335+
succ = this.getATrueSuccessor()
336336
or
337-
succ = getAFalseSuccessor()
337+
succ = this.getAFalseSuccessor()
338338
)
339339
}
340340

@@ -380,16 +380,16 @@ class ConditionBlock extends BasicBlock {
380380
*/
381381

382382
exists(BasicBlock succ |
383-
isCandidateSuccessor(succ, testIsTrue) and
383+
this.isCandidateSuccessor(succ, testIsTrue) and
384384
succ.dominates(controlled)
385385
)
386386
}
387387

388388
private predicate isCandidateSuccessor(BasicBlock succ, boolean testIsTrue) {
389389
(
390-
testIsTrue = true and succ = getATrueSuccessor()
390+
testIsTrue = true and succ = this.getATrueSuccessor()
391391
or
392-
testIsTrue = false and succ = getAFalseSuccessor()
392+
testIsTrue = false and succ = this.getAFalseSuccessor()
393393
) and
394394
forall(BasicBlock pred | pred = succ.getAPredecessor() and pred != this | succ.dominates(pred))
395395
}

0 commit comments

Comments
 (0)