Browse Source

Handled possible null statement in control flow graph builder.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
31ec3a6c74
  1. 11
      ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs

11
ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs

@ -408,10 +408,15 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
bool? cond = ifElseStatement.Condition.IsNull ? true : builder.EvaluateCondition(ifElseStatement.Condition); bool? cond = ifElseStatement.Condition.IsNull ? true : builder.EvaluateCondition(ifElseStatement.Condition);
if (ifElseStatement.TrueStatement.IsNull) if (ifElseStatement.TrueStatement.IsNull)
return data; return data;
ControlFlowNode trueBegin = builder.CreateStartNode(ifElseStatement.TrueStatement); ControlFlowNode trueBegin;
if (cond != false) if (ifElseStatement.TrueStatement.IsNull) {
trueBegin = null;
} else {
trueBegin = builder.CreateStartNode(ifElseStatement.TrueStatement);
}
if (cond != false && trueBegin != null)
Connect(data, trueBegin, ControlFlowEdgeType.ConditionTrue); Connect(data, trueBegin, ControlFlowEdgeType.ConditionTrue);
ControlFlowNode trueEnd = ifElseStatement.TrueStatement.AcceptVisitor(this, trueBegin); ControlFlowNode trueEnd = trueBegin != null ? ifElseStatement.TrueStatement.AcceptVisitor(this, trueBegin) : null;
ControlFlowNode falseEnd; ControlFlowNode falseEnd;
if (ifElseStatement.FalseStatement.IsNull) { if (ifElseStatement.FalseStatement.IsNull) {
falseEnd = null; falseEnd = null;

Loading…
Cancel
Save