diff options
author | David Greene <greened@obbligato.org> | 2009-07-14 20:18:05 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2009-07-14 20:18:05 +0000 |
commit | 71847813bc419f7a0667468136a07429c6d9f164 (patch) | |
tree | 6cd09f8ff7f7b28b32c364fb6f63f44e85937880 /include/llvm/Support/FormattedStream.h | |
parent | a266b5f22811480a65e65a08c8a5d92fe9be8a3b (diff) | |
download | external_llvm-71847813bc419f7a0667468136a07429c6d9f164.zip external_llvm-71847813bc419f7a0667468136a07429c6d9f164.tar.gz external_llvm-71847813bc419f7a0667468136a07429c6d9f164.tar.bz2 |
Have asm printers use formatted_raw_ostream directly to avoid a
dynamic_cast<>.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75670 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/FormattedStream.h')
-rw-r--r-- | include/llvm/Support/FormattedStream.h | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/include/llvm/Support/FormattedStream.h b/include/llvm/Support/FormattedStream.h index 2cead0a..1c213ab 100644 --- a/include/llvm/Support/FormattedStream.h +++ b/include/llvm/Support/FormattedStream.h @@ -23,10 +23,23 @@ namespace llvm /// asm-specific constructs. /// class formatted_raw_ostream : public raw_ostream { + public: + /// DELETE_STREAM - Tell the destructor to delete the held stream. + /// + const static bool DELETE_STREAM = true; + /// PRESERVE_STREAM - Tell the destructor to not delete the held + /// stream. + /// + const static bool PRESERVE_STREAM = false; + private: /// TheStream - The real stream we output to. /// raw_ostream &TheStream; + /// DeleteStream - Do we need to delete TheStream in the + /// destructor? + /// + bool DeleteStream; /// Column - The current output column of the stream. The column /// scheme is zero-based. @@ -61,8 +74,13 @@ namespace llvm /// stream will use stdout instead. /// \param Binary - The file should be opened in binary mode on /// platforms that support this distinction. - formatted_raw_ostream(raw_ostream &Stream) - : raw_ostream(), TheStream(Stream), Column(0) {} + formatted_raw_ostream(raw_ostream &Stream, bool Delete = false) + : raw_ostream(), TheStream(Stream), DeleteStream(Delete), Column(0) {} + + ~formatted_raw_ostream() { + if (DeleteStream) + delete &TheStream; + } /// PadToColumn - Align the output to some column number. /// @@ -72,6 +90,16 @@ namespace llvm /// void PadToColumn(unsigned NewCol, unsigned MinPad = 0); }; -} + +/// fouts() - This returns a reference to a formatted_raw_ostream for +/// standard output. Use it like: fouts() << "foo" << "bar"; +formatted_raw_ostream &fouts(); + +/// ferrs() - This returns a reference to a formatted_raw_ostream for +/// standard error. Use it like: ferrs() << "foo" << "bar"; +formatted_raw_ostream &ferrs(); + +} // end llvm namespace + #endif |