Skip to content

Commit 95f2622

Browse files
committed
WI #2045 better handling 1 branch in multi branch case.
1 parent 7e780a9 commit 95f2622

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

TypeCobol.Analysis.Test/BasicCfgInstrs/Declaratives1.int

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ Leaving block : 4
7171
=======
7272
METRICS
7373
=======
74-
{EdgeCount=28; NodeCount=24; ControlSubgraphCount=1; HighCyclomaticComplexity=6; HighEssentialComplexityPath=5}
74+
{EdgeCount=27; NodeCount=24; ControlSubgraphCount=1; HighCyclomaticComplexity=5; HighEssentialComplexityPath=4}

TypeCobol.Analysis/Graph/CfgAbstractInterpretation.Environment.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,16 @@ protected virtual void Run(BasicBlock<N, D> startBlock, BasicBlock<N, D> stopBlo
9898
}
9999
else
100100
{
101-
DFSStack.Push(nextFlowBlock);
101+
DFSStack.Push(nextFlowBlock);
102+
// If the multi branch context instruction has a successor
103+
// to the next flow block, add one edge.
104+
foreach (var edge in block.SuccessorEdges)
105+
{
106+
if (Cfg.SuccessorEdges[edge] == nextFlowBlock)
107+
{
108+
Metrics.EdgeCount++;
109+
}
110+
}
102111
}
103112
}
104113
}
@@ -184,8 +193,6 @@ private BasicBlock<N, D> InterpretContext(BasicBlock<N, D> block)
184193
Metrics.EdgeCount++;
185194
Run(CheckRelocatedBlock(block.Context, b), CheckRelocatedBlock(block.Context, block.Context.NextFlowBlock));
186195
}
187-
// Special case exemple IF THEN Without and ELSE => add virtual else to next block
188-
Metrics.EdgeCount += block.Context.Branches.Count == 1 ? 1 : 0;
189196
}
190197

191198
System.Diagnostics.Debug.Assert(this.InterpretationStack.Count > 0 &&

0 commit comments

Comments
 (0)