本文整理汇总了C++中Sema::ActOnDeclStmt方法的典型用法代码示例。如果您正苦于以下问题:C++ Sema::ActOnDeclStmt方法的具体用法?C++ Sema::ActOnDeclStmt怎么用?C++ Sema::ActOnDeclStmt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sema
的用法示例。
在下文中一共展示了Sema::ActOnDeclStmt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VisitCompoundStmt
bool VisitCompoundStmt(CompoundStmt* CS) {
for(CompoundStmt::body_iterator I = CS->body_begin(), E = CS->body_end();
I != E; ++I) {
if (!isa<BinaryOperator>(*I))
continue;
const BinaryOperator* BinOp = cast<BinaryOperator>(*I);
if (isAutoCandidate(BinOp)) {
ASTContext& C = m_Sema->getASTContext();
VarDecl* VD
= cast<VarDecl>(cast<DeclRefExpr>(BinOp->getLHS())->getDecl());
TypeSourceInfo* ResTSI = 0;
TypeSourceInfo* TrivialTSI
= C.getTrivialTypeSourceInfo(VD->getType());
Expr* RHS = BinOp->getRHS();
m_Sema->DeduceAutoType(TrivialTSI, RHS, ResTSI);
VD->setTypeSourceInfo(ResTSI);
VD->setType(ResTSI->getType());
VD->setInit(RHS);
Sema::DeclGroupPtrTy VDPtrTy = m_Sema->ConvertDeclToDeclGroup(VD);
// Transform the AST into a "sane" state. Replace the binary operator
// with decl stmt, because the binop semantically is a decl with init.
StmtResult DS = m_Sema->ActOnDeclStmt(VDPtrTy, BinOp->getLocStart(),
BinOp->getLocEnd());
assert(!DS.isInvalid() && "Invalid DeclStmt.");
*I = DS.take();
}
}
return true; // returning false will abort the in-depth traversal.
}
示例2: Fix
void Fix(CompoundStmt* CS) {
if (!CS->size())
return;
typedef llvm::SmallVector<Stmt*, 32> Statements;
Statements Stmts;
Stmts.append(CS->body_begin(), CS->body_end());
for (Statements::iterator I = Stmts.begin(); I != Stmts.end(); ++I) {
if (!TraverseStmt(*I) && !m_HandledDecls.count(m_FoundDRE->getDecl())) {
Sema::DeclGroupPtrTy VDPtrTy
= m_Sema->ConvertDeclToDeclGroup(m_FoundDRE->getDecl());
StmtResult DS = m_Sema->ActOnDeclStmt(VDPtrTy,
m_FoundDRE->getLocStart(),
m_FoundDRE->getLocEnd());
assert(!DS.isInvalid() && "Invalid DeclStmt.");
I = Stmts.insert(I, DS.take());
m_HandledDecls.insert(m_FoundDRE->getDecl());
}
}
CS->setStmts(m_Sema->getASTContext(), Stmts.data(), Stmts.size());
}