summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-04-25 17:01:33 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-04-25 17:01:33 +0000
commit103a2de0b4003bbb25c0aa42fd9247621620d1dd (patch)
treed50d6de51f91b63e14e760b28230e8a04792633a /clang/lib/Frontend
parent0840a22452f70d09bed5c9e114e6df21f3ea9963 (diff)
downloadbcm5719-llvm-103a2de0b4003bbb25c0aa42fd9247621620d1dd.tar.gz
bcm5719-llvm-103a2de0b4003bbb25c0aa42fd9247621620d1dd.zip
Push unique_ptr ownership of ASTUnits further back into their factories.
llvm-svn: 207237
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index b35fcf196d7..74169870868 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -51,6 +51,7 @@
using namespace clang;
using llvm::TimeRecord;
+using llvm::make_unique;
namespace {
class SimpleTimer {
@@ -1945,18 +1946,13 @@ bool ASTUnit::LoadFromCompilerInvocation(bool PrecompilePreamble) {
return Parse(OverrideMainBuffer);
}
-ASTUnit *ASTUnit::LoadFromCompilerInvocation(CompilerInvocation *CI,
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
- bool OnlyLocalDecls,
- bool CaptureDiagnostics,
- bool PrecompilePreamble,
- TranslationUnitKind TUKind,
- bool CacheCodeCompletionResults,
- bool IncludeBriefCommentsInCodeCompletion,
- bool UserFilesAreVolatile) {
+std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
+ CompilerInvocation *CI, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
+ bool OnlyLocalDecls, bool CaptureDiagnostics, bool PrecompilePreamble,
+ TranslationUnitKind TUKind, bool CacheCodeCompletionResults,
+ bool IncludeBriefCommentsInCodeCompletion, bool UserFilesAreVolatile) {
// Create the AST unit.
- std::unique_ptr<ASTUnit> AST;
- AST.reset(new ASTUnit(false));
+ std::unique_ptr<ASTUnit> AST(new ASTUnit(false));
ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics);
AST->Diagnostics = Diags;
AST->OnlyLocalDecls = OnlyLocalDecls;
@@ -1981,8 +1977,9 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(CompilerInvocation *CI,
llvm::CrashRecoveryContextReleaseRefCleanup<DiagnosticsEngine> >
DiagCleanup(Diags.getPtr());
- return AST->LoadFromCompilerInvocation(PrecompilePreamble) ? 0
- : AST.release();
+ if (AST->LoadFromCompilerInvocation(PrecompilePreamble))
+ return nullptr;
+ return AST;
}
ASTUnit *ASTUnit::LoadFromCommandLine(
OpenPOWER on IntegriCloud