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 | 302008dbeae03364ffffc1bcf77d2eb28897d98a (patch) | |
tree | 6cd09f8ff7f7b28b32c364fb6f63f44e85937880 /include/llvm/Support/FormattedStream.h | |
parent | 6e30ad8ce7be319ef4f30bc9163e0b736537f846 (diff) | |
download | external_llvm-302008dbeae03364ffffc1bcf77d2eb28897d98a.zip external_llvm-302008dbeae03364ffffc1bcf77d2eb28897d98a.tar.gz external_llvm-302008dbeae03364ffffc1bcf77d2eb28897d98a.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 |