mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 20:05:35 +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.IBranchNode;
|
||||||
import org.eclipse.cdt.codan.core.model.cfg.ICfgData;
|
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.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.IExitNode;
|
||||||
import org.eclipse.cdt.codan.core.model.cfg.IJumpNode;
|
import org.eclipse.cdt.codan.core.model.cfg.IJumpNode;
|
||||||
import org.eclipse.cdt.codan.core.model.cfg.IPlainNode;
|
import org.eclipse.cdt.codan.core.model.cfg.IPlainNode;
|
||||||
|
@ -191,10 +192,11 @@ public class ControlFlowGraphBuilder {
|
||||||
ICPPASTCatchHandler[] catchHandlers = body.getCatchHandlers();
|
ICPPASTCatchHandler[] catchHandlers = body.getCatchHandlers();
|
||||||
for (int i = 0; i < catchHandlers.length; i++) {
|
for (int i = 0; i < catchHandlers.length; i++) {
|
||||||
ICPPASTCatchHandler handler = catchHandlers[i];
|
ICPPASTCatchHandler handler = catchHandlers[i];
|
||||||
IBranchNode handlerNode = factory
|
IBranchNode handlerNode = factory.createBranchNode(handler
|
||||||
.createBranchNode(handler.getDeclaration());
|
.getDeclaration());
|
||||||
addOutgoing(ifNode, handlerNode);
|
addOutgoing(ifNode, handlerNode);
|
||||||
IBasicBlock els = createSubGraph(handlerNode, handler.getCatchBody());
|
IBasicBlock els = createSubGraph(handlerNode,
|
||||||
|
handler.getCatchBody());
|
||||||
addJump(els, mergeNode);
|
addJump(els, mergeNode);
|
||||||
}
|
}
|
||||||
return mergeNode;
|
return mergeNode;
|
||||||
|
@ -483,6 +485,10 @@ public class ControlFlowGraphBuilder {
|
||||||
dead.add(node);
|
dead.add(node);
|
||||||
return;
|
return;
|
||||||
} else if (prev instanceof ICfgData) {
|
} else if (prev instanceof ICfgData) {
|
||||||
|
if (prev instanceof IDecisionNode && !(node instanceof IBranchNode)) {
|
||||||
|
dead.add(node);
|
||||||
|
return;
|
||||||
|
}
|
||||||
((AbstractBasicBlock) prev).addOutgoing(node);
|
((AbstractBasicBlock) prev).addOutgoing(node);
|
||||||
}
|
}
|
||||||
if (!(node instanceof IStartNode))
|
if (!(node instanceof IStartNode))
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.eclipse.cdt.codan.ui.cfgview.views;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
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.ControlFlowGraphBuilder;
|
||||||
import org.eclipse.cdt.codan.core.cxx.internal.model.cfg.CxxControlFlowGraph;
|
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 action1;
|
||||||
private Action doubleClickAction;
|
private Action doubleClickAction;
|
||||||
|
|
||||||
|
class DeadNodes extends ArrayList<IBasicBlock> {}
|
||||||
class ViewContentProvider implements IStructuredContentProvider,
|
class ViewContentProvider implements IStructuredContentProvider,
|
||||||
ITreeContentProvider {
|
ITreeContentProvider {
|
||||||
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
|
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
|
||||||
|
@ -118,7 +120,16 @@ public class ControlFlowGraphView extends ViewPart {
|
||||||
Collection<IBasicBlock> blocks = getFlat(
|
Collection<IBasicBlock> blocks = getFlat(
|
||||||
((IControlFlowGraph) parent).getStartNode(),
|
((IControlFlowGraph) parent).getStartNode(),
|
||||||
new ArrayList<IBasicBlock>());
|
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) {
|
} else if (parent instanceof IDecisionNode) {
|
||||||
ArrayList blocks = new ArrayList();
|
ArrayList blocks = new ArrayList();
|
||||||
IBasicBlock[] outgoingNodes = ((IDecisionNode) parent)
|
IBasicBlock[] outgoingNodes = ((IDecisionNode) parent)
|
||||||
|
|
Loading…
Add table
Reference in a new issue