From Vassil: substitute then / else (ROOT-6345).

VisitCompoundStmt correctly substitutes the child Stmts. When calling Visit()
on a Stmt, this substitution needs to be carried out by the caller: only
it knows what target type to request. This fixes the issue for if statements
which do not fall back to VisitStmt() because of the conditional being of bool
type. In principle we are still missing do / while statements, too - again due
to the conditional part.
This commit is contained in:
Axel Naumann 2014-06-13 10:43:56 +02:00 committed by sftnight
parent a57c866b3d
commit cea02a82e7

View File

@ -287,11 +287,19 @@ namespace cling {
//return ASTNodeInfo(Node, /*needs eval*/false);
}
// Visit the other parts - they will fall naturally into Stmt or
// CompoundStmt where we know what to do.
Visit(Node->getThen());
if (Stmt* ElseExpr = Node->getElse())
Visit(ElseExpr);
// Visit the other parts - they will fall naturally into CompoundStmt
// where we know what to do. For Stmt, though, we need to substitute here,
// knowing the "target" type.
ASTNodeInfo thenInfo = Visit(Node->getThen());
if (thenInfo.isForReplacement())
Node->setThen(SubstituteUnknownSymbol(m_Context->VoidTy,
thenInfo.getAs<Expr>()));
if (Stmt* ElseExpr = Node->getElse()) {
ASTNodeInfo elseInfo = Visit(ElseExpr);
if (elseInfo.isForReplacement())
Node->setElse(SubstituteUnknownSymbol(m_Context->VoidTy,
elseInfo.getAs<Expr>()));
}
return ASTNodeInfo(Node, false);
}
@ -564,7 +572,7 @@ namespace cling {
ASTNodeInfo EvaluateTSynthesizer::VisitCallExpr(CallExpr* E) {
// FIXME: Maybe we need to handle the arguments
// ASTNodeInfo NewNode = Visit(E->getCallee());
//ASTNodeInfo NewNode = Visit(E->getCallee());
return ASTNodeInfo (E, IsArtificiallyDependent(E));
}