From 2f721476d10c1cc7a5336650a85012f78c94d33a Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 14 Dec 2020 17:46:11 -0800 Subject: 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 --- clang/lib/Frontend/CompilerInstance.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'clang/lib/Frontend/CompilerInstance.cpp') 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 @@ -816,10 +815,7 @@ std::unique_ptr CompilerInstance::createOutputFile( if (!Binary || OS->supportsSeeking()) return std::move(OS); - auto B = std::make_unique(*OS); - assert(!NonSeekStream); - NonSeekStream = std::move(OS); - return std::move(B); + return std::make_unique(std::move(OS)); } // Initialization Utilities -- cgit v1.1