1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 20:43:44 +02:00
Commit Graph

44 Commits

Author SHA1 Message Date
Dan Gohman
f01e53a482 Change raw_ostream so that it doesn't call llvm_report_error
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.

llvm-svn: 75857
2009-07-15 23:25:33 +00:00
Dan Gohman
2224e8e16a Fix a thinko in a comment that Duncan spotted.
llvm-svn: 75803
2009-07-15 17:34:43 +00:00
Dan Gohman
9ced780576 Add a Force option to raw_fd_ostream to specify whether opening
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.

llvm-svn: 75801
2009-07-15 17:29:42 +00:00
Dan Gohman
9f95a90619 Add a comment noting that raw_os_ostream does not check for errors.
llvm-svn: 75794
2009-07-15 16:45:52 +00:00
David Greene
a60479705b Make changes suggested by Chris and eliminate newly-added raw_ostream
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.

llvm-svn: 75283
2009-07-10 21:14:44 +00:00
David Greene
98610d5cfd Add some hooks that a redesigned AsmStream needs to do its job. These
allow derived classes to examine the stream buffer before it's flushed.

llvm-svn: 75199
2009-07-09 23:43:41 +00:00
Torok Edwin
5da9f51d1e Add support for outputting ANSI colors to raw_fd_ostream.
llvm-svn: 72854
2009-06-04 07:09:50 +00:00
Douglas Gregor
bdeba00c46 Make all raw_ostreams support the tell() function.
llvm-svn: 69583
2009-04-20 07:34:17 +00:00
Daniel Dunbar
7c98197368 Add fast path for raw_ostream output of strings.
- Particularly nice for small constant strings, which get optimized
   down nicely. On a synthetic benchmark writing out "hello" in a
   loop, this is about 2x faster with gcc and 3x faster with
   llvm-gcc. llc on insn-attrtab.bc from 403.gcc is about .5% faster.

 - I tried for a fancier solution which wouldn't increase code size as
   much (by trying to match constant arrays), but can't quite make it
   fly.

llvm-svn: 68396
2009-04-03 18:43:17 +00:00
Daniel Dunbar
e9d33b08eb raw_ostream: Return '*this' explicitly (instead of implicitly via
write) to expose more alias information.

llvm-svn: 67070
2009-03-17 01:53:36 +00:00
Daniel Dunbar
b04be1838d raw_ostream: Rework implementation of unbuffered streams so outputting
a single character requires only one branch to follow slow path.
 - Never use a buffer when writing on an unbuffered stream.

 - Move default buffer size to header.

llvm-svn: 67066
2009-03-17 01:13:35 +00:00
Daniel Dunbar
2062a58347 raw_ostream: Replace flush_impl with write_impl, which takes data to
write as arguments.
 - Add raw_ostream::GetNumBytesInBuffer.
 - Privatize buffer pointers.
 - Get rid of slow and unnecessary code for writing out large strings.

llvm-svn: 67060
2009-03-16 23:29:31 +00:00
Daniel Dunbar
c2d554fe0b raw_ostream: Lift out flush_nonempty.
- Flush a known non-empty buffers; enforces the interface to
   flush_impl and kills off HandleFlush (which I saw no reason to be
   an inline method, Chris?).

 - Clarify invariant that flush_impl is only called with OutBufCur >
   OutBufStart.

 - This also cleary collects all places where we have to deal with the
   buffer possibly not existing.

 - A few more comments and fixing the unbuffered behavior remain in
   this commit sequence.

llvm-svn: 67057
2009-03-16 22:55:06 +00:00
Daniel Dunbar
c64fdabf4f Add slow path for single character write, and use exclusively for
single characters writes outside of the fast path in raw_ostream.h

llvm-svn: 67053
2009-03-16 22:00:17 +00:00
Daniel Dunbar
0401add555 raw_ostream: unbuffered streams weren't being immediately flushed on
single character writes.

llvm-svn: 66827
2009-03-12 22:02:44 +00:00
Dan Gohman
6eec7905d5 Add an explicit keyword.
llvm-svn: 66595
2009-03-10 23:10:46 +00:00
Daniel Dunbar
b60a074565 PR3478: raw_ostream should not buffer stderr
- Add unbuffered flag to raw_ostream, forwarded by raw_fd_ostream and
   used by raw_stderr_ostream.

llvm-svn: 66545
2009-03-10 16:21:55 +00:00
Misha Brukman
7ee4196e74 Removed trailing whitespace.
llvm-svn: 65196
2009-02-20 22:51:36 +00:00
Ted Kremenek
d8045c9154 Add method raw_fd_ostream::seek() for random access within a file.
llvm-svn: 63044
2009-01-26 21:42:04 +00:00
Ted Kremenek
a851e459e1 Have raw_fd_ostream keep track of the position in the file to make tell() go faster by not requiring a flush().
llvm-svn: 60560
2008-12-04 22:51:11 +00:00
Ted Kremenek
b31e49cd47 Add 'tell' method to raw_fd_ostream that clients can use to query the current location in the file the stream is writing to.
llvm-svn: 60085
2008-11-26 03:33:13 +00:00
Daniel Dunbar
a830cb14f3 Add Binary flag to raw_fd_ostream constructor.
Document raw_fd_ostream's treatment of "-".

llvm-svn: 59219
2008-11-13 05:01:07 +00:00
Ted Kremenek
b04b85f615 Added raw_fd_ostream::close().
llvm-svn: 58052
2008-10-23 23:49:09 +00:00
Daniel Dunbar
aa7a7ae8d5 Clear raw_fd_ostream error string on success and explain behavior in
documentation.

Add C++ header marker.

llvm-svn: 57923
2008-10-21 19:53:10 +00:00
Nuno Lopes
8d481ade2f plug memleak: destroy internal buffer
llvm-svn: 55632
2008-09-02 12:06:08 +00:00
Ted Kremenek
5f192023b2 Grammar fix.
llvm-svn: 55371
2008-08-26 16:41:15 +00:00
Ted Kremenek
909c1c36e2 Added "str()" method to raw_string_ostream.
str() mirrors the same method in std::ostringstream.
str() flushes the buffered stream contents to string and returns a reference to the string.

llvm-svn: 55370
2008-08-26 16:34:01 +00:00
Chris Lattner
3ad9fe55e5 Add raw_stream adaptors that write into an std::string and SmallVector/SmallString.
llvm-svn: 55265
2008-08-23 22:43:04 +00:00
Chris Lattner
fe3155fc62 Switch the asmprinter (.ll) and all the stuff it requires over to
use raw_ostream instead of std::ostream.  Among other goodness,
this speeds up llvm-dis of kc++ with a release build from 0.85s
to 0.49s (88% faster).

Other interesting changes:
 1) This makes Value::print be non-virtual.
 2) AP[S]Int and ConstantRange can no longer print to ostream directly, 
    use raw_ostream instead.
 3) This fixes a bug in raw_os_ostream where it didn't flush itself 
    when destroyed.
 4) This adds a new SDNode::print method, instead of only allowing "dump".


A lot of APIs have both std::ostream and raw_ostream versions, it would
be useful to go through and systematically anihilate the std::ostream 
versions.

This passes dejagnu, but there may be minor fallout, plz let me know if
so and I'll fix it.

llvm-svn: 55263
2008-08-23 22:23:09 +00:00
Chris Lattner
719fad27a8 Split format() out to its own file, add support for formatting
up to three values in one call.

llvm-svn: 55251
2008-08-23 19:48:00 +00:00
Chris Lattner
9ef2c187a0 conditionalize this to work on windows, untested but it should work
according to the intarnetz

llvm-svn: 55248
2008-08-23 19:27:03 +00:00
Chris Lattner
b7914ec04e add a simple mechanism for formatted output. This gives raw_ostream's
all the power and risk of fprintf format strings.  Use them like this:

  OS << format("%10.4f", 42.0) << "\n" << format("%x", 42) << '\n';

llvm-svn: 55246
2008-08-23 19:23:10 +00:00
Nicolas Geoffray
00aced70f5 Also overload for char, since the "char" type depends on the host.
llvm-svn: 55173
2008-08-22 08:44:47 +00:00
Owen Anderson
e17306778c Overload for both signed and unsigned char.
llvm-svn: 55171
2008-08-22 07:42:25 +00:00
Owen Anderson
5a542e7eda Move non-trivial methods out of line to avoid code-size bloat.
llvm-svn: 55138
2008-08-21 20:58:52 +00:00
Owen Anderson
902453c302 Implement operator<< in terms of basic types rather than [u]int*_t, which is better for portability. There might be some way to factor this all with metaprogramming magic, but I'm not sure how offhand.
llvm-svn: 55114
2008-08-21 06:20:47 +00:00
Eli Friedman
fdab2ca258 Remove size_t operator; this unbreaks the build on Linux. Committing on
the suggestion of resistor.

If this breaks some other platform, please go ahead and back this out.

llvm-svn: 55106
2008-08-21 04:28:31 +00:00
Owen Anderson
2c1d54952b Use raw_ostream throughout the AsmPrinter.
llvm-svn: 55092
2008-08-21 00:14:44 +00:00
Chris Lattner
f155e446fd add raw_ostream method for emitting an unsigned.
llvm-svn: 54972
2008-08-19 04:23:02 +00:00
Nick Lewycky
7d6a6f4509 Fix build on GCC 4.3.
llvm-svn: 54870
2008-08-17 06:40:16 +00:00
Chris Lattner
dab4a64423 add support for a cout/cerr analog (outs()/errs()) as well as
a simple adaptor class to give raw output capabilities to 
something that wants to write to an ostream.

llvm-svn: 54865
2008-08-17 04:13:37 +00:00
Chris Lattner
eef022091c rename OutputData to 'write' to match ostream.
llvm-svn: 54857
2008-08-17 01:46:05 +00:00
Chris Lattner
fd2dd46dcd remove accidental comment.
llvm-svn: 54856
2008-08-17 01:35:54 +00:00
Chris Lattner
312d8de59b add a new raw_ostream class which is an extremely high performance ostream that
can *only* output data (no seeking, reading, etc).  This is adapted from the
clang "-E outputter", and is roughly 10% faster than stdio on darwin and 30%
(or more) faster than std::ostream.

llvm-svn: 54855
2008-08-17 01:35:29 +00:00