Add an overload for InstrProfWriter::write so that users can emit the
buffer to a string. Also use this new overload for existing unit test
usecases.
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D153904
/// Write the profile to \c OS
Error write(raw_fd_ostream &OS);
+ /// Write the profile to a string output stream \c OS
+ Error write(raw_string_ostream &OS);
+
/// Write the profile in text format to \c OS
Error writeText(raw_fd_ostream &OS);
return writeImpl(POS);
}
+Error InstrProfWriter::write(raw_string_ostream &OS) {
+ ProfOStream POS(OS);
+ return writeImpl(POS);
+}
+
std::unique_ptr<MemoryBuffer> InstrProfWriter::writeBuffer() {
std::string Data;
raw_string_ostream OS(Data);
- ProfOStream POS(OS);
// Write the hash table.
- if (Error E = writeImpl(POS))
+ if (Error E = write(OS))
return nullptr;
// Return this in an aligned memory buffer.
return MemoryBuffer::getMemBufferCopy(Data);