mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 335909 - Exception in switch statement
This commit is contained in:
parent
746c7f5b5c
commit
aadbf2a477
2 changed files with 21 additions and 4 deletions
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.codan.core.model.cfg.IBasicBlock;
|
|||
import org.eclipse.cdt.codan.core.model.cfg.IBranchNode;
|
||||
import org.eclipse.cdt.codan.core.model.cfg.ICfgData;
|
||||
import org.eclipse.cdt.codan.core.model.cfg.IConnectorNode;
|
||||
import org.eclipse.cdt.codan.core.model.cfg.IDecisionNode;
|
||||
import org.eclipse.cdt.codan.core.model.cfg.IExitNode;
|
||||
import org.eclipse.cdt.codan.core.model.cfg.IJumpNode;
|
||||
import org.eclipse.cdt.codan.core.model.cfg.IPlainNode;
|
||||
|
@ -191,10 +192,11 @@ public class ControlFlowGraphBuilder {
|
|||
ICPPASTCatchHandler[] catchHandlers = body.getCatchHandlers();
|
||||
for (int i = 0; i < catchHandlers.length; i++) {
|
||||
ICPPASTCatchHandler handler = catchHandlers[i];
|
||||
IBranchNode handlerNode = factory
|
||||
.createBranchNode(handler.getDeclaration());
|
||||
IBranchNode handlerNode = factory.createBranchNode(handler
|
||||
.getDeclaration());
|
||||
addOutgoing(ifNode, handlerNode);
|
||||
IBasicBlock els = createSubGraph(handlerNode, handler.getCatchBody());
|
||||
IBasicBlock els = createSubGraph(handlerNode,
|
||||
handler.getCatchBody());
|
||||
addJump(els, mergeNode);
|
||||
}
|
||||
return mergeNode;
|
||||
|
@ -483,6 +485,10 @@ public class ControlFlowGraphBuilder {
|
|||
dead.add(node);
|
||||
return;
|
||||
} else if (prev instanceof ICfgData) {
|
||||
if (prev instanceof IDecisionNode && !(node instanceof IBranchNode)) {
|
||||
dead.add(node);
|
||||
return;
|
||||
}
|
||||
((AbstractBasicBlock) prev).addOutgoing(node);
|
||||
}
|
||||
if (!(node instanceof IStartNode))
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.eclipse.cdt.codan.ui.cfgview.views;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.codan.core.cxx.internal.model.cfg.ControlFlowGraphBuilder;
|
||||
import org.eclipse.cdt.codan.core.cxx.internal.model.cfg.CxxControlFlowGraph;
|
||||
|
@ -95,6 +96,7 @@ public class ControlFlowGraphView extends ViewPart {
|
|||
private Action action1;
|
||||
private Action doubleClickAction;
|
||||
|
||||
class DeadNodes extends ArrayList<IBasicBlock> {}
|
||||
class ViewContentProvider implements IStructuredContentProvider,
|
||||
ITreeContentProvider {
|
||||
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
|
||||
|
@ -118,7 +120,16 @@ public class ControlFlowGraphView extends ViewPart {
|
|||
Collection<IBasicBlock> blocks = getFlat(
|
||||
((IControlFlowGraph) parent).getStartNode(),
|
||||
new ArrayList<IBasicBlock>());
|
||||
return blocks.toArray();
|
||||
DeadNodes dead = new DeadNodes();
|
||||
Iterator<IBasicBlock> iter = ((IControlFlowGraph) parent).getUnconnectedNodeIterator();
|
||||
for (; iter.hasNext();) {
|
||||
IBasicBlock iBasicBlock = (IBasicBlock) iter.next();
|
||||
dead.add(iBasicBlock);
|
||||
}
|
||||
ArrayList all = new ArrayList();
|
||||
all.addAll(blocks);
|
||||
if (dead.size()>0) all.add(dead);
|
||||
return all.toArray();
|
||||
} else if (parent instanceof IDecisionNode) {
|
||||
ArrayList blocks = new ArrayList();
|
||||
IBasicBlock[] outgoingNodes = ((IDecisionNode) parent)
|
||||
|
|
Loading…
Add table
Reference in a new issue