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


C++ IntrusiveRefCntPtr::setFatalsAsError方法代码示例

本文整理汇总了C++中IntrusiveRefCntPtr::setFatalsAsError方法的典型用法代码示例。如果您正苦于以下问题:C++ IntrusiveRefCntPtr::setFatalsAsError方法的具体用法?C++ IntrusiveRefCntPtr::setFatalsAsError怎么用?C++ IntrusiveRefCntPtr::setFatalsAsError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IntrusiveRefCntPtr的用法示例。


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

示例1: ParseProjectFile

ASTUnit* TranslationUnitManager::ParseProjectFile(ProjectFile* file,bool allowAdd)
{
    cbAssert (file && file->file.FileExists() && "File not exists");


    wxString fileName = file->file.GetFullPath();
    auto project = file->GetParentProject();

    {   //if the file is already being parsed return immediately.
        std::lock_guard<std::mutex> lock(m_FilesBeingParsedMutex);

        if (std::find(m_FilesBeingParsed.begin(), m_FilesBeingParsed.end(), file) != m_FilesBeingParsed.end())
            return nullptr;
        m_FilesBeingParsed.push_back(file);
    }


    auto iter = m_CompilationDatabases.find(project);

    if(iter == m_CompilationDatabases.end())
    {
        LoggerAccess::Get()->Log("Could not find the compilation database for project : " + project->GetTitle());
        return nullptr;
    }
    auto compileCommands = iter->second->getCompileCommands(wx2std(file->file.GetFullPath()));
    if (compileCommands.empty())
    {
        LoggerAccess::Get()->Log("No compile commands for the file" + file->file.GetName());
        return nullptr;
    }

    auto args = compileCommands[0].CommandLine;


    if (!Options::Get().ShouldSpellCheck())
        args.push_back("-fno-spell-checking");
    //Get Additional compile options from the config panel
    auto addOptions = Options::Get().GetCompilerOptions();
    args.insert(args.end(), addOptions.begin(), addOptions.end());

#ifdef CLANGCC_DEBUG_LOGGING
    wxString commandLine = "Command Line is ";
    std::for_each(args.begin(),args.end(), [&](const std::string s){ commandLine.Append(s); commandLine.append(' '); });
    LoggerAccess::Get()->Log(commandLine);
#endif

    //Parsing started event.
    ccEvent startEvent(ccEVT_PARSE_START, fileName, nullptr, file);
    AddPendingEvent(startEvent);

#ifdef CLANGCC_TIMING
    wxStopWatch watch;
#endif // CLANGCC_TIMING

    std::vector<const char*> argsinChar;
    argsinChar.reserve(args.size());
    std::transform(args.begin(), args.end(), std::back_inserter(argsinChar),
                        [](const std::string& strings){return strings.c_str();});

    DiagnosticOptions* diagOpts = new DiagnosticOptions();
    IntrusiveRefCntPtr<DiagnosticsEngine> diags = CompilerInstance::createDiagnostics(diagOpts,0);
    diags->setFatalsAsError(true);

    auto ast = ASTUnit::LoadFromCommandLine(&*argsinChar.begin(),&*argsinChar.end(),
                                            m_PCHContainerOps,
                                            diags,
                                            StringRef(),
                                            true, /* OnlyLocalDecls */
                                            true, /*CaptureDiagnostics*/
                                            None, /*Remapped Files*/
                                            true, /*RemappedFiles keep original name*/
                                            1, /*Precompile preamble*/
                                            TU_Complete,
                                            Options::Get().ShouldCacheCompletionResults(),/*CacheCodeCompletionResults*/
                                            true, /*Include Brief Comment*/
                                            true, /*allow pch with compiler errors*/
                                            Options::Get().ShouldSkipFunctionBodies(),
                                            true,
                                            false,
                                            m_PCHContainerOps->getRawReader().getFormat()
                                           );

#ifdef CLANGCC_TIMING
    LoggerAccess::Get()->Log(wxString::Format("Parsing %s completed in %ldms", file->file.GetFullName().c_str(), watch.Time()),Logger::info);
#endif // CLANGCC_TIMING
    if (!ast)
      LoggerAccess::Get()->Log("\t Cannot Create ASTUnit for " + file->file.GetFullName());
    if (ast)
    {
        if (allowAdd)
            AddASTUnitForProjectFile(file,ast);
    }

    {   //File is free again
        std::lock_guard<std::mutex> lock(m_FilesBeingParsedMutex);
        m_FilesBeingParsed.erase(std::remove(m_FilesBeingParsed.begin(), m_FilesBeingParsed.end(), file),m_FilesBeingParsed.end());
    }
    //Parsing ended event
    ccEvent endEvent(ccEVT_PARSE_END, fileName, ast, file);
    AddPendingEvent(endEvent);
//.........这里部分代码省略.........
开发者ID:golgepapaz,项目名称:clang_cc,代码行数:101,代码来源:translationunitmanager.cpp


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