Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2015-02-17 06:51:57 +0000
committerAlena Laskavaia2015-02-19 00:08:59 +0000
commit3586267e6b0f97d0787aa143c0e6e2ab5b5e70be (patch)
tree065edb0b1ec35c727830da3f642b82bd76d13e52 /codan/org.eclipse.cdt.codan.core.cxx
parent340b507e381a07ecfa3152f1e2d935849c1ad9bc (diff)
downloadorg.eclipse.cdt-3586267e6b0f97d0787aa143c0e6e2ab5b5e70be.tar.gz
org.eclipse.cdt-3586267e6b0f97d0787aa143c0e6e2ab5b5e70be.tar.xz
org.eclipse.cdt-3586267e6b0f97d0787aa143c0e6e2ab5b5e70be.zip
Bug 455828 - Proper handling of 'break' inside compound statement in a
case of a switch Change-Id: I73329a8769bc20a4fc4e017faad627e03adce9d9 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
Diffstat (limited to 'codan/org.eclipse.cdt.codan.core.cxx')
-rw-r--r--codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java46
1 files changed, 24 insertions, 22 deletions
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 8e3094593a7..f158c645f18 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
@@ -336,30 +336,32 @@ public class ControlFlowGraphBuilder {
return; // bad
IASTCompoundStatement comp = (IASTCompoundStatement) body;
IBasicBlock prev = switchNode;
- for (IASTStatement statement : comp.getStatements()) {
- if (statement instanceof IASTCaseStatement || statement instanceof IASTDefaultStatement) {
- IBranchNode lbl = null;
- if (statement instanceof IASTCaseStatement) {
- lbl = factory.createBranchNode(statement);
- } else if (statement instanceof IASTDefaultStatement) {
- lbl = factory.createBranchNode(IBranchNode.DEFAULT);
- }
- if (!(prev instanceof IExitNode) && prev != switchNode) {
- IConnectorNode here = factory.createConnectorNode();
- addJump(prev, here);
- addOutgoing(lbl, here);
- prev = here;
- } else {
- prev = lbl;
+ IConnectorNode savedBreak = outerBreak;
+ outerBreak = mergeNode;
+ try {
+ for (IASTStatement statement : comp.getStatements()) {
+ if (statement instanceof IASTCaseStatement || statement instanceof IASTDefaultStatement) {
+ IBranchNode lbl = null;
+ if (statement instanceof IASTCaseStatement) {
+ lbl = factory.createBranchNode(statement);
+ } else if (statement instanceof IASTDefaultStatement) {
+ lbl = factory.createBranchNode(IBranchNode.DEFAULT);
+ }
+ if (!(prev instanceof IExitNode) && prev != switchNode) {
+ IConnectorNode here = factory.createConnectorNode();
+ addJump(prev, here);
+ addOutgoing(lbl, here);
+ prev = here;
+ } else {
+ prev = lbl;
+ }
+ addOutgoing(switchNode, lbl);
+ continue;
}
- addOutgoing(switchNode, lbl);
- continue;
- }
- if (statement instanceof IASTBreakStatement) {
- prev = addJump(prev, mergeNode);
- continue;
+ prev = createSubGraph(prev, statement);
}
- prev = createSubGraph(prev, statement);
+ } finally {
+ outerBreak = savedBreak;
}
addJump(prev, mergeNode);
}

Back to the top