diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-07-17 20:40:36 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-07-17 20:40:36 +0000 |
commit | a51666a4d624a745df90e1c84777fb7a644ff80b (patch) | |
tree | 27a6715358a552387f3e0fd041de88a3095d0a35 /clang/lib/Frontend/Rewrite | |
parent | fa59e620126114e35477299dbb726c4e85195276 (diff) | |
download | bcm5719-llvm-a51666a4d624a745df90e1c84777fb7a644ff80b.tar.gz bcm5719-llvm-a51666a4d624a745df90e1c84777fb7a644ff80b.zip |
unique_ptr-ify ownership of ASTConsumers
(after fixing a bug in MultiplexConsumer I noticed the ownership of the
nested consumers was implemented with raw pointers - so this fixes
that... and follows the source back to its origin pushing unique_ptr
ownership up through there too)
llvm-svn: 213307
Diffstat (limited to 'clang/lib/Frontend/Rewrite')
-rw-r--r-- | clang/lib/Frontend/Rewrite/FrontendActions.cpp | 14 | ||||
-rw-r--r-- | clang/lib/Frontend/Rewrite/HTMLPrint.cpp | 11 | ||||
-rw-r--r-- | clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Frontend/Rewrite/RewriteObjC.cpp | 12 |
4 files changed, 24 insertions, 26 deletions
diff --git a/clang/lib/Frontend/Rewrite/FrontendActions.cpp b/clang/lib/Frontend/Rewrite/FrontendActions.cpp index 59fef736f16..1b5eb2855be 100644 --- a/clang/lib/Frontend/Rewrite/FrontendActions.cpp +++ b/clang/lib/Frontend/Rewrite/FrontendActions.cpp @@ -30,8 +30,8 @@ using namespace clang; // AST Consumer Actions //===----------------------------------------------------------------------===// -ASTConsumer *HTMLPrintAction::CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) { +std::unique_ptr<ASTConsumer> +HTMLPrintAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { if (raw_ostream *OS = CI.createDefaultOutputFile(false, InFile)) return CreateHTMLPrinter(OS, CI.getPreprocessor()); return nullptr; @@ -40,9 +40,9 @@ ASTConsumer *HTMLPrintAction::CreateASTConsumer(CompilerInstance &CI, FixItAction::FixItAction() {} FixItAction::~FixItAction() {} -ASTConsumer *FixItAction::CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) { - return new ASTConsumer(); +std::unique_ptr<ASTConsumer> +FixItAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { + return llvm::make_unique<ASTConsumer>(); } namespace { @@ -148,8 +148,8 @@ bool FixItRecompile::BeginInvocation(CompilerInstance &CI) { #ifdef CLANG_ENABLE_OBJC_REWRITER -ASTConsumer *RewriteObjCAction::CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) { +std::unique_ptr<ASTConsumer> +RewriteObjCAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { if (raw_ostream *OS = CI.createDefaultOutputFile(false, InFile, "cpp")) { if (CI.getLangOpts().ObjCRuntime.isNonFragile()) return CreateModernObjCRewriter(InFile, OS, diff --git a/clang/lib/Frontend/Rewrite/HTMLPrint.cpp b/clang/lib/Frontend/Rewrite/HTMLPrint.cpp index 64da05fdde6..22ccfe6936b 100644 --- a/clang/lib/Frontend/Rewrite/HTMLPrint.cpp +++ b/clang/lib/Frontend/Rewrite/HTMLPrint.cpp @@ -47,11 +47,12 @@ namespace { }; } -ASTConsumer* clang::CreateHTMLPrinter(raw_ostream *OS, - Preprocessor &PP, - bool SyntaxHighlight, - bool HighlightMacros) { - return new HTMLPrinter(OS, PP, SyntaxHighlight, HighlightMacros); +std::unique_ptr<ASTConsumer> clang::CreateHTMLPrinter(raw_ostream *OS, + Preprocessor &PP, + bool SyntaxHighlight, + bool HighlightMacros) { + return llvm::make_unique<HTMLPrinter>(OS, PP, SyntaxHighlight, + HighlightMacros); } void HTMLPrinter::Initialize(ASTContext &context) { diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index 3e18a8b415a..c97fa979f60 100644 --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -675,14 +675,11 @@ RewriteModernObjC::RewriteModernObjC(std::string inFile, raw_ostream* OS, "for @try/@finally (code may not execute properly)"); } -ASTConsumer *clang::CreateModernObjCRewriter(const std::string& InFile, - raw_ostream* OS, - DiagnosticsEngine &Diags, - const LangOptions &LOpts, - bool SilenceRewriteMacroWarning, - bool LineInfo) { - return new RewriteModernObjC(InFile, OS, Diags, LOpts, - SilenceRewriteMacroWarning, LineInfo); +std::unique_ptr<ASTConsumer> clang::CreateModernObjCRewriter( + const std::string &InFile, raw_ostream *OS, DiagnosticsEngine &Diags, + const LangOptions &LOpts, bool SilenceRewriteMacroWarning, bool LineInfo) { + return llvm::make_unique<RewriteModernObjC>( + InFile, OS, Diags, LOpts, SilenceRewriteMacroWarning, LineInfo); } void RewriteModernObjC::InitializeCommon(ASTContext &context) { diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp index 7a721771759..8d48d9e7b69 100644 --- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -600,12 +600,12 @@ RewriteObjC::RewriteObjC(std::string inFile, raw_ostream* OS, "for @try/@finally (code may not execute properly)"); } -ASTConsumer *clang::CreateObjCRewriter(const std::string& InFile, - raw_ostream* OS, - DiagnosticsEngine &Diags, - const LangOptions &LOpts, - bool SilenceRewriteMacroWarning) { - return new RewriteObjCFragileABI(InFile, OS, Diags, LOpts, SilenceRewriteMacroWarning); +std::unique_ptr<ASTConsumer> +clang::CreateObjCRewriter(const std::string &InFile, raw_ostream *OS, + DiagnosticsEngine &Diags, const LangOptions &LOpts, + bool SilenceRewriteMacroWarning) { + return llvm::make_unique<RewriteObjCFragileABI>(InFile, OS, Diags, LOpts, + SilenceRewriteMacroWarning); } void RewriteObjC::InitializeCommon(ASTContext &context) { |