1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

114 Commits

Author SHA1 Message Date
NAKAMURA Takumi
cdd69c874f raw_ostream: [PR6745] Tweak formatting (double)%e for Windows hosts.
On MSVCRT and compatible, output of %e is incompatible to Posix by default. Number of exponent digits should be at least 2. "%+03d"

FIXME: Implement our formatter in future!
llvm-svn: 127872
2011-03-18 09:30:10 +00:00
NAKAMURA Takumi
341bf54557 lib/Support/raw_ostream.cpp: On mingw, report_fatal_error() should not be called at dtor context.
report_fatal_error() invokes exit(). We know report_fatal_error() might not write messages to stderr when any errors were detected on FD == 2.

llvm-svn: 127726
2011-03-16 02:53:39 +00:00
Benjamin Kramer
49043825b4 raw_ostream: while it is generally desirable to do larger writes, it can lead to
inefficient file system buffering if the writes are not a multiple of the desired
buffer size. Avoid this by limiting the large write to a multiple of the buffer
size and copying the remainder into the buffer.

Thanks to Dan for pointing this out.

llvm-svn: 127026
2011-03-04 19:49:30 +00:00
Benjamin Kramer
0376064f8f raw_ostream: If writing a string that is larger than the buffer, write it directly instead of doing many buffer-sized writes.
This caps the number of write(2) calls per string to a maximum of 2.

llvm-svn: 127010
2011-03-04 18:18:16 +00:00
Daniel Dunbar
d2c741c07a raw_fd_ostream: Add a SetUseAtomicWrites() method (uses writev).
llvm-svn: 124771
2011-02-03 03:32:32 +00:00
Michael J. Spencer
30124fea1f Support/raw_ostream: Fix uninitalized variable in raw_fd_ostream constructor.
llvm-svn: 123643
2011-01-17 15:53:12 +00:00
Michael J. Spencer
d5ec932c3a Merge System into Support.
llvm-svn: 120298
2010-11-29 18:16:10 +00:00
Daniel Dunbar
56381d8cc7 raw_ostream::write_escaped: Add a UseHexEscapes argument.
llvm-svn: 120200
2010-11-27 07:59:50 +00:00
NAKAMURA Takumi
8c67d3f400 lib/Support/raw_ostream.cpp: Fix Cygwin's build.
setmode is provided by io.h on Cygwin.

llvm-svn: 116784
2010-10-19 01:21:55 +00:00
Francois Pichet
ad0548d742 Always use binary mode for output stream. This is important to prevent unwanted end of line conversion on Windows. Should not affect Unix where O_BINARY is not defined. This fix /clang/test/lexer/preamble.c XFAIL on WIN32.
llvm-svn: 116509
2010-10-14 20:30:58 +00:00
Dan Gohman
6645ce3f75 Move tool_output_file into its own file.
llvm-svn: 115973
2010-10-07 20:32:40 +00:00
Dan Gohman
f9e09104f1 Make tool_output_file's raw_ostream instance a member variable instead
of a base class.

This makes it possible to unregister the file from FilesToRemove when
the file is done. Also, this eliminates the need for
formatted_tool_output_file.

llvm-svn: 112706
2010-09-01 14:20:41 +00:00
Dan Gohman
b316c3de4e Make outs() close its file when its stream is destructed, so that
pending output errors are detected.

llvm-svn: 111643
2010-08-20 16:44:56 +00:00
Dan Gohman
20fe555d22 Delete raw_stdout_ostream and raw_stderr_ostream, which are unused
outside of outs() and errs() themselves, and they don't really
need custom classes.

llvm-svn: 111642
2010-08-20 16:39:41 +00:00
Dan Gohman
4d1241b6b6 Move raw_ostream's Error flag into raw_fd_ostream, as that's the only
class which is using it.

llvm-svn: 111639
2010-08-20 16:34:20 +00:00
Dan Gohman
d88735e805 Introduce a new tool_output_file class, which extends raw_ostream with
functionality that most command-line tools need: ensuring that the
output file gets deleted if the tool is interrupted or encounters an
error.

llvm-svn: 111595
2010-08-20 00:48:10 +00:00
Dan Gohman
95e334dbca Make raw_fd_ostream consider itself the owner of STDOUT_FILENO when
constructed with an output filename of "-". In particular, allow the
file descriptor to be closed, and close the file descriptor in the
destructor if it hasn't been explicitly closed already, to ensure
that any write errors are detected.

llvm-svn: 111436
2010-08-18 22:26:19 +00:00
Dan Gohman
95cda1f1ef Revert r111321. This doesn't fix a problem.
llvm-svn: 111339
2010-08-18 01:34:52 +00:00
Chris Lattner
1657977d0d Fix the rest of rdar://8318441 which happens when a raw_fd_ostream
(e.g. errs()) fails in close() due to (e.g.) a broken pipe.  As
previously written, the had_error() flag would get set and then
the raw_ostream dtor would report a fatal error.  There is nothing
the client can do about this and we have no way to report the error,
so just eat it.

llvm-svn: 111321
2010-08-17 23:11:56 +00:00
Chris Lattner
aa6eb3d13d avoid undef behavior on minint, fixing PR7783.
llvm-svn: 110114
2010-08-03 16:41:24 +00:00
Chris Lattner
96566c78ef add some triple for minix, patch by Kees van Reeuwijk from PR7582
llvm-svn: 107785
2010-07-07 15:52:27 +00:00
Dan Gohman
6e97d8955f Minor code simplification.
llvm-svn: 104959
2010-05-28 16:50:23 +00:00
Dan Gohman
1c7843bad9 Fix a redundant-return warning.
llvm-svn: 104958
2010-05-28 16:50:01 +00:00
Dan Gohman
393fa6e0a2 Usage of O_NONBLOCK in bjam is now confirmed as a bug and fixed upstream.
Update the comment.

llvm-svn: 104021
2010-05-18 15:25:14 +00:00
Dan Gohman
783a114a69 Handle the case where open(2) or close(2) is interrupted by a signal when
automatic syscall restarting is disabled.

Also, fix the build on systems which don't define EWOULDBLOCK.

llvm-svn: 103158
2010-05-06 02:06:20 +00:00
Dan Gohman
3a3eadef40 Handle EWOULDBLOCK as EAGAIN. And add a comment explaining why
EAGAIN and EWOULDBLOCK are used here.

Also, handle the case where a write call is interrupted after
some data has already been written.

llvm-svn: 103153
2010-05-06 01:27:36 +00:00
Benjamin Kramer
8712466dd6 Try again if write(2) reports an recoverable error.
This should fix mysteriously crashing boost regression tests when stderr is
managed by bjam (PR7043).

llvm-svn: 103085
2010-05-05 15:17:47 +00:00
Chris Lattner
9d77e5ba47 add minix support, patch by Kees van Reeuwijk! PR6797
llvm-svn: 100895
2010-04-09 20:45:04 +00:00
Chris Lattner
80b41881bc rename llvm::llvm_report_error -> llvm::report_fatal_error
llvm-svn: 100709
2010-04-07 22:58:41 +00:00
Dan Gohman
177e2ae058 Fix minor style issues.
llvm-svn: 99414
2010-03-24 19:38:02 +00:00
Chris Lattner
f42f70bfa1 add an assertion requested on llvmdev.
llvm-svn: 97769
2010-03-05 00:49:08 +00:00
Chris Lattner
bd65f192f2 enhance raw_svector_ostream::write_impl to work with unbuffered streams,
which may call write_impl on things that are not the usual buffer.

llvm-svn: 96209
2010-02-15 02:18:26 +00:00
Benjamin Kramer
fbfb029ab0 Fix MSVC build.
llvm-svn: 94809
2010-01-29 15:19:06 +00:00
Benjamin Kramer
326bcaa5f9 Use llvm::format instead of ftostr (which just calls sprintf).
llvm-svn: 94807
2010-01-29 14:40:33 +00:00
Chris Lattner
639c136993 Changes to fix buffering that I forgot to commit with previous patch.
llvm-svn: 94222
2010-01-22 21:16:10 +00:00
Chris Lattner
20390f5205 add a new MCAsmStreamer::GetCommentOS method to simplify stuff
that doesn't want to use twines.

llvm-svn: 94199
2010-01-22 19:17:48 +00:00
Chris Lattner
e390b70e2c Make some methods const. The only interesting change here is that
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.

llvm-svn: 91740
2009-12-19 01:38:42 +00:00
Dan Gohman
8e0956f734 Micro-optimize these functions in the case where they are not inlined.
llvm-svn: 91316
2009-12-14 19:32:31 +00:00
Daniel Dunbar
5aa3eebc5d Add raw_ostream::write_escaped, for writing escaped strings.
llvm-svn: 84355
2009-10-17 20:43:08 +00:00
Daniel Dunbar
f1b6d523e4 Drop the raw_ostream required buffer size to 1.
- As best I can tell, we have eliminated all the code which used to require a
   larger buffer size.

llvm-svn: 81912
2009-09-15 20:31:46 +00:00
Dan Gohman
149ac38d37 Fix llvm-extract's "writing bitcode to a terminal" warning, which wasn't
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.

llvm-svn: 81568
2009-09-11 20:46:33 +00:00
Dan Gohman
53f0d68f87 Make LLVM command-line tools overwrite their output files without -f.
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.

llvm-svn: 79990
2009-08-25 15:34:52 +00:00
Dan Gohman
4fdc1f8e2d Correctly account for the Spaces array nul terminator. Thanks Chris!
llvm-svn: 79894
2009-08-24 04:43:38 +00:00
Dan Gohman
0c0f711f50 raw_ostream::indent is used for PadToColumn which often prints more
than 16 spaces. Make the Spaces array wide enough to handle common cases.

llvm-svn: 79890
2009-08-24 04:13:01 +00:00
Chris Lattner
98f201632e split raw_os_ostream out to its own header and implementation file. This
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.

llvm-svn: 79886
2009-08-24 04:02:06 +00:00
Chris Lattner
39262eb119 prune the #includes in raw_ostream.h by moving a
member out of line. ftostr is not particularly speedy,
so that method is presumably not perf sensitive.

llvm-svn: 79885
2009-08-24 03:52:50 +00:00
Daniel Dunbar
e58499843b Fix off-by-one in llvm::Format::print.
- 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. :)

llvm-svn: 79862
2009-08-23 20:31:39 +00:00
Benjamin Kramer
05c71d319e Fix windows build.
llvm-svn: 79845
2009-08-23 08:57:52 +00:00
Chris Lattner
f16d8ade4f Change raw_fd_ostream to take flags as an optional bitmask
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).

llvm-svn: 79807
2009-08-23 02:51:22 +00:00
Chris Lattner
b20aefd460 add a raw_ostream::indent method, to be used like:
OS.indent(i) << "whatever";

people seem to like indenting things ;-)

llvm-svn: 79784
2009-08-22 23:10:29 +00:00