diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java index f737015c20d..07aea511da1 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java @@ -146,14 +146,11 @@ public class ControlFlowGraphBuilder { return node; } - private IBasicBlock createSubGraph(IBasicBlock prev, IASTNode body) { + private IBasicBlock createSubGraph(IBasicBlock prev, IASTStatement body) { if (body instanceof IASTCompoundStatement) { IASTCompoundStatement comp = (IASTCompoundStatement) body; - IASTNode[] children = comp.getChildren(); - for (int i = 0; i < children.length; i++) { - IASTNode node = children[i]; - IBasicBlock last = createSubGraph(prev, node); - prev = last; + for (IASTStatement statement : comp.getStatements()) { + prev = createSubGraph(prev, statement); } } else if (body instanceof IASTExpressionStatement || body instanceof IASTDeclarationStatement || body instanceof IASTNullStatement) { if (isThrowStatement(body) || isExitStatement(body)) { @@ -327,20 +324,17 @@ public class ControlFlowGraphBuilder { return conn; } - private void createSwitchBody(DecisionNode switchNode, IConnectorNode mergeNode, IASTStatement body) { + private void createSwitchBody(IDecisionNode switchNode, IConnectorNode mergeNode, IASTStatement body) { if (!(body instanceof IASTCompoundStatement)) return; // bad IASTCompoundStatement comp = (IASTCompoundStatement) body; - IASTNode[] children = comp.getChildren(); IBasicBlock prev = switchNode; - for (int i = 0; i < children.length; i++) { - IASTNode elem = children[i]; - if (elem instanceof IASTCaseStatement || elem instanceof IASTDefaultStatement) { + for (IASTStatement statement : comp.getStatements()) { + if (statement instanceof IASTCaseStatement || statement instanceof IASTDefaultStatement) { IBranchNode lbl = null; - if (elem instanceof IASTCaseStatement) { - IASTCaseStatement caseSt = (IASTCaseStatement) elem; - lbl = factory.createBranchNode(caseSt); - } else if (elem instanceof IASTDefaultStatement) { + if (statement instanceof IASTCaseStatement) { + lbl = factory.createBranchNode(statement); + } else if (statement instanceof IASTDefaultStatement) { lbl = factory.createBranchNode(IBranchNode.DEFAULT); } if (!(prev instanceof IExitNode) && prev != switchNode) { @@ -354,12 +348,11 @@ public class ControlFlowGraphBuilder { addOutgoing(switchNode, lbl); continue; } - if (elem instanceof IASTBreakStatement) { + if (statement instanceof IASTBreakStatement) { prev = addJump(prev, mergeNode); continue; } - IBasicBlock last = createSubGraph(prev, elem); - prev = last; + prev = createSubGraph(prev, statement); } addJump(prev, mergeNode); }