Skip to content

Commit e0421db

Browse files
committed
C#: Reinstate toString for SSA data flow nodes.
1 parent bedadc9 commit e0421db

3 files changed

Lines changed: 7 additions & 15 deletions

File tree

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,6 @@ module Ssa {
506506
}
507507

508508
override Element getElement() { result = ad.getElement() }
509-
510-
override string toString() { result = "SSA def(" + this.getSourceVariable() + ")" }
511509
}
512510

513511
/**
@@ -551,12 +549,6 @@ module Ssa {
551549
final Callable getCallable() { result = this.getBasicBlock().getEnclosingCallable() }
552550

553551
override Element getElement() { result = this.getCallable() }
554-
555-
override string toString() {
556-
if this.getSourceVariable().getAssignable() instanceof LocalScopeVariable
557-
then result = "SSA capture def(" + this.getSourceVariable() + ")"
558-
else result = "SSA entry def(" + this.getSourceVariable() + ")"
559-
}
560552
}
561553

562554
/**
@@ -590,10 +582,6 @@ module Ssa {
590582

591583
/** Gets the parameter that this entry definition represents. */
592584
Parameter getParameter() { result = p }
593-
594-
override string toString() {
595-
result = "SSA param_default(" + pragma[only_bind_out](this.getParameter()) + ")"
596-
}
597585
}
598586

599587
/**
@@ -687,8 +675,6 @@ module Ssa {
687675
predicate hasInputFromBlock(Definition inp, BasicBlock bb) {
688676
inp = SsaImpl::phiHasInputFromBlock(this, bb)
689677
}
690-
691-
override string toString() { result = "SSA phi(" + this.getSourceVariable() + ")" }
692678
}
693679

694680
/**

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ module Ssa_ = Impl::MakeSsa<SsaInput>;
7878

7979
class Definition = Impl::Definition;
8080

81+
private class SsaDefinitionToStringProxy extends Definition {
82+
override string toString() { result = this.(SsaDefinition).toString() }
83+
}
84+
8185
deprecated class WriteDefinition = Impl::WriteDefinition;
8286

8387
deprecated class UncertainWriteDefinition = Impl::UncertainWriteDefinition;

shared/ssa/codeql/ssa/Ssa.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ module Make<
10541054
/** A static single assignment (SSA) definition. */
10551055
class SsaDefinition extends FinalDefinition {
10561056
/** Gets a textual representation of this SSA definition. */
1057-
string toString() { result = super.toString() }
1057+
string toString() { result = "SSA def(" + this.getSourceVariable() + ")" }
10581058

10591059
/**
10601060
* Gets the control flow node of this SSA definition.
@@ -1207,6 +1207,8 @@ module Make<
12071207
* a phi definition for `x` is inserted just before the call `puts x`.
12081208
*/
12091209
class SsaPhiDefinition extends SsaDefinition instanceof PhiNode {
1210+
override string toString() { result = "SSA phi(" + this.getSourceVariable() + ")" }
1211+
12101212
/** Holds if `inp` is an input to this phi definition along the edge originating in `bb`. */
12111213
predicate hasInputFromBlock(SsaDefinition inp, BasicBlock bb) {
12121214
phiHasInputFromBlockCached(this, inp, bb)

0 commit comments

Comments
 (0)