}
};
- /// If the output doesn't support seeking (terminal, pipe). we switch
- /// the stream to a buffer_ostream. These are the buffer and the original
- /// stream.
- std::unique_ptr<llvm::raw_fd_ostream> NonSeekStream;
-
/// The list of active output files.
std::list<OutputFile> OutputFiles;
llvm::sys::fs::remove(Module.second);
BuiltModules.clear();
}
- NonSeekStream.reset();
}
std::unique_ptr<raw_pwrite_stream>
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
~buffer_ostream() override { OS << str(); }
};
+class buffer_unique_ostream : public raw_svector_ostream {
+ std::unique_ptr<raw_ostream> OS;
+ SmallVector<char, 0> Buffer;
+
+ virtual void anchor() override;
+
+public:
+ buffer_unique_ostream(std::unique_ptr<raw_ostream> OS)
+ : raw_svector_ostream(Buffer), OS(std::move(OS)) {}
+ ~buffer_unique_ostream() override { *OS << str(); }
+};
+
} // end namespace llvm
#endif // LLVM_SUPPORT_RAW_OSTREAM_H
void raw_pwrite_stream::anchor() {}
void buffer_ostream::anchor() {}
+
+void buffer_unique_ostream::anchor() {}