Skip to content

Commit a90698f

Browse files
committed
C#: Rename ControlFlow::Node to ControlFlowNode.
1 parent 63449b8 commit a90698f

36 files changed

Lines changed: 128 additions & 128 deletions

csharp/ql/lib/semmle/code/csharp/Assignable.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class AssignableRead extends AssignableAccess {
8585
}
8686

8787
pragma[noinline]
88-
private ControlFlow::Node getAnAdjacentReadSameVar() {
88+
private ControlFlowNode getAnAdjacentReadSameVar() {
8989
SsaImpl::adjacentReadPairSameVar(_, this.getAControlFlowNode(), result)
9090
}
9191

@@ -115,7 +115,7 @@ class AssignableRead extends AssignableAccess {
115115
*/
116116
pragma[nomagic]
117117
AssignableRead getANextRead() {
118-
forex(ControlFlow::Node cfn | cfn = result.getAControlFlowNode() |
118+
forex(ControlFlowNode cfn | cfn = result.getAControlFlowNode() |
119119
cfn = this.getAnAdjacentReadSameVar()
120120
)
121121
}
@@ -419,7 +419,7 @@ class AssignableDefinition extends TAssignableDefinition {
419419
* the definitions of `x` and `y` in `M(out x, out y)` and `(x, y) = (0, 1)`
420420
* relate to the same call to `M` and assignment node, respectively.
421421
*/
422-
deprecated ControlFlow::Node getAControlFlowNode() {
422+
deprecated ControlFlowNode getAControlFlowNode() {
423423
result = this.getExpr().getAControlFlowNode()
424424
}
425425

@@ -494,7 +494,7 @@ class AssignableDefinition extends TAssignableDefinition {
494494
*/
495495
pragma[nomagic]
496496
AssignableRead getAFirstRead() {
497-
forex(ControlFlow::Node cfn | cfn = result.getAControlFlowNode() |
497+
forex(ControlFlowNode cfn | cfn = result.getAControlFlowNode() |
498498
exists(Ssa::ExplicitDefinition def | result = def.getAFirstReadAtNode(cfn) |
499499
this = def.getADefinition()
500500
)
@@ -688,7 +688,7 @@ module AssignableDefinitions {
688688
/** Gets the underlying parameter. */
689689
Parameter getParameter() { result = p }
690690

691-
deprecated override ControlFlow::Node getAControlFlowNode() {
691+
deprecated override ControlFlowNode getAControlFlowNode() {
692692
result = p.getCallable().getEntryPoint()
693693
}
694694

csharp/ql/lib/semmle/code/csharp/Caching.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module Stages {
1818
private predicate forceCachingInSameStageRev() {
1919
exists(Split s)
2020
or
21-
exists(ControlFlow::Node n)
21+
exists(ControlFlowNode n)
2222
or
2323
forceCachingInSameStageRev()
2424
}

csharp/ql/lib/semmle/code/csharp/controlflow/BasicBlocks.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ final class BasicBlock extends BasicBlocksImpl::BasicBlock {
6767
BasicBlock getASuccessor() { result = super.getASuccessor() }
6868

6969
/** Gets the control flow node at a specific (zero-indexed) position in this basic block. */
70-
ControlFlow::Node getNode(int pos) { result = super.getNode(pos) }
70+
ControlFlowNode getNode(int pos) { result = super.getNode(pos) }
7171

7272
/** Gets a control flow node in this basic block. */
73-
ControlFlow::Node getANode() { result = super.getANode() }
73+
ControlFlowNode getANode() { result = super.getANode() }
7474

7575
/** Gets the first control flow node in this basic block. */
76-
ControlFlow::Node getFirstNode() { result = super.getFirstNode() }
76+
ControlFlowNode getFirstNode() { result = super.getFirstNode() }
7777

7878
/** Gets the last control flow node in this basic block. */
79-
ControlFlow::Node getLastNode() { result = super.getLastNode() }
79+
ControlFlowNode getLastNode() { result = super.getLastNode() }
8080

8181
/** Gets the callable that this basic block belongs to. */
8282
final Callable getCallable() { result = this.getFirstNode().getEnclosingCallable() }
@@ -339,12 +339,14 @@ final class ConditionBlock extends BasicBlock, BasicBlocksImpl::ConditionBasicBl
339339
}
340340
}
341341

342+
private class ControlFlowNodeAlias = ControlFlowNode;
343+
342344
private class BasicBlockAlias = BasicBlock;
343345

344346
private class EntryBasicBlockAlias = EntryBasicBlock;
345347

346348
module Cfg implements BB::CfgSig<Location> {
347-
class ControlFlowNode = ControlFlow::Node;
349+
class ControlFlowNode = ControlFlowNodeAlias;
348350

349351
class BasicBlock = BasicBlockAlias;
350352

csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowElement.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ControlFlowElementOrCallable extends ExprOrStmtParent, TControlFlowElement
1616
* A program element that can possess control flow. That is, either a statement or
1717
* an expression.
1818
*
19-
* A control flow element can be mapped to a control flow node (`ControlFlow::Node`)
19+
* A control flow element can be mapped to a control flow node (`ControlFlowNode`)
2020
* via `getAControlFlowNode()`. There is a one-to-many relationship between
2121
* control flow elements and control flow nodes. This allows control flow
2222
* splitting, for example modeling the control flow through `finally` blocks.
@@ -37,15 +37,15 @@ class ControlFlowElement extends ControlFlowElementOrCallable, @control_flow_ele
3737
* Gets a control flow node for this element. That is, a node in the
3838
* control flow graph that corresponds to this element.
3939
*
40-
* Typically, there is exactly one `ControlFlow::Node` associated with a
40+
* Typically, there is exactly one `ControlFlowNode` associated with a
4141
* `ControlFlowElement`, but a `ControlFlowElement` may be split into
42-
* several `ControlFlow::Node`s, for example to represent the continuation
42+
* several `ControlFlowNode`s, for example to represent the continuation
4343
* flow in a `try/catch/finally` construction.
4444
*/
4545
Nodes::ElementNode getAControlFlowNode() { result.getAstNode() = this }
4646

4747
/** Gets the control flow node for this element. */
48-
ControlFlow::Node getControlFlowNode() { result.getAstNode() = this }
48+
ControlFlowNode getControlFlowNode() { result.getAstNode() = this }
4949

5050
/** Gets the basic block in which this element occurs. */
5151
BasicBlock getBasicBlock() { result = this.getAControlFlowNode().getBasicBlock() }

csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowGraph.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import csharp
22

3+
class ControlFlowNode = ControlFlow::Node;
4+
35
/**
46
* Provides classes representing the control flow graph within callables.
57
*/

csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowReachability.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ private import semmle.code.csharp.controlflow.Guards as Guards
99
private import semmle.code.csharp.ExprOrStmtParent
1010

1111
private module ControlFlowInput implements
12-
InputSig<Location, ControlFlow::Node, ControlFlow::BasicBlock>
12+
InputSig<Location, ControlFlowNode, ControlFlow::BasicBlock>
1313
{
1414
private import csharp as CS
1515

16-
AstNode getEnclosingAstNode(ControlFlow::Node node) {
16+
AstNode getEnclosingAstNode(ControlFlowNode node) {
1717
node.getAstNode() = result
1818
or
1919
not exists(node.getAstNode()) and result = node.getEnclosingCallable()

csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private import semmle.code.csharp.frameworks.system.collections.Generic
1616
private import codeql.controlflow.Guards as SharedGuards
1717

1818
private module GuardsInput implements
19-
SharedGuards::InputSig<Location, ControlFlow::Node, ControlFlow::BasicBlock>
19+
SharedGuards::InputSig<Location, ControlFlowNode, ControlFlow::BasicBlock>
2020
{
2121
private import csharp as CS
2222

@@ -605,22 +605,22 @@ class AccessOrCallExpr extends Expr {
605605
* An expression can have more than one SSA qualifier in the presence
606606
* of control flow splitting.
607607
*/
608-
Ssa::Definition getAnSsaQualifier(ControlFlow::Node cfn) { result = getAnSsaQualifier(this, cfn) }
608+
Ssa::Definition getAnSsaQualifier(ControlFlowNode cfn) { result = getAnSsaQualifier(this, cfn) }
609609
}
610610

611611
private Declaration getDeclarationTarget(Expr e) {
612612
e = any(AssignableAccess aa | result = aa.getTarget()) or
613613
result = e.(Call).getTarget()
614614
}
615615

616-
private Ssa::Definition getAnSsaQualifier(Expr e, ControlFlow::Node cfn) {
616+
private Ssa::Definition getAnSsaQualifier(Expr e, ControlFlowNode cfn) {
617617
e = getATrackedAccess(result, cfn)
618618
or
619619
not e = getATrackedAccess(_, _) and
620620
result = getAnSsaQualifier(e.(QualifiableExpr).getQualifier(), cfn)
621621
}
622622

623-
private AssignableAccess getATrackedAccess(Ssa::Definition def, ControlFlow::Node cfn) {
623+
private AssignableAccess getATrackedAccess(Ssa::Definition def, ControlFlowNode cfn) {
624624
result = def.getAReadAtNode(cfn)
625625
or
626626
result = def.(Ssa::ExplicitDefinition).getADefinition().getTargetAccess() and
@@ -1115,7 +1115,7 @@ module Internal {
11151115

11161116
pragma[nomagic]
11171117
private predicate nodeIsGuardedBySameSubExpr0(
1118-
ControlFlow::Node guardedCfn, BasicBlock guardedBB, AccessOrCallExpr guarded, Guard g,
1118+
ControlFlowNode guardedCfn, BasicBlock guardedBB, AccessOrCallExpr guarded, Guard g,
11191119
AccessOrCallExpr sub, GuardValue v
11201120
) {
11211121
Stages::GuardsStage::forceCachingInSameStage() and
@@ -1128,7 +1128,7 @@ module Internal {
11281128

11291129
pragma[nomagic]
11301130
private predicate nodeIsGuardedBySameSubExpr(
1131-
ControlFlow::Node guardedCfn, BasicBlock guardedBB, AccessOrCallExpr guarded, Guard g,
1131+
ControlFlowNode guardedCfn, BasicBlock guardedBB, AccessOrCallExpr guarded, Guard g,
11321132
AccessOrCallExpr sub, GuardValue v
11331133
) {
11341134
nodeIsGuardedBySameSubExpr0(guardedCfn, guardedBB, guarded, g, sub, v) and
@@ -1137,8 +1137,8 @@ module Internal {
11371137

11381138
pragma[nomagic]
11391139
private predicate nodeIsGuardedBySameSubExprSsaDef0(
1140-
ControlFlow::Node cfn, BasicBlock guardedBB, AccessOrCallExpr guarded, Guard g,
1141-
ControlFlow::Node subCfn, BasicBlock subCfnBB, AccessOrCallExpr sub, GuardValue v,
1140+
ControlFlowNode cfn, BasicBlock guardedBB, AccessOrCallExpr guarded, Guard g,
1141+
ControlFlowNode subCfn, BasicBlock subCfnBB, AccessOrCallExpr sub, GuardValue v,
11421142
Ssa::Definition def
11431143
) {
11441144
nodeIsGuardedBySameSubExpr(cfn, guardedBB, guarded, g, sub, v) and
@@ -1148,7 +1148,7 @@ module Internal {
11481148

11491149
pragma[nomagic]
11501150
private predicate nodeIsGuardedBySameSubExprSsaDef(
1151-
ControlFlow::Node guardedCfn, AccessOrCallExpr guarded, Guard g, ControlFlow::Node subCfn,
1151+
ControlFlowNode guardedCfn, AccessOrCallExpr guarded, Guard g, ControlFlowNode subCfn,
11521152
AccessOrCallExpr sub, GuardValue v, Ssa::Definition def
11531153
) {
11541154
exists(BasicBlock guardedBB, BasicBlock subCfnBB |
@@ -1162,15 +1162,15 @@ module Internal {
11621162
private predicate isGuardedByExpr0(
11631163
AccessOrCallExpr guarded, Guard g, AccessOrCallExpr sub, GuardValue v
11641164
) {
1165-
forex(ControlFlow::Node cfn | cfn = guarded.getAControlFlowNode() |
1165+
forex(ControlFlowNode cfn | cfn = guarded.getAControlFlowNode() |
11661166
nodeIsGuardedBySameSubExpr(cfn, _, guarded, g, sub, v)
11671167
)
11681168
}
11691169

11701170
cached
11711171
predicate isGuardedByExpr(AccessOrCallExpr guarded, Guard g, AccessOrCallExpr sub, GuardValue v) {
11721172
isGuardedByExpr0(guarded, g, sub, v) and
1173-
forall(ControlFlow::Node subCfn, Ssa::Definition def |
1173+
forall(ControlFlowNode subCfn, Ssa::Definition def |
11741174
nodeIsGuardedBySameSubExprSsaDef(_, guarded, g, subCfn, sub, v, def)
11751175
|
11761176
def = guarded.getAnSsaQualifier(_)
@@ -1182,7 +1182,7 @@ module Internal {
11821182
ControlFlow::Nodes::ElementNode guarded, Guard g, AccessOrCallExpr sub, GuardValue v
11831183
) {
11841184
nodeIsGuardedBySameSubExpr(guarded, _, _, g, sub, v) and
1185-
forall(ControlFlow::Node subCfn, Ssa::Definition def |
1185+
forall(ControlFlowNode subCfn, Ssa::Definition def |
11861186
nodeIsGuardedBySameSubExprSsaDef(guarded, _, g, subCfn, sub, v, def)
11871187
|
11881188
def =

csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qll

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private predicate nonNullDef(Ssa::ExplicitDefinition def) {
126126
/**
127127
* Holds if `node` is a dereference `d` of SSA definition `def`.
128128
*/
129-
private predicate dereferenceAt(ControlFlow::Node node, Ssa::Definition def, Dereference d) {
129+
private predicate dereferenceAt(ControlFlowNode node, Ssa::Definition def, Dereference d) {
130130
d = def.getAReadAtNode(node)
131131
}
132132

@@ -192,9 +192,7 @@ private predicate isNullDefaultArgument(Ssa::ImplicitParameterDefinition def, Al
192192
}
193193

194194
/** Holds if `def` is an SSA definition that may be `null`. */
195-
private predicate defMaybeNull(
196-
Ssa::Definition def, ControlFlow::Node node, string msg, Element reason
197-
) {
195+
private predicate defMaybeNull(Ssa::Definition def, ControlFlowNode node, string msg, Element reason) {
198196
not nonNullDef(def) and
199197
(
200198
// A variable compared to `null` might be `null`
@@ -256,19 +254,19 @@ private Ssa::Definition getAnUltimateDefinition(Ssa::Definition def) {
256254
* through an intermediate dereference that always throws a null reference
257255
* exception.
258256
*/
259-
private predicate defReaches(Ssa::Definition def, ControlFlow::Node cfn) {
257+
private predicate defReaches(Ssa::Definition def, ControlFlowNode cfn) {
260258
exists(def.getAFirstReadAtNode(cfn))
261259
or
262-
exists(ControlFlow::Node mid | defReaches(def, mid) |
260+
exists(ControlFlowNode mid | defReaches(def, mid) |
263261
SsaImpl::adjacentReadPairSameVar(_, mid, cfn) and
264262
not mid = any(Dereference d | d.isAlwaysNull(def.getSourceVariable())).getAControlFlowNode()
265263
)
266264
}
267265

268266
private module NullnessConfig implements ControlFlowReachability::ConfigSig {
269-
predicate source(ControlFlow::Node node, Ssa::Definition def) { defMaybeNull(def, node, _, _) }
267+
predicate source(ControlFlowNode node, Ssa::Definition def) { defMaybeNull(def, node, _, _) }
270268

271-
predicate sink(ControlFlow::Node node, Ssa::Definition def) {
269+
predicate sink(ControlFlowNode node, Ssa::Definition def) {
272270
exists(Dereference d |
273271
dereferenceAt(node, def, d) and
274272
not d instanceof NonNullExpr
@@ -283,9 +281,7 @@ private module NullnessConfig implements ControlFlowReachability::ConfigSig {
283281
private module NullnessFlow = ControlFlowReachability::Flow<NullnessConfig>;
284282

285283
predicate maybeNullDeref(Dereference d, Ssa::SourceVariable v, string msg, Element reason) {
286-
exists(
287-
Ssa::Definition origin, Ssa::Definition ssa, ControlFlow::Node src, ControlFlow::Node sink
288-
|
284+
exists(Ssa::Definition origin, Ssa::Definition ssa, ControlFlowNode src, ControlFlowNode sink |
289285
defMaybeNull(origin, src, msg, reason) and
290286
NullnessFlow::flow(src, origin, sink, ssa) and
291287
ssa.getSourceVariable() = v and

csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ module Ssa {
164164
*/
165165
class Definition extends SsaImpl::Definition {
166166
/** Gets the control flow node of this SSA definition. */
167-
final ControlFlow::Node getControlFlowNode() {
167+
final ControlFlowNode getControlFlowNode() {
168168
exists(ControlFlow::BasicBlock bb, int i | this.definesAt(_, bb, i) |
169169
result = bb.getNode(0.maximum(i))
170170
)
@@ -236,7 +236,7 @@ module Ssa {
236236
* - The reads of `this.Field` on lines 10 and 11 can be reached from the phi
237237
* node between lines 9 and 10.
238238
*/
239-
final AssignableRead getAReadAtNode(ControlFlow::Node cfn) {
239+
final AssignableRead getAReadAtNode(ControlFlowNode cfn) {
240240
result = SsaImpl::getAReadAtNode(this, cfn)
241241
}
242242

@@ -310,7 +310,7 @@ module Ssa {
310310
* Subsequent reads can be found by following the steps defined by
311311
* `AssignableRead.getANextRead()`.
312312
*/
313-
final AssignableRead getAFirstReadAtNode(ControlFlow::Node cfn) {
313+
final AssignableRead getAFirstReadAtNode(ControlFlowNode cfn) {
314314
SsaImpl::firstReadSameVar(this, cfn) and
315315
result.getAControlFlowNode() = cfn
316316
}
@@ -373,7 +373,7 @@ module Ssa {
373373
* - The read of `this.Field` on line 11 is a last read of the phi node
374374
* between lines 9 and 10.
375375
*/
376-
deprecated final AssignableRead getALastReadAtNode(ControlFlow::Node cfn) {
376+
deprecated final AssignableRead getALastReadAtNode(ControlFlowNode cfn) {
377377
SsaImpl::lastReadSameVar(this, cfn) and
378378
result.getAControlFlowNode() = cfn
379379
}

csharp/ql/lib/semmle/code/csharp/dataflow/SignAnalysis.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ private import semmle.code.csharp.dataflow.internal.rangeanalysis.SignAnalysisCo
1111

1212
/** Holds if `e` can be positive and cannot be negative. */
1313
predicate positiveExpr(Expr e) {
14-
forex(ControlFlow::Node cfn | cfn = e.getAControlFlowNode() |
14+
forex(ControlFlowNode cfn | cfn = e.getAControlFlowNode() |
1515
positive(cfn) or strictlyPositive(cfn)
1616
)
1717
}
1818

1919
/** Holds if `e` can be negative and cannot be positive. */
2020
predicate negativeExpr(Expr e) {
21-
forex(ControlFlow::Node cfn | cfn = e.getAControlFlowNode() |
21+
forex(ControlFlowNode cfn | cfn = e.getAControlFlowNode() |
2222
negative(cfn) or strictlyNegative(cfn)
2323
)
2424
}
2525

2626
/** Holds if `e` is strictly positive. */
2727
predicate strictlyPositiveExpr(Expr e) {
28-
forex(ControlFlow::Node cfn | cfn = e.getAControlFlowNode() | strictlyPositive(cfn))
28+
forex(ControlFlowNode cfn | cfn = e.getAControlFlowNode() | strictlyPositive(cfn))
2929
}
3030

3131
/** Holds if `e` is strictly negative. */
3232
predicate strictlyNegativeExpr(Expr e) {
33-
forex(ControlFlow::Node cfn | cfn = e.getAControlFlowNode() | strictlyNegative(cfn))
33+
forex(ControlFlowNode cfn | cfn = e.getAControlFlowNode() | strictlyNegative(cfn))
3434
}
3535

3636
/** Holds if `e` can be positive and cannot be negative. */

0 commit comments

Comments
 (0)