summaryrefslogtreecommitdiff
path: root/lib/Support/MemoryBuffer.cpp
Commit message (Collapse)AuthorAge
* Go ahead and get rid of the old page size interface and convert all theChandler Carruth2012-12-31
| | | | | | | users over to the new one. No sense maintaining this "compatibility" layer it seems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171331 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
* MemoryBuffer: Windows doesn't define S_IFIFO.Daniel Dunbar2012-11-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167467 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuffer: Support reading named pipes in getFile().Daniel Dunbar2012-11-05
| | | | | | - We only support this when the client didn't claim to know the file size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167407 91177308-0d34-0410-b5e6-96231b3b80d8
* Add LLVM_OVERRIDE to methods that override their base classes.Craig Topper2012-09-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164471 91177308-0d34-0410-b5e6-96231b3b80d8
* In MemoryBuffer::getOpenFile() don't verify that the mmap'edArgyrios Kyrtzidis2012-07-11
| | | | | | | | | | | | file buffer is null-terminated. If the file is smaller than we thought, mmap will not allow dereferencing past the pages that are enough to cover the actual file size, even though we asked for a larger address range. rdar://11612916 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160075 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove an "else" that snuck in after a "return" ;)Kaelyn Uhrain2012-06-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158844 91177308-0d34-0410-b5e6-96231b3b80d8
* Check that a file is not a directory before reading it into a MemoryBuffer.Kaelyn Uhrain2012-06-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158841 91177308-0d34-0410-b5e6-96231b3b80d8
* In MemoryBuffer::getOpenFile() make sure that the buffer is null-terminated ifArgyrios Kyrtzidis2012-04-05
| | | | | | | | | | | | | the caller requested a null-terminated one. When mapping the file there could be a racing issue that resulted in the file being larger than the FileSize passed by the caller. We already have an assertion for this in MemoryBuffer::init() but have a runtime guarantee that the buffer will be null-terminated, so do a copy that adds a null-terminator. Protects against crash of rdar://11161822. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154082 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a sanity check in MemoryBuffer::getOpenFile() to make sure we don't hangArgyrios Kyrtzidis2012-03-13
| | | | | | | | if the passed in FileSize is inaccurate. rdar://11034179 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152662 91177308-0d34-0410-b5e6-96231b3b80d8
* Change default error_code ctor to a 'named ctor' so it's more self-documenting.David Blaikie2012-02-09
| | | | | | | | | | | Unify default construction of error_code uses on this idiom so that users don't feel compelled to make static globals for naming convenience. (unfortunately I couldn't make the original ctor private as some APIs don't return their result, instead using an out parameter (that makes sense to default construct) - which is a bit of a pity. I did, however, find/fix some cases of unnecessary default construction of error_code before I hit the unfixable cases) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150197 91177308-0d34-0410-b5e6-96231b3b80d8
* Add configure checking for pread(2) and use it to save a syscall when ↵Benjamin Kramer2011-11-22
| | | | | | reading files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145061 91177308-0d34-0410-b5e6-96231b3b80d8
* Turn error recovery into an assert.Benjamin Kramer2011-11-22
| | | | | | | This was put in because in a certain version of DragonFlyBSD stat(2) lied about the size of some files. This was fixed a long time ago so we can remove the workaround. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145059 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused include of sys/uio.h in MemoryBuffer.cpp. It was not correctly ↵David Meyer2011-10-20
| | | | | | protected by ifdef either. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142623 91177308-0d34-0410-b5e6-96231b3b80d8
* use 64-bit types instead of off_t/size_t to avoid the issue whenIvan Krasin2011-09-15
| | | | | | | | | | gold plugin is built with Large File Support (sizeof(off_t) == 64 on i686) and the rest of LLVM is built w/o Large File Support (sizeof(off_t) == 32 on i686) which corrupts the stack. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139873 91177308-0d34-0410-b5e6-96231b3b80d8
* random comment cleanups.Chris Lattner2011-05-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131829 91177308-0d34-0410-b5e6-96231b3b80d8
* Add MemoryBuffer::getBufferKind() to report whether a memory buffer uses ↵Ted Kremenek2011-04-28
| | | | | | malloc'ed or mmap'ed memory. This is for performance analysis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130432 91177308-0d34-0410-b5e6-96231b3b80d8
* We don't need a null terminator for the output file.Rafael Espindola2011-03-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128098 91177308-0d34-0410-b5e6-96231b3b80d8
* Check RequiresNullTerminator first, or we might read from an invalid address.Rafael Espindola2011-03-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127853 91177308-0d34-0410-b5e6-96231b3b80d8
* Use RequiresNullTerminator to create buffers without a null terminatorRafael Espindola2011-03-17
| | | | | | instead of copying. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127835 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't compute the file size if we don't need to.Rafael Espindola2011-03-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127426 91177308-0d34-0410-b5e6-96231b3b80d8
* Add r127409 back now that the windows file was updated.Rafael Espindola2011-03-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127417 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r127409 which broke all the Windows bots.Jakob Stoklund Olesen2011-03-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127413 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for MemoryBuffers that are not null terminated and addRafael Espindola2011-03-10
| | | | | | support for creating buffers that cover only a part of a file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127409 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't open the file again in the gold plugin. To be able to do this, updateRafael Espindola2011-02-08
| | | | | | MemoryBuffer::getOpenFile to not close the file descriptor. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125128 91177308-0d34-0410-b5e6-96231b3b80d8
* Add missing standard headers. Patch by Joerg Sonnenberger!Nick Lewycky2010-12-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122193 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuffer now return an error_code and returns a OwningPtr<MemoryBuffer> ↵Michael J. Spencer2010-12-16
| | | | | | via an out parm. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121958 91177308-0d34-0410-b5e6-96231b3b80d8
* Support/MemoryBuffer: Replace all uses of std::string *ErrMsg with ↵Michael J. Spencer2010-12-09
| | | | | | error_code &ec. And fix clients. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121379 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
* add a MemoryBuffer::getOpenFile method, which turns an openChris Lattner2010-11-23
| | | | | | | file descriptor into a MemoryBuffer (and closes the FD). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120065 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert functionality doug added in r98575 that was neverChris Lattner2010-11-23
| | | | | | | documented and only used by some clang stuff I just removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120002 91177308-0d34-0410-b5e6-96231b3b80d8
* Rewrite MemoryBuffer::getSTDIN to use read(2) and a SmallVector buffer.Benjamin Kramer2010-06-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106856 91177308-0d34-0410-b5e6-96231b3b80d8
* Bring back the empty vector workaround I removed in r106839. Looks like MSVC ↵Benjamin Kramer2010-06-25
| | | | | | needs it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106841 91177308-0d34-0410-b5e6-96231b3b80d8
* Tweak MemoryBuffer to allocate the class itself, the name and possibly theBenjamin Kramer2010-06-25
| | | | | | | | | | | buffer in the same chunk of memory. 2 less mallocs for every uninitialized MemoryBuffer and 1 less malloc for every MemoryBuffer pointing to a memory range translate into 20% less mallocs on clang -cc1 -Eonly Cocoa_h.m. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106839 91177308-0d34-0410-b5e6-96231b3b80d8
* Add overloads for getFile and getFileOrSTDIN which take a const char *Dan Gohman2010-06-24
| | | | | | | | instead of a StringRef, avoiding the need to copy the string in the common case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106754 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an explicit keyword.Dan Gohman2010-06-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106538 91177308-0d34-0410-b5e6-96231b3b80d8
* Add basic error checking to MemoryBuffer::getSTDIN.Dan Gohman2010-05-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104855 91177308-0d34-0410-b5e6-96231b3b80d8
* stringref-ize the MemoryBuffer::get apis. This requiresChris Lattner2010-04-05
| | | | | | | a co-committed clang patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100485 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove accidental include and add a comment.Benjamin Kramer2010-04-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100107 91177308-0d34-0410-b5e6-96231b3b80d8
* Various improvements to MemoryBuffer::getFile:Benjamin Kramer2010-04-01
| | | | | | | | | | | | - Use a RAII object to close the FD. - Use sys::StrError instead of thread-unsafe strerror calls. - Recover gracefully if read returns zero. This works around an issue on DragonFlyBSD where /dev/null has an st_size of 136 but we can't read 136 bytes from it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100106 91177308-0d34-0410-b5e6-96231b3b80d8
* Extend MemoryBuffer::getFile() to take an optional "stat" structureDouglas Gregor2010-03-15
| | | | | | | | pointer. If given, the structure will be set with the stat information from the file actually read. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98575 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace a temporary std::string with SmallString.Benjamin Kramer2010-02-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97259 91177308-0d34-0410-b5e6-96231b3b80d8
* sizeof(char) is always 1.Chris Lattner2009-12-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92079 91177308-0d34-0410-b5e6-96231b3b80d8
* return more useful error messages by using strerror to format errnoChris Lattner2009-12-01
| | | | | | | instead of returning an ambiguous reason. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90275 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix MemoryBuffer::getSTDIN to *not* return null if stdin is empty, this is a ↵Daniel Dunbar2009-11-10
| | | | | | | | lame API. Also, Stringrefify some more MemoryBuffer functions, and add two performance FIXMEs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86630 91177308-0d34-0410-b5e6-96231b3b80d8
* A value is only assigned to errno if NumRead equals -1, so doDuncan Sands2009-11-04
| | | | | | | not reason based on errno if NumRead has a different value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86046 91177308-0d34-0410-b5e6-96231b3b80d8
* Make this code more robust by not thinking we are making progressDuncan Sands2009-11-03
| | | | | | | if zero bytes were read. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85922 91177308-0d34-0410-b5e6-96231b3b80d8
* Tweak MemoryBuffer::getSTDIN so that it returns after the first EOF. Eli Friedman2009-05-18
| | | | | | | | | It doesn't matter for piped input, but it's annoying when typing at the console. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71998 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch from new[] + delete[] to malloc + free since llvm does not catch C++ ↵Evan Cheng2009-02-13
| | | | | | exceptions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64448 91177308-0d34-0410-b5e6-96231b3b80d8
* If new[] fails, return 0 rather then trying to dereference a null pointer.Evan Cheng2009-02-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64444 91177308-0d34-0410-b5e6-96231b3b80d8