mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 562343 - Handle empty loop body when creating ExecFor
Change-Id: I11c07800d493b0a64681531a1d4719c17206dd19
This commit is contained in:
parent
d36ed7cfd5
commit
d4082abb67
2 changed files with 9 additions and 1 deletions
|
@ -16,6 +16,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
|
@ -27,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.DestructorCallCollector;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExecCompoundStatement;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExecFor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExecSimpleDeclaration;
|
||||
|
||||
|
@ -252,7 +255,8 @@ public class CPPASTForStatement extends CPPASTAttributeOwner implements ICPPASTF
|
|||
: null;
|
||||
ICPPASTExpression iterationExpr = (ICPPASTExpression) getIterationExpression();
|
||||
ICPPEvaluation iterationEval = iterationExpr != null ? iterationExpr.getEvaluation() : null;
|
||||
ICPPExecution bodyExec = EvalUtil.getExecutionFromStatement(getBody());
|
||||
ICPPExecution bodyExec = Optional.ofNullable(getBody()).map(EvalUtil::getExecutionFromStatement)
|
||||
.orElseGet(() -> new ExecCompoundStatement());
|
||||
return new ExecFor(initializerExec, conditionExprEval, conditionDeclExec, iterationEval, bodyExec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@ import org.eclipse.core.runtime.CoreException;
|
|||
public class ExecCompoundStatement implements ICPPExecution {
|
||||
private ICPPExecution[] executions;
|
||||
|
||||
public ExecCompoundStatement() {
|
||||
this(new IASTStatement[] {});
|
||||
}
|
||||
|
||||
private ExecCompoundStatement(ICPPExecution[] executions) {
|
||||
this.executions = executions;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue