当前位置: 首页>>代码示例>>C++>>正文


C++ llvm::OwningPtr类代码示例

本文整理汇总了C++中llvm::OwningPtr的典型用法代码示例。如果您正苦于以下问题:C++ OwningPtr类的具体用法?C++ OwningPtr怎么用?C++ OwningPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OwningPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: strcpy

llvm::Module *NodeCompiler::compile(const char *fileName)
{
    // Add filename as the last argument of the compiler
    char globfilename[512];
    strcpy(globfilename, SRC_DIR"/");
    strcat(globfilename, fileName);
    m_args.push_back(globfilename);
    const llvm::OwningPtr<Compilation>
        Compilation(
            //m_driver->BuildCompilation(llvm::makeArrayRef(m_args)));
            m_driver->BuildCompilation(m_args));

    // Compilation Job to get the correct arguments
    const JobList &Jobs = Compilation->getJobs();
    const Command *Cmd = llvm::cast<Command>(*Jobs.begin());
    const ArgStringList *const CC1Args = &Cmd->getArguments();

    //m_driver->PrintActions(*Compilation);

    llvm::OwningPtr<CompilerInvocation> CI(new CompilerInvocation);
    CompilerInvocation::CreateFromArgs(
        *CI, CC1Args->data() + 1, CC1Args->data() + CC1Args->size(), *m_diagEngine);

    // Show the invocation, with -v.
    // TO debug the -fvectorize issue
    //if (CI->getHeaderSearchOpts().Verbose) {
    //    llvm::errs() << "clang invocation:\n";
    //    Compilation->PrintJob(llvm::errs(), Jobs, "\n", true);
    //    llvm::errs() << "\n";
    //}

    // Create the compiler instance
    m_clang->setInvocation(CI.take());

    // Diagnostics
    m_clang->createDiagnostics();
    //m_args.pop_back(); // Remove filename for future compilation
    if (!m_clang->hasDiagnostics())
        return NULL;

    // Emit only llvm code
    llvm::Module *mod=NULL;
    std::cout << "emitting llvm code" << "\n";
    if (!m_clang->ExecuteAction(*m_action)) {
        std::cout << "unable to generate llvm code" << "\n";
    } else {
        mod = m_action->takeModule();
    }
    std::cout << "code generated\n";
    return mod;
}
开发者ID:cpichard,项目名称:fission,代码行数:51,代码来源:NodeCompiler.cpp

示例2: argumentsAdjusterPtr

static clang::CompilerInvocation *newCompilerInvocation(std::string &mainExecutable,
        std::vector<std::string> &unadjustedCmdLine, bool runClangChecker = false)
{
    // Prepare for command lines, and convert to old-school argv
    llvm::OwningPtr<clang::tooling::ArgumentsAdjuster> argumentsAdjusterPtr(
        new clang::tooling::ClangSyntaxOnlyAdjuster());
    std::vector<std::string> commandLine = argumentsAdjusterPtr->Adjust(unadjustedCmdLine);
    assert(!commandLine.empty());
    commandLine[0] = mainExecutable;

    std::vector<const char*> argv;
    int start = 0, end = commandLine.size();
    if (runClangChecker)
    {
        argv.push_back(commandLine[0].c_str());
        argv.push_back("--analyze");
        start = 1;
        end -= 1;
    }
    for (int cmdIndex = start; cmdIndex != end; cmdIndex++)
    {
        argv.push_back(commandLine[cmdIndex].c_str());
    }

    // create diagnostic engine
    llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> diagOpts =
        new clang::DiagnosticOptions();
    clang::DiagnosticsEngine diagnosticsEngine(
        llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs>(new clang::DiagnosticIDs()),
        &*diagOpts,
        new clang::DiagnosticConsumer(),
        false);

    // create driver
    const char *const mainBinaryPath = argv[0];
    const llvm::OwningPtr<clang::driver::Driver> driver(
        newDriver(&diagnosticsEngine, mainBinaryPath));
    driver->setCheckInputsExist(false);

    // create compilation invocation
    const llvm::OwningPtr<clang::driver::Compilation> compilation(
        driver->BuildCompilation(llvm::makeArrayRef(argv)));
    const llvm::opt::ArgStringList *const cc1Args = getCC1Arguments(compilation.get());
    return newInvocation(&diagnosticsEngine, *cc1Args);
}
开发者ID:kettch,项目名称:oclint,代码行数:45,代码来源:Driver.cpp

示例3: DiagnosticPrinter

bool ToolInvocation::run() {
  std::vector<const char*> Argv;
  for (int I = 0, E = CommandLine.size(); I != E; ++I)
    Argv.push_back(CommandLine[I].c_str());
  const char *const BinaryName = Argv[0];
  DiagnosticOptions DefaultDiagnosticOptions;
  TextDiagnosticPrinter DiagnosticPrinter(
      llvm::errs(), DefaultDiagnosticOptions);
  DiagnosticsEngine Diagnostics(llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs>(
      new DiagnosticIDs()), &DiagnosticPrinter, false);

  const llvm::OwningPtr<clang::driver::Driver> Driver(
      newDriver(&Diagnostics, BinaryName));
  // Since the input might only be virtual, don't check whether it exists.
  Driver->setCheckInputsExist(false);
  const llvm::OwningPtr<clang::driver::Compilation> Compilation(
      Driver->BuildCompilation(llvm::makeArrayRef(Argv)));
  const clang::driver::ArgStringList *const CC1Args = getCC1Arguments(
      &Diagnostics, Compilation.get());
  if (CC1Args == NULL) {
    return false;
  }
  llvm::OwningPtr<clang::CompilerInvocation> Invocation(
      newInvocation(&Diagnostics, *CC1Args));
  return runInvocation(BinaryName, Compilation.get(),
                       Invocation.take(), *CC1Args, ToolAction.take());
}
开发者ID:socantre,项目名称:Clang,代码行数:27,代码来源:Tooling.cpp

示例4: SetUpBuildDumpLog

static void SetUpBuildDumpLog(const DiagnosticOptions &DiagOpts,
                              unsigned argc, char **argv,
                              llvm::OwningPtr<DiagnosticClient> &DiagClient) {
  std::string ErrorInfo;
  llvm::raw_ostream *OS =
    new llvm::raw_fd_ostream(DiagOpts.DumpBuildInformation.c_str(), ErrorInfo);
  if (!ErrorInfo.empty()) {
    // FIXME: Do not fail like this.
    llvm::errs() << "error opening -dump-build-information file '"
                 << DiagOpts.DumpBuildInformation << "', option ignored!\n";
    delete OS;
    return;
  }

  (*OS) << "clang -cc1 command line arguments: ";
  for (unsigned i = 0; i != argc; ++i)
    (*OS) << argv[i] << ' ';
  (*OS) << '\n';

  // Chain in a diagnostic client which will log the diagnostics.
  DiagnosticClient *Logger =
    new TextDiagnosticPrinter(*OS, DiagOpts, /*OwnsOutputStream=*/true);
  DiagClient.reset(new ChainedDiagnosticClient(DiagClient.take(), Logger));
}
开发者ID:aaasz,项目名称:SHP,代码行数:24,代码来源:CompilerInstance.cpp

示例5: mapped_file

llvm::error_code FileOutputBuffer::create(FileHandle& pFileHandle,
    size_t pSize, llvm::OwningPtr<FileOutputBuffer>& pResult)
{
  llvm::error_code EC;
  llvm::OwningPtr<mapped_file_region> mapped_file(new mapped_file_region(
      pFileHandle.handler(),
      false,
      mapped_file_region::readwrite,
      pSize,
      0,
      EC));

  if (EC)
    return EC;

  pResult.reset(new FileOutputBuffer(mapped_file.get(), pFileHandle));
  if (pResult)
    mapped_file.take();
  return llvm::error_code::success();
}
开发者ID:PixNDom,项目名称:android_mediatek_frameworks,代码行数:20,代码来源:FileOutputBuffer.cpp

示例6: getMangledName

    std::string getMangledName(FunctionDecl* FD) {
      // Copied from Interpreter.cpp;
      if (!m_MangleCtx)
        m_MangleCtx.reset(FD->getASTContext().createMangleContext());

      std::string mangledName;
      if (m_MangleCtx->shouldMangleDeclName(FD)) {
        llvm::raw_string_ostream RawStr(mangledName);
        switch(FD->getKind()) {
        case Decl::CXXConstructor:
          //Ctor_Complete,          // Complete object ctor
          //Ctor_Base,              // Base object ctor
          //Ctor_CompleteAllocating // Complete object allocating ctor (unused)
          m_MangleCtx->mangleCXXCtor(cast<CXXConstructorDecl>(FD),
                                     Ctor_Complete, RawStr);
          break;

        case Decl::CXXDestructor:
          //Dtor_Deleting, // Deleting dtor
          //Dtor_Complete, // Complete object dtor
          //Dtor_Base      // Base object dtor
          m_MangleCtx->mangleCXXDtor(cast<CXXDestructorDecl>(FD),
                                     Dtor_Complete, RawStr);
          break;

        default :
          m_MangleCtx->mangleName(FD, RawStr);
          break;
        }
        RawStr.flush();
      } else {
        mangledName = FD->getNameAsString();
      }
      return mangledName;
    }
开发者ID:agheorghiu,项目名称:root,代码行数:35,代码来源:NullDerefProtectionTransformer.cpp

示例7: Initialize

    virtual void Initialize(ASTContext &Ctx) {
      Context = &Ctx;

      if (llvm::TimePassesIsEnabled)
        LLVMIRGeneration.startTimer();

      Gen->Initialize(Ctx);

      TheModule.reset(Gen->GetModule());

      if (llvm::TimePassesIsEnabled)
        LLVMIRGeneration.stopTimer();
    }
开发者ID:ACSOP,项目名称:android_external_clang,代码行数:13,代码来源:CodeGenAction.cpp

示例8: aravdebug

    aravdebug(const char * userfile, int lineno, const char *PATH) {

        dataPath = getenv("DLOG_OUTPUT_FOLDER") + std::string(PATH);

        //llvm::errs()<<"Data path ::"<<dataPath;
        datatempPath = dataPath + ".temp";
//		tagPath = dataPath + ".tag";

        std::string syscall = "rm -f " + dataPath;

        int status = system(syscall.c_str());
        if (status < 0)
            std::cout << "DLOG Error: " << strerror(errno) << '\n';

        OS.reset((new llvm::raw_fd_ostream(datatempPath.c_str(), ErrorInfo)));

        llvm::errs() << ErrorInfo;

        id = gid++;

        //llvm::errs()<<"created DLOG with id "<<id<<"\n";
        tagset.insert("SYSTEM");
        (*OS) << DIV("SYSTEM")<< "Created Debugger " << GREEN(id)
              << CALLINFO
              << EDIV;

        tagset.insert("CALLINFO");

        (*OS).flush();
    }
开发者ID:rata,项目名称:DLOG,代码行数:30,代码来源:mydebug.hpp

示例9: HandleDiagnostic

    void HandleDiagnostic(clang::DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic& Info) override {

        /* Moc ignores most of the errors since it even can operate on non self-contained headers.
         * So try to change errors into warning.
         */

        auto DiagId = Info.getID();
        auto Cat = Info.getDiags()->getDiagnosticIDs()->getCategoryNumberForDiag(DiagId);

        bool ShouldReset = false;

        if (DiagLevel >= clang::DiagnosticsEngine::Error ) {
            if (Cat == 2 || Cat == 4
                || DiagId == clang::diag::err_param_redefinition
                || DiagId == clang::diag::err_pp_expr_bad_token_binop ) {
                if (!HadRealError)
                    ShouldReset = true;
                DiagLevel = clang::DiagnosticsEngine::Warning;
            } else {
                HadRealError++;
            }
        }

        DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
        Proxy->HandleDiagnostic(DiagLevel, Info);

        if (ShouldReset) {
            // FIXME:  is there another way to ignore errors?
            const_cast<clang::DiagnosticsEngine *>(Info.getDiags())->Reset();
        }
    }
开发者ID:qyqx,项目名称:moc-ng,代码行数:31,代码来源:main.cpp

示例10: HandleTopLevelDecl

    virtual void HandleTopLevelDecl(DeclGroupRef D) {
      PrettyStackTraceDecl CrashInfo(*D.begin(), SourceLocation(),
                                     Context->getSourceManager(),
                                     "LLVM IR generation of declaration");

      if (llvm::TimePassesIsEnabled)
        LLVMIRGeneration.startTimer();

      Gen->HandleTopLevelDecl(D);

      if (llvm::TimePassesIsEnabled)
        LLVMIRGeneration.stopTimer();
    }
开发者ID:ACSOP,项目名称:android_external_clang,代码行数:13,代码来源:CodeGenAction.cpp

示例11: HandleTranslationUnit

    virtual void HandleTranslationUnit(ASTContext &C) {
      {
        PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
        if (llvm::TimePassesIsEnabled)
          LLVMIRGeneration.startTimer();

        Gen->HandleTranslationUnit(C);

        if (llvm::TimePassesIsEnabled)
          LLVMIRGeneration.stopTimer();
      }

      // Silently ignore if we weren't initialized for some reason.
      if (!TheModule)
        return;

      // Make sure IR generation is happy with the module. This is released by
      // the module provider.
      Module *M = Gen->ReleaseModule();
      if (!M) {
        // The module has been released by IR gen on failures, do not double
        // free.
        TheModule.take();
        return;
      }

      assert(TheModule.get() == M &&
             "Unexpected module change during IR generation");

      // Install an inline asm handler so that diagnostics get printed through
      // our diagnostics hooks.
      LLVMContext &Ctx = TheModule->getContext();
      LLVMContext::InlineAsmDiagHandlerTy OldHandler =
        Ctx.getInlineAsmDiagnosticHandler();
      void *OldContext = Ctx.getInlineAsmDiagnosticContext();
      Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this);

      EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
                        TheModule.get(), Action, AsmOutStream);
      
      Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
    }
开发者ID:ACSOP,项目名称:android_external_clang,代码行数:42,代码来源:CodeGenAction.cpp

示例12: CompleteTentativeDefinition

 virtual void CompleteTentativeDefinition(VarDecl *D) {
   Gen->CompleteTentativeDefinition(D);
 }
开发者ID:ACSOP,项目名称:android_external_clang,代码行数:3,代码来源:CodeGenAction.cpp

示例13: finish

 void finish() override {
     Proxy->finish();
 }
开发者ID:qyqx,项目名称:moc-ng,代码行数:3,代码来源:main.cpp

示例14: EndSourceFile

 void EndSourceFile() override {
     Proxy->EndSourceFile();
 }
开发者ID:qyqx,项目名称:moc-ng,代码行数:3,代码来源:main.cpp

示例15: clear

 void clear() override {
     Proxy->clear();
 }
开发者ID:qyqx,项目名称:moc-ng,代码行数:3,代码来源:main.cpp


注:本文中的llvm::OwningPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。