summaryrefslogtreecommitdiffstats
path: root/include/llvm/Support/FormattedStream.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-14 20:33:33 +0000
committerChris Lattner <sabre@nondot.org>2009-07-14 20:33:33 +0000
commit4a18d2f1cce981873498d2f0303d84ef3d7ecbf6 (patch)
tree7195833d5651c13bcf05d57c52fff25d850d9acf /include/llvm/Support/FormattedStream.h
parent5473f07314cef4b93e82405664e49e04c175db80 (diff)
downloadexternal_llvm-4a18d2f1cce981873498d2f0303d84ef3d7ecbf6.zip
external_llvm-4a18d2f1cce981873498d2f0303d84ef3d7ecbf6.tar.gz
external_llvm-4a18d2f1cce981873498d2f0303d84ef3d7ecbf6.tar.bz2
allow default construction of formatted_raw_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75674 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/FormattedStream.h')
-rw-r--r--include/llvm/Support/FormattedStream.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/include/llvm/Support/FormattedStream.h b/include/llvm/Support/FormattedStream.h
index 1c213ab..ecfa4b8 100644
--- a/include/llvm/Support/FormattedStream.h
+++ b/include/llvm/Support/FormattedStream.h
@@ -35,7 +35,7 @@ namespace llvm
private:
/// TheStream - The real stream we output to.
///
- raw_ostream &TheStream;
+ raw_ostream *TheStream;
/// DeleteStream - Do we need to delete TheStream in the
/// destructor?
///
@@ -48,7 +48,7 @@ namespace llvm
virtual void write_impl(const char *Ptr, unsigned Size) {
ComputeColumn(Ptr, Size);
- TheStream.write(Ptr, Size);
+ TheStream->write(Ptr, Size);
}
/// current_pos - Return the current position within the stream,
@@ -56,7 +56,7 @@ namespace llvm
virtual uint64_t current_pos() {
// This has the same effect as calling TheStream.current_pos(),
// but that interface is private.
- return TheStream.tell() - TheStream.GetNumBytesInBuffer();
+ return TheStream->tell() - TheStream->GetNumBytesInBuffer();
}
/// ComputeColumn - Examine the current output and figure out
@@ -75,12 +75,19 @@ namespace llvm
/// \param Binary - The file should be opened in binary mode on
/// platforms that support this distinction.
formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
- : raw_ostream(), TheStream(Stream), DeleteStream(Delete), Column(0) {}
+ : raw_ostream(), TheStream(&Stream), DeleteStream(Delete), Column(0) {}
+ explicit formatted_raw_ostream()
+ : raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {}
~formatted_raw_ostream() {
if (DeleteStream)
delete &TheStream;
}
+
+ void setStream(raw_ostream &Stream, bool Delete = false) {
+ TheStream = &Stream;
+ DeleteStream = Delete;
+ }
/// PadToColumn - Align the output to some column number.
///