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/PCHContainerOperations.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/PCHContainerOperations.cpp')
-rw-r--r-- | clang/lib/Frontend/PCHContainerOperations.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/Frontend/PCHContainerOperations.cpp b/clang/lib/Frontend/PCHContainerOperations.cpp index d41d90e1e5c..2d4edde4328 100644 --- a/clang/lib/Frontend/PCHContainerOperations.cpp +++ b/clang/lib/Frontend/PCHContainerOperations.cpp @@ -28,12 +28,12 @@ namespace { /// \brief A PCHContainerGenerator that writes out the PCH to a flat file. class RawPCHContainerGenerator : public ASTConsumer { std::shared_ptr<PCHBuffer> Buffer; - raw_pwrite_stream *OS; + std::unique_ptr<raw_pwrite_stream> OS; public: - RawPCHContainerGenerator(llvm::raw_pwrite_stream *OS, + RawPCHContainerGenerator(std::unique_ptr<llvm::raw_pwrite_stream> OS, std::shared_ptr<PCHBuffer> Buffer) - : Buffer(std::move(Buffer)), OS(OS) {} + : Buffer(std::move(Buffer)), OS(std::move(OS)) {} ~RawPCHContainerGenerator() override = default; @@ -53,9 +53,9 @@ public: std::unique_ptr<ASTConsumer> RawPCHContainerWriter::CreatePCHContainerGenerator( CompilerInstance &CI, const std::string &MainFileName, - const std::string &OutputFileName, llvm::raw_pwrite_stream *OS, + const std::string &OutputFileName, std::unique_ptr<llvm::raw_pwrite_stream> OS, std::shared_ptr<PCHBuffer> Buffer) const { - return llvm::make_unique<RawPCHContainerGenerator>(OS, Buffer); + return llvm::make_unique<RawPCHContainerGenerator>(std::move(OS), Buffer); } void RawPCHContainerReader::ExtractPCH( |