summaryrefslogtreecommitdiff
path: root/lib/Support/raw_ostream.cpp
Commit message (Collapse)AuthorAge
* Revert "Introduce a string_ostream string builder facilty"Alp Toker2014-06-26
| | | | | | Temporarily back out commits r211749, r211752 and r211754. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211814 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a string_ostream string builder faciltyAlp Toker2014-06-26
| | | | | | | | | | | | | | | | | | | | string_ostream is a safe and efficient string builder that combines opaque stack storage with a built-in ostream interface. small_string_ostream<bytes> additionally permits an explicit stack storage size other than the default 128 bytes to be provided. Beyond that, storage is transferred to the heap. This convenient class can be used in most places an std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair would previously have been used, in order to guarantee consistent access without byte truncation. The patch also converts much of LLVM to use the new facility. These changes include several probable bug fixes for truncated output, a programming error that's no longer possible with the new interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211749 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-12
| | | | | | This should make sure that most new uses use the std prefix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210835 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove system_error.h.Rafael Espindola2014-06-12
| | | | | | | This is a minimal change to remove the header. I will remove the occurrences of "using std::error_code" in a followup patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210803 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper2014-04-15
| | | | | | instead of comparing to nullptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206252 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Use StringRef in raw_fd_ostream constructor"Ben Langmuir2014-02-27
| | | | | | This reverts commit r202225, which may cause a performance regression. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202338 91177308-0d34-0410-b5e6-96231b3b80d8
* Use StringRef in raw_fd_ostream constructorBen Langmuir2014-02-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202225 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace the F_Binary flag with a F_Text one.Rafael Espindola2014-02-24
| | | | | | | | | After this I will set the default back to F_None. The advantage is that before this patch forgetting to set F_Binary would corrupt a file on windows. Forgetting to set F_Text produces one that cannot be read in notepad, which is a better failure mode :-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202052 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_fd_ostream: Don't change STDERR to O_BINARY, or w*printf() (in assert()) ↵NAKAMURA Takumi2014-01-12
| | | | | | would barf wide chars after llvm::errs(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199057 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_stream formatter: [Win32] Use std::signbit() if available, instead of ↵NAKAMURA Takumi2014-01-12
| | | | | | | | _fpclass(). FIXME: It should be generic to C++11. For now, it is dedicated to mingw-w64. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199052 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_fd_ostream: Be more verbose about the reason when opening a file fails.Benjamin Kramer2013-10-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191911 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream.cpp: Introduce <fcntl.h> to let O_BINARY provided. Or, ↵NAKAMURA Takumi2013-07-17
| | | | | | | | llvm::outs() would be set to O_TEXT by default. llvm/test/Object/check_binary_output.ll is expected to pass on win32. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186480 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a wrapper for open.Rafael Espindola2013-07-16
| | | | | | | This centralizes the handling of O_BINARY and opens the way for hiding more differences (like how open behaves with directories). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186447 91177308-0d34-0410-b5e6-96231b3b80d8
* Create files with mode 666. This matches the behavior of other unix tools.Rafael Espindola2013-07-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186414 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the program class.Rafael Espindola2013-06-12
| | | | | | | It was only used to implement ExecuteAndWait and ExecuteNoWait. Expose just those two functions and make Execute and Wait implementations details. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183864 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't try to generate crash diagnostics if we had an I/O failure. It's veryChad Rosier2013-03-27
| | | | | | | | likely the crash diagnostics generation will fail as well. Part of rdar://13296693 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178163 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't crash if write_impl() leaves less buffer space available than expected.Matt Beaumont-Gay2013-03-12
| | | | | | This was tickled by a Clang diagnostic; Clang test case to follow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176911 91177308-0d34-0410-b5e6-96231b3b80d8
* Add static cast to unsigned char whenever a character classification ↵Guy Benyei2013-02-12
| | | | | | function is called with a signed char argument, in order to avoid assertions in Windows Debug configuration. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175006 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-03
| | | | | | | | | | | | | | | | | 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. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace the BUILTIN_EXPECT macro with a less horrible ↵Benjamin Kramer2012-08-29
| | | | | | LLVM_LIKELY/LLVM_UNLIKELY interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162873 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream: Add a has_colors() method.Daniel Dunbar2012-07-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160558 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed few warnings.Galina Kistanova2012-07-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160142 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply 'Add reverseColor to raw_ostream'.Benjamin Kramer2012-04-16
| | | | | | | To be used in printing unprintable source in clang diagnostics. Patch by Seth Cantrell, with a minor fix for mingw by me. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154805 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r154800 which breaks windows builders.Argyrios Kyrtzidis2012-04-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154802 91177308-0d34-0410-b5e6-96231b3b80d8
* Add reverseColor to raw_ostream.Argyrios Kyrtzidis2012-04-16
| | | | | | | To be used in printing unprintable source in clang diagnostics. Patch by Seth Cantrell! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154800 91177308-0d34-0410-b5e6-96231b3b80d8
* Support/Program: Make Change<stream>ToBinary return error_code.Michael J. Spencer2011-12-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146522 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid undefined behavior in signed integer negation. Patch by Ahmed Charles.Eli Friedman2011-10-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141905 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix integer overflow bug in raw_ostream::write. This showed up as aNick Lewycky2011-08-28
| | | | | | | non-deterministic crash in the test suite. Fixes PR10055! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138717 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream: [PR6745] Tweak formatting (double)%e for Windows hosts.NAKAMURA Takumi2011-03-18
| | | | | | | | 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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127872 91177308-0d34-0410-b5e6-96231b3b80d8
* lib/Support/raw_ostream.cpp: On mingw, report_fatal_error() should not be ↵NAKAMURA Takumi2011-03-16
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127726 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream: while it is generally desirable to do larger writes, it can lead toBenjamin Kramer2011-03-04
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127026 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream: If writing a string that is larger than the buffer, write it ↵Benjamin Kramer2011-03-04
| | | | | | | | directly instead of doing many buffer-sized writes. This caps the number of write(2) calls per string to a maximum of 2. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127010 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_fd_ostream: Add a SetUseAtomicWrites() method (uses writev).Daniel Dunbar2011-02-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124771 91177308-0d34-0410-b5e6-96231b3b80d8
* Support/raw_ostream: Fix uninitalized variable in raw_fd_ostream constructor.Michael J. Spencer2011-01-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123643 91177308-0d34-0410-b5e6-96231b3b80d8
* Merge System into Support.Michael J. Spencer2010-11-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120298 91177308-0d34-0410-b5e6-96231b3b80d8
* raw_ostream::write_escaped: Add a UseHexEscapes argument.Daniel Dunbar2010-11-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120200 91177308-0d34-0410-b5e6-96231b3b80d8
* lib/Support/raw_ostream.cpp: Fix Cygwin's build.NAKAMURA Takumi2010-10-19
| | | | | | setmode is provided by io.h on Cygwin. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116784 91177308-0d34-0410-b5e6-96231b3b80d8
* Always use binary mode for output stream. This is important to prevent ↵Francois Pichet2010-10-14
| | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116509 91177308-0d34-0410-b5e6-96231b3b80d8
* Move tool_output_file into its own file.Dan Gohman2010-10-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115973 91177308-0d34-0410-b5e6-96231b3b80d8
* Make tool_output_file's raw_ostream instance a member variable insteadDan Gohman2010-09-01
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112706 91177308-0d34-0410-b5e6-96231b3b80d8
* Make outs() close its file when its stream is destructed, so thatDan Gohman2010-08-20
| | | | | | | pending output errors are detected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111643 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete raw_stdout_ostream and raw_stderr_ostream, which are unusedDan Gohman2010-08-20
| | | | | | | | outside of outs() and errs() themselves, and they don't really need custom classes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111642 91177308-0d34-0410-b5e6-96231b3b80d8
* Move raw_ostream's Error flag into raw_fd_ostream, as that's the onlyDan Gohman2010-08-20
| | | | | | | class which is using it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111639 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a new tool_output_file class, which extends raw_ostream withDan Gohman2010-08-20
| | | | | | | | | functionality that most command-line tools need: ensuring that the output file gets deleted if the tool is interrupted or encounters an error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111595 91177308-0d34-0410-b5e6-96231b3b80d8
* Make raw_fd_ostream consider itself the owner of STDOUT_FILENO whenDan Gohman2010-08-18
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111436 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r111321. This doesn't fix a problem.Dan Gohman2010-08-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111339 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the rest of rdar://8318441 which happens when a raw_fd_ostreamChris Lattner2010-08-17
| | | | | | | | | | | | (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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111321 91177308-0d34-0410-b5e6-96231b3b80d8
* avoid undef behavior on minint, fixing PR7783.Chris Lattner2010-08-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110114 91177308-0d34-0410-b5e6-96231b3b80d8
* add some triple for minix, patch by Kees van Reeuwijk from PR7582Chris Lattner2010-07-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107785 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor code simplification.Dan Gohman2010-05-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104959 91177308-0d34-0410-b5e6-96231b3b80d8