Ejemplo n.º 1
0
 FunctionDecl * GetLivenessFunction() {
     IdentifierInfo & II = Context->Idents.get(livenessfunction);
     DeclarationName N = Context->DeclarationNames.getIdentifier(&II);
     #if LLVM_VERSION >= 33
     QualType T = Context->getFunctionType(Context->VoidTy, outputtypes, FunctionProtoType::ExtProtoInfo());
     #else
     QualType T = Context->getFunctionType(Context->VoidTy, &outputtypes[0],outputtypes.size(), FunctionProtoType::ExtProtoInfo());
     #endif
     FunctionDecl * F = FunctionDecl::Create(*Context, Context->getTranslationUnitDecl(), SourceLocation(), SourceLocation(), N,T, 0, SC_Extern);
     
     std::vector<ParmVarDecl *> params;
     for(size_t i = 0; i < outputtypes.size(); i++) {
         params.push_back(ParmVarDecl::Create(*Context, F, SourceLocation(), SourceLocation(), 0, outputtypes[i], /*TInfo=*/0, SC_None,
         #if LLVM_VERSION <= 32
         SC_None,
         #endif
         0));
     }
     F->setParams(params);
     #if LLVM_VERSION >= 33
     CompoundStmt * stmts = new (*Context) CompoundStmt(*Context, outputstmts, SourceLocation(), SourceLocation());
     #else
     CompoundStmt * stmts = new (*Context) CompoundStmt(*Context, &outputstmts[0], outputstmts.size(), SourceLocation(), SourceLocation());
     #endif
     F->setBody(stmts);
     return F;
 }
  void NullDerefProtectionTransformer::Transform() {
    FunctionDecl* FD = getTransaction()->getWrapperFD();
    if (!FD)
      return;

    CompoundStmt* CS = dyn_cast<CompoundStmt>(FD->getBody());
    assert(CS && "Function body not a CompundStmt?");
    IfStmtInjector injector((*m_Sema));
    CompoundStmt* newCS = injector.Inject(CS);
    FD->setBody(newCS);
  }
Ejemplo n.º 3
0
void C2Sema::ActOnFinishFunctionBody(Decl* decl, Stmt* body) {
    FunctionDecl* func = cast<FunctionDecl>(decl);
    CompoundStmt* C = cast<CompoundStmt>(body);
    func->setBody(C);
}