Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2014-12-12 23:37:42 -0500
committerElena Laskavaia2014-12-14 13:09:13 -0500
commit24d2e1a4c8cbe3dc18cc71b1726e6c90b3bd0b36 (patch)
tree62aa68dc44b5410ad38fa7ea4693b140acd18bd5 /codan/org.eclipse.cdt.codan.core
parentc4ea834fd69069cd76263bd92b256bf93e50d166 (diff)
downloadorg.eclipse.cdt-24d2e1a4c8cbe3dc18cc71b1726e6c90b3bd0b36.tar.gz
org.eclipse.cdt-24d2e1a4c8cbe3dc18cc71b1726e6c90b3bd0b36.tar.xz
org.eclipse.cdt-24d2e1a4c8cbe3dc18cc71b1726e6c90b3bd0b36.zip
Bug 447486 - codan - CCE is thrown by control flow graph builder
- addOutgoing cannot join JumpNode - block will be added to dead list instead - addjusted goto code to not use addOutgoing but using setJump directly - corrected code that doing fake return to deal jump nodes at the end - corrected code that marks up dead code to remove jump targets - corrected code that calculates all nodes in the graph to take into account dangling labels - fixed CFG viewer to show unconnected labeled statements Change-Id: Ie4d9e37678e3ebaae8e9f268e6f37342e14a1444 Reviewed-on: https://git.eclipse.org/r/38189 Tested-by: Hudson CI Reviewed-by: Elena Laskavaia <elaskavaia.cdt@gmail.com>
Diffstat (limited to 'codan/org.eclipse.cdt.codan.core')
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java6
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java12
2 files changed, 11 insertions, 7 deletions
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java
index 571372cc0e..c35b1f1f66 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java
@@ -15,7 +15,7 @@ import org.eclipse.cdt.codan.core.model.cfg.ISingleIncoming;
/**
* Abstract node with one incoming arc (node)
- *
+ *
*/
public abstract class AbstractSingleIncomingNode extends AbstractBasicBlock implements ISingleIncoming {
private IBasicBlock prev;
@@ -34,7 +34,7 @@ public abstract class AbstractSingleIncomingNode extends AbstractBasicBlock impl
@Override
public int getIncomingSize() {
- return 1;
+ return prev!=null?1:0;
}
@Override
@@ -44,7 +44,7 @@ public abstract class AbstractSingleIncomingNode extends AbstractBasicBlock impl
/**
* Sets the incoming node
- *
+ *
* @param prev
*/
public void setIncoming(IBasicBlock prev) {
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java
index c6d7003038..059c83f5a2 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java
@@ -142,10 +142,14 @@ public class ControlFlowGraph implements IControlFlowGraph {
if (result.contains(start))
return;
result.add(start);
- IBasicBlock[] outgoingNodes = start.getOutgoingNodes();
- for (int i = 0; i < outgoingNodes.length; i++) {
- IBasicBlock b = outgoingNodes[i];
- getNodes(b, result);
+ for (IBasicBlock bb : start.getOutgoingNodes()) {
+ getNodes(bb, result);
+ }
+ if (start instanceof IConnectorNode) {
+ // special case where connect can have some incoming branch nodes not in the graph
+ for (IBasicBlock bb : start.getIncomingNodes()) {
+ getNodes(bb, result);
+ }
}
}
}

Back to the top