diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-07-15 00:55:40 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-07-15 00:55:40 +0000 |
commit | 03f8907f65c5581a3d2653210dcab07e116ebe2f (patch) | |
tree | ea4db0f5bd3b2d034aea3560a15d2c70d25fafb8 /clang/lib/Frontend/Rewrite/HTMLPrint.cpp | |
parent | 38c5318662c51ea02415e81ff4a5fc52df1c9d35 (diff) | |
download | bcm5719-llvm-03f8907f65c5581a3d2653210dcab07e116ebe2f.tar.gz bcm5719-llvm-03f8907f65c5581a3d2653210dcab07e116ebe2f.zip |
Frontend: Simplify ownership model for clang's output streams.
This changes the CompilerInstance::createOutputFile function to return
a std::unique_ptr<llvm::raw_ostream>, rather than an llvm::raw_ostream
implicitly owned by the CompilerInstance. This in most cases required that
I move ownership of the output stream to the relevant ASTConsumer.
The motivation for this change is to allow BackendConsumer to be a client
of interfaces such as D20268 which take ownership of the output stream.
Differential Revision: http://reviews.llvm.org/D21537
llvm-svn: 275507
Diffstat (limited to 'clang/lib/Frontend/Rewrite/HTMLPrint.cpp')
-rw-r--r-- | clang/lib/Frontend/Rewrite/HTMLPrint.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/Frontend/Rewrite/HTMLPrint.cpp b/clang/lib/Frontend/Rewrite/HTMLPrint.cpp index 22ccfe6936b..f5fad346124 100644 --- a/clang/lib/Frontend/Rewrite/HTMLPrint.cpp +++ b/clang/lib/Frontend/Rewrite/HTMLPrint.cpp @@ -32,14 +32,14 @@ using namespace clang; namespace { class HTMLPrinter : public ASTConsumer { Rewriter R; - raw_ostream *Out; + std::unique_ptr<raw_ostream> Out; Preprocessor &PP; bool SyntaxHighlight, HighlightMacros; public: - HTMLPrinter(raw_ostream *OS, Preprocessor &pp, + HTMLPrinter(std::unique_ptr<raw_ostream> OS, Preprocessor &pp, bool _SyntaxHighlight, bool _HighlightMacros) - : Out(OS), PP(pp), SyntaxHighlight(_SyntaxHighlight), + : Out(std::move(OS)), PP(pp), SyntaxHighlight(_SyntaxHighlight), HighlightMacros(_HighlightMacros) {} void Initialize(ASTContext &context) override; @@ -47,11 +47,10 @@ namespace { }; } -std::unique_ptr<ASTConsumer> clang::CreateHTMLPrinter(raw_ostream *OS, - Preprocessor &PP, - bool SyntaxHighlight, - bool HighlightMacros) { - return llvm::make_unique<HTMLPrinter>(OS, PP, SyntaxHighlight, +std::unique_ptr<ASTConsumer> +clang::CreateHTMLPrinter(std::unique_ptr<raw_ostream> OS, Preprocessor &PP, + bool SyntaxHighlight, bool HighlightMacros) { + return llvm::make_unique<HTMLPrinter>(std::move(OS), PP, SyntaxHighlight, HighlightMacros); } |