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