NAKAMURA Takumi
212c80ac5d
raw_ostream.cpp: Introduce <fcntl.h> to let O_BINARY provided. Or, llvm::outs() would be set to O_TEXT by default.
...
llvm/test/Object/check_binary_output.ll is expected to pass on win32.
llvm-svn: 186480
2013-07-17 02:21:10 +00:00
Rafael Espindola
6d35481c94
Add a wrapper for open.
...
This centralizes the handling of O_BINARY and opens the way for hiding more
differences (like how open behaves with directories).
llvm-svn: 186447
2013-07-16 19:44:17 +00:00
Rafael Espindola
e08b59f81d
Create files with mode 666. This matches the behavior of other unix tools.
...
llvm-svn: 186414
2013-07-16 14:10:07 +00:00
Rafael Espindola
cb2eca0f91
Remove the program class.
...
It was only used to implement ExecuteAndWait and ExecuteNoWait. Expose just
those two functions and make Execute and Wait implementations details.
llvm-svn: 183864
2013-06-12 20:58:35 +00:00
Chad Rosier
7ce810cb84
Don't try to generate crash diagnostics if we had an I/O failure. It's very
...
likely the crash diagnostics generation will fail as well.
Part of rdar://13296693
llvm-svn: 178163
2013-03-27 18:30:00 +00:00
Matt Beaumont-Gay
a182be8a91
Don't crash if write_impl() leaves less buffer space available than expected.
...
This was tickled by a Clang diagnostic; Clang test case to follow.
llvm-svn: 176911
2013-03-12 23:55:24 +00:00
Guy Benyei
83c74e9fad
Add static cast to unsigned char whenever a character classification function is called with a signed char argument, in order to avoid assertions in Windows Debug configuration.
...
llvm-svn: 175006
2013-02-12 21:21:59 +00:00
Chandler Carruth
ed0881b2a6
Use the new script to sort the includes of every file under lib.
...
Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.
Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]
llvm-svn: 169131
2012-12-03 16:50:05 +00:00
Benjamin Kramer
bd7f8d0260
Replace the BUILTIN_EXPECT macro with a less horrible LLVM_LIKELY/LLVM_UNLIKELY interface.
...
llvm-svn: 162873
2012-08-29 22:57:00 +00:00
Daniel Dunbar
04b4583c9b
raw_ostream: Add a has_colors() method.
...
llvm-svn: 160558
2012-07-20 18:29:41 +00:00
Galina Kistanova
7da6578291
Fixed few warnings.
...
llvm-svn: 160142
2012-07-12 20:45:36 +00:00
Benjamin Kramer
13d16f3bf3
Reapply 'Add reverseColor to raw_ostream'.
...
To be used in printing unprintable source in clang diagnostics.
Patch by Seth Cantrell, with a minor fix for mingw by me.
llvm-svn: 154805
2012-04-16 08:56:50 +00:00
Argyrios Kyrtzidis
64104f16d4
Revert r154800 which breaks windows builders.
...
llvm-svn: 154802
2012-04-16 07:59:39 +00:00
Argyrios Kyrtzidis
d17db2e0ee
Add reverseColor to raw_ostream.
...
To be used in printing unprintable source in clang diagnostics.
Patch by Seth Cantrell!
llvm-svn: 154800
2012-04-16 07:07:38 +00:00
Michael J. Spencer
a2755f8efa
Support/Program: Make Change<stream>ToBinary return error_code.
...
llvm-svn: 146522
2011-12-13 23:16:49 +00:00
Eli Friedman
53ba208c72
Avoid undefined behavior in signed integer negation. Patch by Ahmed Charles.
...
llvm-svn: 141905
2011-10-13 22:49:56 +00:00
Nick Lewycky
7bfd86d046
Fix integer overflow bug in raw_ostream::write. This showed up as a
...
non-deterministic crash in the test suite. Fixes PR10055!
llvm-svn: 138717
2011-08-28 03:30:02 +00:00
NAKAMURA Takumi
bac0d769cd
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
76e68ea916
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
dfb0ad30a8
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
acf0842088
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
4fed88704d
raw_fd_ostream: Add a SetUseAtomicWrites() method (uses writev).
...
llvm-svn: 124771
2011-02-03 03:32:32 +00:00
Michael J. Spencer
b74799090a
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
447762da85
Merge System into Support.
...
llvm-svn: 120298
2010-11-29 18:16:10 +00:00
Daniel Dunbar
65dc891942
raw_ostream::write_escaped: Add a UseHexEscapes argument.
...
llvm-svn: 120200
2010-11-27 07:59:50 +00:00
NAKAMURA Takumi
fe84f39adb
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
a3037c3abd
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
0df7ea4c24
Move tool_output_file into its own file.
...
llvm-svn: 115973
2010-10-07 20:32:40 +00:00
Dan Gohman
a2233f2801
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
e9a469115c
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
443f2d6426
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
38adfdd100
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
b87ad69350
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
c825ceefb4
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
44790e7aa7
Revert r111321. This doesn't fix a problem.
...
llvm-svn: 111339
2010-08-18 01:34:52 +00:00
Chris Lattner
ce3b2c3f77
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
3db3bb0032
avoid undef behavior on minint, fixing PR7783.
...
llvm-svn: 110114
2010-08-03 16:41:24 +00:00
Chris Lattner
ca97c92eb4
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
fb85820f9a
Minor code simplification.
...
llvm-svn: 104959
2010-05-28 16:50:23 +00:00
Dan Gohman
feaeb36edf
Fix a redundant-return warning.
...
llvm-svn: 104958
2010-05-28 16:50:01 +00:00
Dan Gohman
dea5310433
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
d351116be0
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
ef969f3539
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
ce84a2558c
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
c86cdc7d47
add minix support, patch by Kees van Reeuwijk! PR6797
...
llvm-svn: 100895
2010-04-09 20:45:04 +00:00
Chris Lattner
2104b8d36e
rename llvm::llvm_report_error -> llvm::report_fatal_error
...
llvm-svn: 100709
2010-04-07 22:58:41 +00:00
Dan Gohman
b452d4e9e4
Fix minor style issues.
...
llvm-svn: 99414
2010-03-24 19:38:02 +00:00
Chris Lattner
6783832ec2
add an assertion requested on llvmdev.
...
llvm-svn: 97769
2010-03-05 00:49:08 +00:00
Chris Lattner
115158fa4f
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
ef14f80e95
Fix MSVC build.
...
llvm-svn: 94809
2010-01-29 15:19:06 +00:00