diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-12-14 17:46:11 -0800 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-26 15:20:43 -0800 |
commit | 2f721476d10c1cc7a5336650a85012f78c94d33a (patch) | |
tree | 3d57a648621def8e4b24e73102024f94a318d985 /clang/lib/Frontend/CompilerInstance.cpp | |
parent | f36007e8110174ea10294f6fa546f3c64f0e548a (diff) | |
download | llvm-2f721476d10c1cc7a5336650a85012f78c94d33a.zip llvm-2f721476d10c1cc7a5336650a85012f78c94d33a.tar.gz llvm-2f721476d10c1cc7a5336650a85012f78c94d33a.tar.bz2 |
Frontend: Simplify handling of non-seeking streams in CompilerInstance, NFC
Add a new `raw_pwrite_ostream` variant, `buffer_unique_ostream`, which
is like `buffer_ostream` but with unique ownership of the stream it's
wrapping. Use this in CompilerInstance to simplify the ownership of
non-seeking output streams, avoiding logic sprawled around to deal with
them specially.
This also simplifies future work to encapsulate output files in a
different class.
Differential Revision: https://reviews.llvm.org/D93260
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index f694f41..d60a0e8 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -678,7 +678,6 @@ void CompilerInstance::clearOutputFiles(bool EraseFiles) { llvm::sys::fs::remove(Module.second); BuiltModules.clear(); } - NonSeekStream.reset(); } std::unique_ptr<raw_pwrite_stream> @@ -816,10 +815,7 @@ std::unique_ptr<llvm::raw_pwrite_stream> CompilerInstance::createOutputFile( if (!Binary || OS->supportsSeeking()) return std::move(OS); - auto B = std::make_unique<llvm::buffer_ostream>(*OS); - assert(!NonSeekStream); - NonSeekStream = std::move(OS); - return std::move(B); + return std::make_unique<llvm::buffer_unique_ostream>(std::move(OS)); } // Initialization Utilities |