summaryrefslogtreecommitdiff
path: root/lib/Support/raw_ostream.cpp
Commit message (Collapse)AuthorAge
...
* Fix MSVC build.Benjamin Kramer2010-01-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94809 91177308-0d34-0410-b5e6-96231b3b80d8
* Use llvm::format instead of ftostr (which just calls sprintf).Benjamin Kramer2010-01-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94807 91177308-0d34-0410-b5e6-96231b3b80d8
* Changes to fix buffering that I forgot to commit with previous patch.Chris Lattner2010-01-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94222 91177308-0d34-0410-b5e6-96231b3b80d8
* add a new MCAsmStreamer::GetCommentOS method to simplify stuffChris Lattner2010-01-22
| | | | | | | that doesn't want to use twines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94199 91177308-0d34-0410-b5e6-96231b3b80d8
* Make some methods const. The only interesting change here is thatChris Lattner2009-12-19
| | | | | | | | | | it changes raw_fd_ostream::preferred_buffer_size to return zero on a scary stat failure instead of setting the stream to an error state. This method really should not mutate the stream. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91740 91177308-0d34-0410-b5e6-96231b3b80d8
* Micro-optimize these functions in the case where they are not inlined.Dan Gohman2009-12-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91316 91177308-0d34-0410-b5e6-96231b3b80d8
* Add raw_ostream::write_escaped, for writing escaped strings.Daniel Dunbar2009-10-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84355 91177308-0d34-0410-b5e6-96231b3b80d8
* Drop the raw_ostream required buffer size to 1.Daniel Dunbar2009-09-15
| | | | | | | - As best I can tell, we have eliminated all the code which used to require a larger buffer size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81912 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix llvm-extract's "writing bitcode to a terminal" warning, which wasn'tDan Gohman2009-09-11
| | | | | | | | | | | | | | | | working. To support this, add an is_displayed() function to raw_ostream, and generalize Process::StandardOutIsDisplayed and friends in order to support it. Also, call RemoveFileOnSignal before creating a file instead of after, so that the file isn't left behind if the program is interrupted between when the file is created and RemoveFileOnSignal is called. While here, add a -S to llvm-extract and port it to IRReader so that it supports assembly input. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81568 91177308-0d34-0410-b5e6-96231b3b80d8
* Make LLVM command-line tools overwrite their output files without -f.Dan Gohman2009-08-25
| | | | | | | | | | | | | | | | | This is conventional command-line tool behavior. -f now just means "enable binary output on terminals". Add a -f option to llvm-extract and llvm-link, for consistency. Remove F_Force from raw_fd_ostream and enable overwriting and truncating by default. Introduce an F_Excl flag to permit users to enable a failure when the file already exists. This flag is currently unused. Update Makefiles and documentation accordingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79990 91177308-0d34-0410-b5e6-96231b3b80d8
* Correctly account for the Spaces array nul terminator. Thanks Chris!Dan Gohman2009-08-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79894 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream::indent is used for PadToColumn which often prints moreDan Gohman2009-08-24
| | | | | | | than 16 spaces. Make the Spaces array wide enough to handle common cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79890 91177308-0d34-0410-b5e6-96231b3b80d8
* split raw_os_ostream out to its own header and implementation file. ThisChris Lattner2009-08-24
| | | | | | | | means that raw_ostream no longer has to #include <iosfwd>. Nothing in llvm should use raw_os_ostream.h, but llvm-gcc and some unit tests do. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79886 91177308-0d34-0410-b5e6-96231b3b80d8
* prune the #includes in raw_ostream.h by moving a Chris Lattner2009-08-24
| | | | | | | | member out of line. ftostr is not particularly speedy, so that method is presumably not perf sensitive. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79885 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix off-by-one in llvm::Format::print.Daniel Dunbar2009-08-23
| | | | | | | | | | | | | - This also shortens the Format.h implementation, and uses the print buffer fully (it was wasting a character). - This manifested as llvm-test failures, because one side effect was that raw_ostream would write garbage '\x00' values into the output stream if it happened that the string was at the end of the buffer. This meant that grep would report 'Binary file matches', which meant the silly pattern matching llvm-test eventually does would fail. Cute. :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79862 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix windows build.Benjamin Kramer2009-08-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79845 91177308-0d34-0410-b5e6-96231b3b80d8
* Change raw_fd_ostream to take flags as an optional bitmask Chris Lattner2009-08-23
| | | | | | | | | | | | | | | | | | | instead of as two bools. Use this to add a F_Append flag which has the obvious behavior. Other unrelated changes conflated into this patch: 1. REmove EH stuff from llvm-dis and llvm-as, the try blocks are dead. 2. Simplify the filename inference code in llvm-as/llvm-dis, because raw_fd_ostream does the right thing with '-'. 3. Switch machine verifier to use raw_ostream instead of ostream (Which is the thing that needed append in the first place). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79807 91177308-0d34-0410-b5e6-96231b3b80d8
* add a raw_ostream::indent method, to be used like:Chris Lattner2009-08-22
| | | | | | | | | OS.indent(i) << "whatever"; people seem to like indenting things ;-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79784 91177308-0d34-0410-b5e6-96231b3b80d8
* Change raw_svector_ostream to reserve the input buffer if necessary, Ted wasDaniel Dunbar2009-08-19
| | | | | | | | | | | | | | right. - This class turns out to be much more convenient to use if we do this; clients can make sure the buffer is always big enough if they care (since our current idiom tends to be to use a SmallString<256> for the input to this we should generally be avoiding an unnecessary malloc). Also, add a convenience raw_svector_ostream::str method which flushes the buffer and returns a StringRef for the vector contents. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79446 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch raw_svector_ostream to use the vector as the ostream buffer.Daniel Dunbar2009-08-19
| | | | | | | | - This avoids unnecessary malloc/free overhead in the common case, and unnecessary copying from the ostream buffer into the output vector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79434 91177308-0d34-0410-b5e6-96231b3b80d8
* Speculatively revert r79375, which may be breaking bootstrap, although in aDaniel Dunbar2009-08-19
| | | | | | | rather obscure way (the other candidate is r79377). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79426 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream: Simplify write(unsigned char) to match write(const char*, ↵Daniel Dunbar2009-08-19
| | | | | | unsigned). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79386 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream: Remove pointless redefinitions of tell().Daniel Dunbar2009-08-19
| | | | | | | - The base class implementation is correct. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79385 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream: Add the capability for subclasses to manually install an externalDaniel Dunbar2009-08-18
| | | | | | | buffer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79382 91177308-0d34-0410-b5e6-96231b3b80d8
* Speed up raw_ostream::<<(unsigned long long) for 32-bit systems by doing mostDaniel Dunbar2009-08-18
| | | | | | | div/mods in 32-bits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79375 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in raw_ostream::write(char) introduced by the change toDan Gohman2009-08-18
| | | | | | | | | | allow underlying stream classes to decline buffering. After calling SetBuffered(), re-check whether the stream is Unbuffered in order to handle the case where the underlying stream has declined buffering. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79362 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r78924, disabling buffering defeats all the fast paths in raw_ostream.Daniel Dunbar2009-08-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79361 91177308-0d34-0410-b5e6-96231b3b80d8
* Mingw also doesn't have st_blksize.Dan Gohman2009-08-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79142 91177308-0d34-0410-b5e6-96231b3b80d8
* Always check to see if raw_fd_ostream's file descriptor is attached toDan Gohman2009-08-15
| | | | | | | a terminal, not just when it's STDOUT_FILENO. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79066 91177308-0d34-0410-b5e6-96231b3b80d8
* When standard output is a terminal, set outs() to be unbuffered, toDan Gohman2009-08-13
| | | | | | | | | mimic the behavior of stdtout, which is line-buffered when the output is a terminal. This fixes some issues with bugpoint output appearing being printed out of order. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78953 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a compiler warning about comparing signed with unsigned.Dan Gohman2009-08-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78933 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an assert to check copy_to_buffer's precondition.Dan Gohman2009-08-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78926 91177308-0d34-0410-b5e6-96231b3b80d8
* Set raw_os_ostream, raw_string_ostream, and raw_svector_ostream to beDan Gohman2009-08-13
| | | | | | | | | unbuffered. std::ostream does its own buffering, and std::string and SmallVector both have allocation strategies intended to handle frequent appending. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78924 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support to raw_ostream for sizing the buffer according to theDan Gohman2009-08-13
| | | | | | | | needs of the underlying output mechanism. raw_fd_ostream now uses st_blksize from fstat to determine a buffer size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78923 91177308-0d34-0410-b5e6-96231b3b80d8
* Move SetBufferSize and SetUnbuffered out of line.Dan Gohman2009-08-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78909 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the buffer handling logic so that write_impl is always called withDan Gohman2009-08-13
| | | | | | | | a full buffer, rather than often being called with a slightly-less-than-full buffer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78907 91177308-0d34-0410-b5e6-96231b3b80d8
* Add raw_ostream::write_hexDaniel Dunbar2009-07-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77614 91177308-0d34-0410-b5e6-96231b3b80d8
* Perform simplification noticed by Reid.Daniel Dunbar2009-07-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77477 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream: Follow the 32-bit path when printing "small" decimal numbers.Daniel Dunbar2009-07-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77444 91177308-0d34-0410-b5e6-96231b3b80d8
* Make raw_null_ostream flush its buffer in its destructor, so thatDan Gohman2009-07-27
| | | | | | | | it conforms to the assertion added in r77245. This fixes a failure in qa_override.c in clang's testsuite. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77255 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an assertion check to raw_ostream's destructor to verifyDan Gohman2009-07-27
| | | | | | | that the subclass hasn't left any pending data in the buffer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77245 91177308-0d34-0410-b5e6-96231b3b80d8
* Add raw_null_ostream and llvm::nulls(), a raw_ostream that discards output.Daniel Dunbar2009-07-16
| | | | | | | - No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76103 91177308-0d34-0410-b5e6-96231b3b80d8
* Use size_t.Dan Gohman2009-07-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76069 91177308-0d34-0410-b5e6-96231b3b80d8
* Change raw_ostream so that it doesn't call llvm_report_errorDan Gohman2009-07-15
| | | | | | | | | | | | | | | | | | | immediately on every output error. Instead, add a flag to raw_ostream, and set the flag whenever an error is detected. The flag can be queried and cleared from the public API. This gives applications more flexibility to handling errors in application-specific ways. If the flag is not cleared when the raw_ostream is destructed, llvm_report_error is called from the destructor. This ensures that errors are not implicitly silenced, and provides convenient default behavior for tools like llc and opt. Clients wishing to avoid llvm_report_error calls from raw_ostream should check for errors and clear the error flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75857 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a Force option to raw_fd_ostream to specify whether openingDan Gohman2009-07-15
| | | | | | | | | an existing file is considered an error. Convert several tools to use raw_fd_ostream instead of std::ostream, and to use this new option instead of doing a manual check. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75801 91177308-0d34-0410-b5e6-96231b3b80d8
* Check for errors on close(2) too. And lseek(2).Dan Gohman2009-07-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75793 91177308-0d34-0410-b5e6-96231b3b80d8
* Use 0664 instead of 0644 for the default open mode. This isDan Gohman2009-07-15
| | | | | | | | consistent with common std::ostream implmentations, and it gives the user the option of using the umask group write bit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75792 91177308-0d34-0410-b5e6-96231b3b80d8
* Detect write failures on raw_fd_ostream.Daniel Dunbar2009-07-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75758 91177308-0d34-0410-b5e6-96231b3b80d8
* Have asm printers use formatted_raw_ostream directly to avoid aDavid Greene2009-07-14
| | | | | | | dynamic_cast<>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75670 91177308-0d34-0410-b5e6-96231b3b80d8
* Make changes suggested by Chris and eliminate newly-added raw_ostreamDavid Greene2009-07-10
| | | | | | | | | | hooks as they're no longer needed. The major change with this patch is to make formatted_raw_ostream usable by any client of raw_ostream. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75283 91177308-0d34-0410-b5e6-96231b3b80d8