Skip to content

Commit 15459d3

Browse files
committed
C#: Rename remaining references to ControlFlow::Nodes.
1 parent 703a54c commit 15459d3

File tree

22 files changed

+104
-102
lines changed

22 files changed

+104
-102
lines changed

csharp/ql/consistency-queries/DataFlowConsistency.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private module Input implements InputSig<Location, CsharpDataFlow> {
7070
init.getInitializer().getNumberOfChildren() > 1
7171
)
7272
or
73-
exists(ControlFlow::Nodes::ElementNode cfn, ControlFlow::Nodes::Split split |
73+
exists(ControlFlowNodes::ElementNode cfn, ControlFlowNodes::Split split |
7474
exists(arg.asExprAtNode(cfn))
7575
|
7676
split = cfn.getASplit() and

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ControlFlowElement extends ControlFlowElementOrCallable, @control_flow_ele
4242
* several `ControlFlowNode`s, for example to represent the continuation
4343
* flow in a `try/catch/finally` construction.
4444
*/
45-
Nodes::ElementNode getAControlFlowNode() { result.getAstNode() = this }
45+
ControlFlowNodes::ElementNode getAControlFlowNode() { result.getAstNode() = this }
4646

4747
/** Gets the control flow node for this element. */
4848
ControlFlowNode getControlFlowNode() { result.getAstNode() = this }
@@ -53,14 +53,14 @@ class ControlFlowElement extends ControlFlowElementOrCallable, @control_flow_ele
5353
/**
5454
* Gets a first control flow node executed within this element.
5555
*/
56-
Nodes::ElementNode getAControlFlowEntryNode() {
56+
ControlFlowNodes::ElementNode getAControlFlowEntryNode() {
5757
result = Impl::getAControlFlowEntryNode(this).(ControlFlowElement).getAControlFlowNode()
5858
}
5959

6060
/**
6161
* Gets a potential last control flow node executed within this element.
6262
*/
63-
Nodes::ElementNode getAControlFlowExitNode() {
63+
ControlFlowNodes::ElementNode getAControlFlowExitNode() {
6464
result = Impl::getAControlFlowExitNode(this).(ControlFlowElement).getAControlFlowNode()
6565
}
6666

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

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -255,42 +255,6 @@ module ControlFlow {
255255
Callable getEnclosingCallable() { result = this.getScope() }
256256
}
257257

258-
/** Provides different types of control flow nodes. */
259-
module Nodes {
260-
/**
261-
* A node for a control flow element, that is, an expression or a statement.
262-
*
263-
* Each control flow element maps to zero or more `ElementNode`s: zero when
264-
* the element is in unreachable (dead) code, and multiple when there are
265-
* different splits for the element.
266-
*/
267-
class ElementNode extends Node instanceof Impl::AstCfgNode {
268-
/** Gets a comma-separated list of strings for each split in this node, if any. */
269-
final string getSplitsString() { result = super.getSplitsString() }
270-
271-
/** Gets a split for this control flow node, if any. */
272-
final Split getASplit() { result = super.getASplit() }
273-
}
274-
275-
/** A control-flow node for an expression. */
276-
class ExprNode extends ElementNode {
277-
Expr e;
278-
279-
ExprNode() { e = unique(Expr e_ | e_ = this.asExpr() | e_) }
280-
281-
/** Gets the expression that this control-flow node belongs to. */
282-
Expr getExpr() { result = e }
283-
284-
/** Gets the value of this expression node, if any. */
285-
string getValue() { result = e.getValue() }
286-
287-
/** Gets the type of this expression node. */
288-
Type getType() { result = e.getType() }
289-
}
290-
291-
class Split = Splitting::Split;
292-
}
293-
294258
class BasicBlock = BBs::BasicBlock;
295259

296260
/** Provides different types of basic blocks. */
@@ -308,3 +272,42 @@ module ControlFlow {
308272
class ConditionBlock = BBs::ConditionBlock;
309273
}
310274
}
275+
276+
/** Provides different types of control flow nodes. */
277+
module ControlFlowNodes {
278+
private import internal.ControlFlowGraphImpl as Impl
279+
private import internal.Splitting as Splitting
280+
281+
/**
282+
* A node for a control flow element, that is, an expression or a statement.
283+
*
284+
* Each control flow element maps to zero or more `ElementNode`s: zero when
285+
* the element is in unreachable (dead) code, and multiple when there are
286+
* different splits for the element.
287+
*/
288+
class ElementNode extends ControlFlowNode instanceof Impl::AstCfgNode {
289+
/** Gets a comma-separated list of strings for each split in this node, if any. */
290+
final string getSplitsString() { result = super.getSplitsString() }
291+
292+
/** Gets a split for this control flow node, if any. */
293+
final Split getASplit() { result = super.getASplit() }
294+
}
295+
296+
/** A control-flow node for an expression. */
297+
class ExprNode extends ElementNode {
298+
Expr e;
299+
300+
ExprNode() { e = unique(Expr e_ | e_ = this.asExpr() | e_) }
301+
302+
/** Gets the expression that this control-flow node belongs to. */
303+
Expr getExpr() { result = e }
304+
305+
/** Gets the value of this expression node, if any. */
306+
string getValue() { result = e.getValue() }
307+
308+
/** Gets the type of this expression node. */
309+
Type getType() { result = e.getType() }
310+
}
311+
312+
class Split = Splitting::Split;
313+
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class Guard extends Guards::Guard {
322322
* In case `cfn` or `sub` access an SSA variable in their left-most qualifier, then
323323
* so must the other (accessing the same SSA variable).
324324
*/
325-
predicate controlsNode(ControlFlow::Nodes::ElementNode cfn, AccessOrCallExpr sub, GuardValue v) {
325+
predicate controlsNode(ControlFlowNodes::ElementNode cfn, AccessOrCallExpr sub, GuardValue v) {
326326
isGuardedByNode(cfn, this, sub, v)
327327
}
328328

@@ -332,7 +332,7 @@ class Guard extends Guards::Guard {
332332
* Note: This predicate is inlined.
333333
*/
334334
pragma[inline]
335-
predicate controlsNode(ControlFlow::Nodes::ElementNode cfn, GuardValue v) {
335+
predicate controlsNode(ControlFlowNodes::ElementNode cfn, GuardValue v) {
336336
guardControls(this, cfn.getBasicBlock(), v)
337337
}
338338

@@ -729,7 +729,7 @@ class GuardedExpr extends AccessOrCallExpr {
729729
* In the example above, the node for `x.ToString()` is null-guarded in the
730730
* split `b == true`, but not in the split `b == false`.
731731
*/
732-
class GuardedControlFlowNode extends ControlFlow::Nodes::ElementNode {
732+
class GuardedControlFlowNode extends ControlFlowNodes::ElementNode {
733733
private Guard g;
734734
private AccessOrCallExpr sub0;
735735
private GuardValue v0;
@@ -785,7 +785,7 @@ class GuardedDataFlowNode extends DataFlow::ExprNode {
785785
private GuardValue v0;
786786

787787
GuardedDataFlowNode() {
788-
exists(ControlFlow::Nodes::ElementNode cfn | exists(this.getExprAtNode(cfn)) |
788+
exists(ControlFlowNodes::ElementNode cfn | exists(this.getExprAtNode(cfn)) |
789789
g.controlsNode(cfn, sub0, v0)
790790
)
791791
}
@@ -1178,7 +1178,7 @@ module Internal {
11781178

11791179
cached
11801180
predicate isGuardedByNode(
1181-
ControlFlow::Nodes::ElementNode guarded, Guard g, AccessOrCallExpr sub, GuardValue v
1181+
ControlFlowNodes::ElementNode guarded, Guard g, AccessOrCallExpr sub, GuardValue v
11821182
) {
11831183
nodeIsGuardedBySameSubExpr(guarded, _, _, g, sub, v) and
11841184
forall(ControlFlowNode subCfn, Ssa::Definition def |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ module Ssa {
486486
* `M2` via the call on line 6.
487487
*/
488488
deprecated final predicate isCapturedVariableDefinitionFlowIn(
489-
ImplicitEntryDefinition def, ControlFlow::Nodes::ElementNode c, boolean additionalCalls
489+
ImplicitEntryDefinition def, ControlFlowNodes::ElementNode c, boolean additionalCalls
490490
) {
491491
none()
492492
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ predicate strictlyNegativeExpr(Expr e) {
3434
}
3535

3636
/** Holds if `e` can be positive and cannot be negative. */
37-
predicate positive(ControlFlow::Nodes::ExprNode e) { Common::positive(e) }
37+
predicate positive(ControlFlowNodes::ExprNode e) { Common::positive(e) }
3838

3939
/** Holds if `e` can be negative and cannot be positive. */
40-
predicate negative(ControlFlow::Nodes::ExprNode e) { Common::negative(e) }
40+
predicate negative(ControlFlowNodes::ExprNode e) { Common::negative(e) }
4141

4242
/** Holds if `e` is strictly positive. */
43-
predicate strictlyPositive(ControlFlow::Nodes::ExprNode e) { Common::strictlyPositive(e) }
43+
predicate strictlyPositive(ControlFlowNodes::ExprNode e) { Common::strictlyPositive(e) }
4444

4545
/** Holds if `e` is strictly negative. */
46-
predicate strictlyNegative(ControlFlow::Nodes::ExprNode e) { Common::strictlyNegative(e) }
46+
predicate strictlyNegative(ControlFlowNodes::ExprNode e) { Common::strictlyNegative(e) }

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowDispatch.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ private module Cached {
7373

7474
cached
7575
newtype TDataFlowCall =
76-
TNonDelegateCall(ControlFlow::Nodes::ElementNode cfn, DispatchCall dc) {
76+
TNonDelegateCall(ControlFlowNodes::ElementNode cfn, DispatchCall dc) {
7777
DataFlowImplCommon::forceCachingInSameStage() and
7878
cfn.asExpr() = dc.getCall()
7979
} or
80-
TExplicitDelegateLikeCall(ControlFlow::Nodes::ElementNode cfn, DelegateLikeCall dc) {
80+
TExplicitDelegateLikeCall(ControlFlowNodes::ElementNode cfn, DelegateLikeCall dc) {
8181
cfn.asExpr() = dc
8282
} or
8383
TSummaryCall(FlowSummary::SummarizedCallable c, FlowSummaryImpl::Private::SummaryNode receiver) {
@@ -210,7 +210,7 @@ class DataFlowCallable extends TDataFlowCallable {
210210
}
211211

212212
pragma[nomagic]
213-
private ControlFlow::Nodes::ElementNode getAMultiBodyEntryNode(ControlFlow::BasicBlock bb, int i) {
213+
private ControlFlowNodes::ElementNode getAMultiBodyEntryNode(ControlFlow::BasicBlock bb, int i) {
214214
this.isMultiBodied() and
215215
exists(ControlFlowElement body, Location l |
216216
body = this.asCallable(l).getBody() or
@@ -223,14 +223,14 @@ class DataFlowCallable extends TDataFlowCallable {
223223
}
224224

225225
pragma[nomagic]
226-
private ControlFlow::Nodes::ElementNode getAMultiBodyControlFlowNodePred() {
226+
private ControlFlowNodes::ElementNode getAMultiBodyControlFlowNodePred() {
227227
result = this.getAMultiBodyEntryNode(_, _).getAPredecessor()
228228
or
229229
result = this.getAMultiBodyControlFlowNodePred().getAPredecessor()
230230
}
231231

232232
pragma[nomagic]
233-
private ControlFlow::Nodes::ElementNode getAMultiBodyControlFlowNodeSuccSameBasicBlock() {
233+
private ControlFlowNodes::ElementNode getAMultiBodyControlFlowNodeSuccSameBasicBlock() {
234234
exists(ControlFlow::BasicBlock bb, int i, int j |
235235
exists(this.getAMultiBodyEntryNode(bb, i)) and
236236
result = bb.getNode(j) and
@@ -246,7 +246,7 @@ class DataFlowCallable extends TDataFlowCallable {
246246
}
247247

248248
pragma[inline]
249-
private ControlFlow::Nodes::ElementNode getAMultiBodyControlFlowNode() {
249+
private ControlFlowNodes::ElementNode getAMultiBodyControlFlowNode() {
250250
result =
251251
[
252252
this.getAMultiBodyEntryNode(_, _), this.getAMultiBodyControlFlowNodePred(),
@@ -307,7 +307,7 @@ abstract class DataFlowCall extends TDataFlowCall {
307307
abstract DataFlowCallable getARuntimeTarget();
308308

309309
/** Gets the control flow node where this call happens, if any. */
310-
abstract ControlFlow::Nodes::ElementNode getControlFlowNode();
310+
abstract ControlFlowNodes::ElementNode getControlFlowNode();
311311

312312
/** Gets the data flow node corresponding to this call, if any. */
313313
abstract DataFlow::Node getNode();
@@ -363,7 +363,7 @@ private predicate folderDist(Folder f1, Folder f2, int i) =
363363

364364
/** A non-delegate C# call relevant for data flow. */
365365
class NonDelegateDataFlowCall extends DataFlowCall, TNonDelegateCall {
366-
private ControlFlow::Nodes::ElementNode cfn;
366+
private ControlFlowNodes::ElementNode cfn;
367367
private DispatchCall dc;
368368

369369
NonDelegateDataFlowCall() { this = TNonDelegateCall(cfn, dc) }
@@ -436,7 +436,7 @@ class NonDelegateDataFlowCall extends DataFlowCall, TNonDelegateCall {
436436
not dc.isReflection()
437437
}
438438

439-
override ControlFlow::Nodes::ElementNode getControlFlowNode() { result = cfn }
439+
override ControlFlowNodes::ElementNode getControlFlowNode() { result = cfn }
440440

441441
override DataFlow::ExprNode getNode() { result.getControlFlowNode() = cfn }
442442

@@ -452,7 +452,7 @@ abstract class DelegateDataFlowCall extends DataFlowCall { }
452452

453453
/** An explicit delegate or function pointer call relevant for data flow. */
454454
class ExplicitDelegateLikeDataFlowCall extends DelegateDataFlowCall, TExplicitDelegateLikeCall {
455-
private ControlFlow::Nodes::ElementNode cfn;
455+
private ControlFlowNodes::ElementNode cfn;
456456
private DelegateLikeCall dc;
457457

458458
ExplicitDelegateLikeDataFlowCall() { this = TExplicitDelegateLikeCall(cfn, dc) }
@@ -464,7 +464,7 @@ class ExplicitDelegateLikeDataFlowCall extends DelegateDataFlowCall, TExplicitDe
464464
none() // handled by the shared library
465465
}
466466

467-
override ControlFlow::Nodes::ElementNode getControlFlowNode() { result = cfn }
467+
override ControlFlowNodes::ElementNode getControlFlowNode() { result = cfn }
468468

469469
override DataFlow::ExprNode getNode() { result.getControlFlowNode() = cfn }
470470

@@ -495,7 +495,7 @@ class SummaryCall extends DelegateDataFlowCall, TSummaryCall {
495495
none() // handled by the shared library
496496
}
497497

498-
override ControlFlow::Nodes::ElementNode getControlFlowNode() { none() }
498+
override ControlFlowNodes::ElementNode getControlFlowNode() { none() }
499499

500500
override DataFlow::Node getNode() { none() }
501501

0 commit comments

Comments
 (0)