From 03f8907f65c5581a3d2653210dcab07e116ebe2f Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 15 Jul 2016 00:55:40 +0000 Subject: Frontend: Simplify ownership model for clang's output streams. This changes the CompilerInstance::createOutputFile function to return a std::unique_ptr, 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 --- clang/lib/Frontend/Rewrite/HTMLPrint.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'clang/lib/Frontend/Rewrite/HTMLPrint.cpp') 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 Out; Preprocessor &PP; bool SyntaxHighlight, HighlightMacros; public: - HTMLPrinter(raw_ostream *OS, Preprocessor &pp, + HTMLPrinter(std::unique_ptr 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 clang::CreateHTMLPrinter(raw_ostream *OS, - Preprocessor &PP, - bool SyntaxHighlight, - bool HighlightMacros) { - return llvm::make_unique(OS, PP, SyntaxHighlight, +std::unique_ptr +clang::CreateHTMLPrinter(std::unique_ptr OS, Preprocessor &PP, + bool SyntaxHighlight, bool HighlightMacros) { + return llvm::make_unique(std::move(OS), PP, SyntaxHighlight, HighlightMacros); } -- cgit v1.2.3