Skip to content

Commit 4fef3e8

Browse files
committed
C#: Rename ControlFlow::Node to ControlFlowNode.
1 parent 35e5499 commit 4fef3e8

38 files changed

+133
-135
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class AssignableRead extends AssignableAccess {
8383
}
8484

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

@@ -113,7 +113,7 @@ class AssignableRead extends AssignableAccess {
113113
*/
114114
pragma[nomagic]
115115
AssignableRead getANextRead() {
116-
forex(ControlFlow::Node cfn | cfn = result.getAControlFlowNode() |
116+
forex(ControlFlowNode cfn | cfn = result.getAControlFlowNode() |
117117
cfn = this.getAnAdjacentReadSameVar()
118118
)
119119
}
@@ -402,7 +402,7 @@ class AssignableDefinition extends TAssignableDefinition {
402402
* the definitions of `x` and `y` in `M(out x, out y)` and `(x, y) = (0, 1)`
403403
* relate to the same call to `M` and assignment node, respectively.
404404
*/
405-
deprecated ControlFlow::Node getAControlFlowNode() {
405+
deprecated ControlFlowNode getAControlFlowNode() {
406406
result = this.getExpr().getAControlFlowNode()
407407
}
408408

@@ -477,7 +477,7 @@ class AssignableDefinition extends TAssignableDefinition {
477477
*/
478478
pragma[nomagic]
479479
AssignableRead getAFirstRead() {
480-
forex(ControlFlow::Node cfn | cfn = result.getAControlFlowNode() |
480+
forex(ControlFlowNode cfn | cfn = result.getAControlFlowNode() |
481481
exists(Ssa::ExplicitDefinition def | result = def.getAFirstReadAtNode(cfn) |
482482
this = def.getADefinition()
483483
)
@@ -671,7 +671,7 @@ module AssignableDefinitions {
671671
/** Gets the underlying parameter. */
672672
Parameter getParameter() { result = p }
673673

674-
deprecated override ControlFlow::Node getAControlFlowNode() {
674+
deprecated override ControlFlowNode getAControlFlowNode() {
675675
result = p.getCallable().getEntryPoint()
676676
}
677677

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/commons/Constants.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ private import semmle.code.csharp.commons.ComparisonTest
55
private import semmle.code.csharp.commons.StructuralComparison as StructuralComparison
66

77
pragma[noinline]
8-
private predicate isConstantCondition0(ControlFlow::Node cfn, boolean b) {
8+
private predicate isConstantCondition0(ControlFlowNode cfn, boolean b) {
99
exists(cfn.getASuccessorByType(any(ControlFlow::BooleanSuccessor t | t.getValue() = b))) and
1010
strictcount(ControlFlow::SuccessorType t | exists(cfn.getASuccessorByType(t))) = 1
1111
}
@@ -14,7 +14,7 @@ private predicate isConstantCondition0(ControlFlow::Node cfn, boolean b) {
1414
* Holds if `e` is a condition that always evaluates to Boolean value `b`.
1515
*/
1616
predicate isConstantCondition(Expr e, boolean b) {
17-
forex(ControlFlow::Node cfn | cfn = e.getAControlFlowNode() | isConstantCondition0(cfn, b))
17+
forex(ControlFlowNode cfn | cfn = e.getAControlFlowNode() | isConstantCondition0(cfn, b))
1818
}
1919

2020
/**

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
@@ -1114,7 +1114,7 @@ module Internal {
11141114

11151115
pragma[nomagic]
11161116
private predicate nodeIsGuardedBySameSubExpr0(
1117-
ControlFlow::Node guardedCfn, BasicBlock guardedBB, AccessOrCallExpr guarded, Guard g,
1117+
ControlFlowNode guardedCfn, BasicBlock guardedBB, AccessOrCallExpr guarded, Guard g,
11181118
AccessOrCallExpr sub, GuardValue v
11191119
) {
11201120
Stages::GuardsStage::forceCachingInSameStage() and
@@ -1127,7 +1127,7 @@ module Internal {
11271127

11281128
pragma[nomagic]
11291129
private predicate nodeIsGuardedBySameSubExpr(
1130-
ControlFlow::Node guardedCfn, BasicBlock guardedBB, AccessOrCallExpr guarded, Guard g,
1130+
ControlFlowNode guardedCfn, BasicBlock guardedBB, AccessOrCallExpr guarded, Guard g,
11311131
AccessOrCallExpr sub, GuardValue v
11321132
) {
11331133
nodeIsGuardedBySameSubExpr0(guardedCfn, guardedBB, guarded, g, sub, v) and
@@ -1136,8 +1136,8 @@ module Internal {
11361136

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

11481148
pragma[nomagic]
11491149
private predicate nodeIsGuardedBySameSubExprSsaDef(
1150-
ControlFlow::Node guardedCfn, AccessOrCallExpr guarded, Guard g, ControlFlow::Node subCfn,
1150+
ControlFlowNode guardedCfn, AccessOrCallExpr guarded, Guard g, ControlFlowNode subCfn,
11511151
AccessOrCallExpr sub, GuardValue v, Ssa::Definition def
11521152
) {
11531153
exists(BasicBlock guardedBB, BasicBlock subCfnBB |
@@ -1161,15 +1161,15 @@ module Internal {
11611161
private predicate isGuardedByExpr0(
11621162
AccessOrCallExpr guarded, Guard g, AccessOrCallExpr sub, GuardValue v
11631163
) {
1164-
forex(ControlFlow::Node cfn | cfn = guarded.getAControlFlowNode() |
1164+
forex(ControlFlowNode cfn | cfn = guarded.getAControlFlowNode() |
11651165
nodeIsGuardedBySameSubExpr(cfn, _, guarded, g, sub, v)
11661166
)
11671167
}
11681168

11691169
cached
11701170
predicate isGuardedByExpr(AccessOrCallExpr guarded, Guard g, AccessOrCallExpr sub, GuardValue v) {
11711171
isGuardedByExpr0(guarded, g, sub, v) and
1172-
forall(ControlFlow::Node subCfn, Ssa::Definition def |
1172+
forall(ControlFlowNode subCfn, Ssa::Definition def |
11731173
nodeIsGuardedBySameSubExprSsaDef(_, guarded, g, subCfn, sub, v, def)
11741174
|
11751175
def = guarded.getAnSsaQualifier(_)
@@ -1181,7 +1181,7 @@ module Internal {
11811181
ControlFlow::Nodes::ElementNode guarded, Guard g, AccessOrCallExpr sub, GuardValue v
11821182
) {
11831183
nodeIsGuardedBySameSubExpr(guarded, _, _, g, sub, v) and
1184-
forall(ControlFlow::Node subCfn, Ssa::Definition def |
1184+
forall(ControlFlowNode subCfn, Ssa::Definition def |
11851185
nodeIsGuardedBySameSubExprSsaDef(guarded, _, g, subCfn, sub, v, def)
11861186
|
11871187
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
}

0 commit comments

Comments
 (0)