diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-08-10 19:08:04 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-08-10 19:08:04 +0000 |
commit | 6f7382ddd11db36df6b7f08324134ec1a54e0a5e (patch) | |
tree | 7e48396093f2d07d702e14ebb2eaac3e7871dafc /clang/lib/Frontend | |
parent | f62d4e772d7ea782ed2335639bd3f9c5c7b217f1 (diff) | |
download | bcm5719-llvm-6f7382ddd11db36df6b7f08324134ec1a54e0a5e.tar.gz bcm5719-llvm-6f7382ddd11db36df6b7f08324134ec1a54e0a5e.zip |
std::unique_ptr-ify the result of ASTUnit::LoadFromASTFile
llvm-svn: 215320
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/ASTMerge.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 17 | ||||
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 4 |
3 files changed, 11 insertions, 16 deletions
diff --git a/clang/lib/Frontend/ASTMerge.cpp b/clang/lib/Frontend/ASTMerge.cpp index ff6434c5694..95cfe248003 100644 --- a/clang/lib/Frontend/ASTMerge.cpp +++ b/clang/lib/Frontend/ASTMerge.cpp @@ -45,8 +45,8 @@ void ASTMergeAction::ExecuteAction() { new ForwardingDiagnosticConsumer( *CI.getDiagnostics().getClient()), /*ShouldOwnClient=*/true)); - ASTUnit *Unit = ASTUnit::LoadFromASTFile(ASTFiles[I], Diags, - CI.getFileSystemOpts(), false); + std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile( + ASTFiles[I], Diags, CI.getFileSystemOpts(), false); if (!Unit) continue; @@ -66,8 +66,6 @@ void ASTMergeAction::ExecuteAction() { Importer.Import(D); } - - delete Unit; } AdaptedAction->ExecuteAction(); diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index f0c755e3da4..9505c0769fe 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -662,14 +662,11 @@ void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> &Diags, } } -ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, - IntrusiveRefCntPtr<DiagnosticsEngine> Diags, - const FileSystemOptions &FileSystemOpts, - bool OnlyLocalDecls, - ArrayRef<RemappedFile> RemappedFiles, - bool CaptureDiagnostics, - bool AllowPCHWithCompilerErrors, - bool UserFilesAreVolatile) { +std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile( + const std::string &Filename, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, + const FileSystemOptions &FileSystemOpts, bool OnlyLocalDecls, + ArrayRef<RemappedFile> RemappedFiles, bool CaptureDiagnostics, + bool AllowPCHWithCompilerErrors, bool UserFilesAreVolatile) { std::unique_ptr<ASTUnit> AST(new ASTUnit(true)); // Recover resources if we crash before exiting this method. @@ -705,7 +702,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, // Gather Info for preprocessor construction later on. - HeaderSearch &HeaderInfo = *AST->HeaderInfo.get(); + HeaderSearch &HeaderInfo = *AST->HeaderInfo; unsigned Counter; AST->PP = @@ -767,7 +764,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, // Tell the diagnostic client that we have started a source file. AST->getDiagnostics().getClient()->BeginSourceFile(Context.getLangOpts(),&PP); - return AST.release(); + return AST; } namespace { diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 8295d6ddfa9..cd3dd1f17dd 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -189,8 +189,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, IntrusiveRefCntPtr<DiagnosticsEngine> Diags(&CI.getDiagnostics()); - std::unique_ptr<ASTUnit> AST( - ASTUnit::LoadFromASTFile(InputFile, Diags, CI.getFileSystemOpts())); + std::unique_ptr<ASTUnit> AST = + ASTUnit::LoadFromASTFile(InputFile, Diags, CI.getFileSystemOpts()); if (!AST) goto failure; |