diff options
Diffstat (limited to 'clang/tools/libclang/Indexing.cpp')
-rw-r--r-- | clang/tools/libclang/Indexing.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp index 5422dd3dc62..905e764accd 100644 --- a/clang/tools/libclang/Indexing.cpp +++ b/clang/tools/libclang/Indexing.cpp @@ -476,17 +476,19 @@ static CXErrorCode clang_indexSourceFile_Impl( // present it will be unused. if (source_filename) Args->push_back(source_filename); - - IntrusiveRefCntPtr<CompilerInvocation> - CInvok(createInvocationFromCommandLine(*Args, Diags)); + + std::shared_ptr<CompilerInvocation> CInvok = + createInvocationFromCommandLine(*Args, Diags); if (!CInvok) return CXError_Failure; // Recover resources if we crash before exiting this function. - llvm::CrashRecoveryContextCleanupRegistrar<CompilerInvocation, - llvm::CrashRecoveryContextReleaseRefCleanup<CompilerInvocation> > - CInvokCleanup(CInvok.get()); + llvm::CrashRecoveryContextCleanupRegistrar< + std::shared_ptr<CompilerInvocation>, + llvm::CrashRecoveryContextDeleteCleanup< + std::shared_ptr<CompilerInvocation>>> + CInvokCleanup(&CInvok); if (CInvok->getFrontendOpts().Inputs.empty()) return CXError_Failure; @@ -518,13 +520,14 @@ static CXErrorCode clang_indexSourceFile_Impl( CInvok->getHeaderSearchOpts().ModuleFormat = CXXIdx->getPCHContainerOperations()->getRawReader().getFormat(); - ASTUnit *Unit = ASTUnit::create(CInvok.get(), Diags, CaptureDiagnostics, - /*UserFilesAreVolatile=*/true); + auto Unit = ASTUnit::create(CInvok, Diags, CaptureDiagnostics, + /*UserFilesAreVolatile=*/true); if (!Unit) return CXError_InvalidArguments; + auto *UPtr = Unit.get(); std::unique_ptr<CXTUOwner> CXTU( - new CXTUOwner(MakeCXTranslationUnit(CXXIdx, Unit))); + new CXTUOwner(MakeCXTranslationUnit(CXXIdx, std::move(Unit)))); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar<CXTUOwner> @@ -583,16 +586,16 @@ static CXErrorCode clang_indexSourceFile_Impl( !PrecompilePreamble ? 0 : 2 - CreatePreambleOnFirstParse; DiagnosticErrorTrap DiagTrap(*Diags); bool Success = ASTUnit::LoadFromCompilerInvocationAction( - CInvok.get(), CXXIdx->getPCHContainerOperations(), Diags, - IndexAction.get(), Unit, Persistent, CXXIdx->getClangResourcesPath(), + std::move(CInvok), CXXIdx->getPCHContainerOperations(), Diags, + IndexAction.get(), UPtr, Persistent, CXXIdx->getClangResourcesPath(), OnlyLocalDecls, CaptureDiagnostics, PrecompilePreambleAfterNParses, CacheCodeCompletionResults, /*IncludeBriefCommentsInCodeCompletion=*/false, /*UserFilesAreVolatile=*/true); if (DiagTrap.hasErrorOccurred() && CXXIdx->getDisplayDiagnostics()) - printDiagsToStderr(Unit); + printDiagsToStderr(UPtr); - if (isASTReadError(Unit)) + if (isASTReadError(UPtr)) return CXError_ASTReadError; if (!Success) |