Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2014-08-14 20:56:53 +0000
committerSergey Prigogin2014-08-14 21:50:36 +0000
commitd87c480f476eb3333327338f8863a64bf428aa36 (patch)
treeff7144d7f04bf3bdb7309051506c2f68e0438570
parent63053a556c64c8cac91679a0936d5bcf9d1feedf (diff)
downloadorg.eclipse.cdt-d87c480f476eb3333327338f8863a64bf428aa36.tar.gz
org.eclipse.cdt-d87c480f476eb3333327338f8863a64bf428aa36.tar.xz
org.eclipse.cdt-d87c480f476eb3333327338f8863a64bf428aa36.zip
Proper reporting of unsupported statement types.
Change-Id: I4e4745bf7661329873107e8849f6200577756891 Reviewed-on: https://git.eclipse.org/r/31725 Tested-by: Hudson CI Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java19
-rw-r--r--codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/Messages.java25
-rw-r--r--codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/Messages.properties12
3 files changed, 52 insertions, 4 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 139b4af08b2..82c004ab60d 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
@@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import org.eclipse.cdt.codan.core.cxx.Activator;
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;
@@ -54,8 +55,10 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
import org.eclipse.cdt.internal.core.dom.parser.Value;
+import org.eclipse.osgi.util.NLS;
/**
* This class creates C control flow graph
@@ -154,6 +157,8 @@ public class ControlFlowGraphBuilder {
return createWhile(prev, (IASTWhileStatement) body);
} else if (body instanceof IASTForStatement) {
return createFor(prev, (IASTForStatement) body);
+ } else if (body instanceof ICPPASTRangeBasedForStatement) {
+ return createRangeBasedFor(prev, (ICPPASTRangeBasedForStatement) body);
} else if (body instanceof IASTDoStatement) {
return createDoWhile(prev, (IASTDoStatement) body);
} else if (body instanceof IASTReturnStatement) {
@@ -199,7 +204,6 @@ public class ControlFlowGraphBuilder {
addOutgoing(prev, gotoNode);
return gotoNode;
} else if (body instanceof IASTProblemStatement) {
- // System.err.println("problem");
CxxPlainNode node = factory.createPlainNode(body);
addOutgoing(prev, node);
return node;
@@ -208,7 +212,8 @@ public class ControlFlowGraphBuilder {
} else if (body instanceof ICPPASTTryBlockStatement) {
return createTry(prev, (ICPPASTTryBlockStatement) body);
} else {
- System.err.println("unknown statement for cfg: " + body); //$NON-NLS-1$
+ Activator.log(NLS.bind(Messages.ControlFlowGraphBuilder_unsupported_statement_type,
+ body.getClass().getSimpleName()));
}
return prev;
}
@@ -377,6 +382,11 @@ public class ControlFlowGraphBuilder {
return nBreak;
}
+ private IBasicBlock createRangeBasedFor(IBasicBlock prev, ICPPASTRangeBasedForStatement forNode) {
+ // TODO(Alena Laskavaia): Implement proper graph.
+ return createSubGraph(prev, forNode.getBody());
+ }
+
protected IBasicBlock createWhile(IBasicBlock prev, IASTWhileStatement body) {
// Add continue connector
IConnectorNode nContinue = factory.createConnectorNode();
@@ -492,8 +502,9 @@ public class ControlFlowGraphBuilder {
if (ast instanceof IASTExpression) {
IValue dvalue = Value.create((IASTExpression) ast, 5);
Long numericalValue = dvalue.numericalValue();
- if (numericalValue==null) return false;
- return (numericalValue==testvalue);
+ if (numericalValue == null)
+ return false;
+ return numericalValue == testvalue;
}
}
return false;
diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/Messages.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/Messages.java
new file mode 100644
index 00000000000..1b5aa242f6e
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/Messages.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.core.cxx.internal.model.cfg;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+ public static String ControlFlowGraphBuilder_unsupported_statement_type;
+
+ private Messages() {
+ // Do not instantiate
+ }
+
+ static {
+ NLS.initializeMessages(Messages.class.getName(), Messages.class);
+ }
+} \ No newline at end of file
diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/Messages.properties b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/Messages.properties
new file mode 100644
index 00000000000..aa32732507c
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/Messages.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2013 Google, Inc and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Sergey Prigogin (Google) - initial API and implementation
+###############################################################################
+
+ControlFlowGraphBuilder_unsupported_statement_type=Unsupported statement type: {0}.

Back to the top