ASTNodeInfo EvaluateTSynthesizer::VisitCompoundStmt(CompoundStmt* Node) { ++m_NestedCompoundStmts; ASTNodes Children; ASTNodes NewChildren; if (GetChildren(Children, Node)) { ASTNodes::iterator it; for (it = Children.begin(); it != Children.end(); ++it) { ASTNodeInfo NewNode = Visit(*it); if (!NewNode.hasSingleNode()) { ASTNodes& NewStmts(NewNode.getNodes()); for(unsigned i = 0; i < NewStmts.size(); ++i) NewChildren.push_back(NewStmts[i]); Node->setStmts(*m_Context, NewChildren.data(), NewChildren.size()); // Resolve all 1:n replacements Visit(Node); } else { if (NewNode.isForReplacement()) { if (Expr* E = NewNode.getAs<Expr>()) { // Check whether value printer has been requested bool valuePrinterReq = false; // If this was the last or the last is not null stmt, means that // we need to value print. // If this is in a wrapper function's body then look for VP. if (FunctionDecl* FD = dyn_cast<FunctionDecl>(m_CurDeclContext)) valuePrinterReq = m_NestedCompoundStmts < 2 && utils::Analyze::IsWrapper(FD) && ((it+1) == Children.end() || ((it+2) == Children.end() && !isa<NullStmt>(*(it+1)))); // Assume void if still not escaped NewChildren.push_back(SubstituteUnknownSymbol(m_Context->VoidTy,E, valuePrinterReq)); } } else NewChildren.push_back(*it); } } } Node->setStmts(*m_Context, NewChildren.data(), NewChildren.size()); --m_NestedCompoundStmts; return ASTNodeInfo(Node, 0); }
bool EvaluateTSynthesizer::GetChildren(ASTNodes& Children, Stmt* Node) { if (std::distance(Node->child_begin(), Node->child_end()) < 1) return false; for (Stmt::child_iterator I = Node->child_begin(), E = Node->child_end(); I != E; ++I) { Children.push_back(*I); } return true; }
ASTNodeInfo EvaluateTSynthesizer::VisitCompoundStmt(CompoundStmt* Node) { ASTNodes Children; ASTNodes NewChildren; if (GetChildren(Children, Node)) { ASTNodes::iterator it; for (it = Children.begin(); it != Children.end(); ++it) { ASTNodeInfo NewNode = Visit(*it); if (!NewNode.hasSingleNode()) { ASTNodes& NewStmts(NewNode.getNodes()); for(unsigned i = 0; i < NewStmts.size(); ++i) NewChildren.push_back(NewStmts[i]); Node->setStmts(*m_Context, NewChildren.data(), NewChildren.size()); // Resolve all 1:n replacements Visit(Node); } else { if (NewNode.isForReplacement()) { if (Expr* E = NewNode.getAs<Expr>()) { // Check whether value printer has been requested bool valuePrinterReq = false; if ((it+1) == Children.end() || !isa<NullStmt>(*(it+1))) valuePrinterReq = true; // Assume void if still not escaped NewChildren.push_back(SubstituteUnknownSymbol(m_Context->VoidTy,E, valuePrinterReq)); } } else NewChildren.push_back(*it); } } } Node->setStmts(*m_Context, NewChildren.data(), NewChildren.size()); return ASTNodeInfo(Node, 0); }