mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
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>
This commit is contained in:
parent
63053a556c
commit
d87c480f47
3 changed files with 52 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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}.
|
Loading…
Add table
Reference in a new issue