summaryrefslogtreecommitdiff
path: root/lib/Support/MemoryBuffer.cpp
Commit message (Collapse)AuthorAge
* Finishing touch for the std::error_code transition.Rafael Espindola2014-06-13
| | | | | | | | | | | While std::error_code itself seems to work OK in all platforms, there are few annoying differences with regards to the std::errc enumeration. This patch adds a simple llvm enumeration, which will hopefully avoid build breakages in other platforms and surprises as we get more uses of std::error_code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210920 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix build on windows.Rafael Espindola2014-06-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210873 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove 'using std::errro_code' from lib.Rafael Espindola2014-06-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210871 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
* Don't import make_error_code into the llvm namespace.Rafael Espindola2014-06-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210772 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't put generic_category in the llvm namespace.Rafael Espindola2014-06-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210737 91177308-0d34-0410-b5e6-96231b3b80d8
* Use std::error_code instead of llvm::error_code.Rafael Espindola2014-06-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea of this patch is to turn llvm/Support/system_error.h into a transitional header that just brings in the erorr_code api to the llvm namespace. I will remove it shortly afterwards. The cases where the general idea needed some tweaking: * std::errc is a namespace in msvc, so we cannot use "using std::errc". I could add an #ifdef, but there were not that many uses, so I just added std:: to them in this patch. * Template specialization had to be moved to the std namespace in this patch set already. * The msvc implementation of default_error_condition doesn't seem to provide the same transformations as we need. Not too surprising since the standard doesn't actually say what "equivalent" means. I fixed the problem by keeping our old mapping and using it at error_code construction time. Despite these shortcomings I think this is still a good thing. Some reasons: * The different implementations of system_error might improve over time. * It removes 925 lines of code from llvm already. * It removes 6313 bytes from the text segment of the clang binary when it is built with gcc and 2816 bytes when building with clang and libstdc++. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210687 91177308-0d34-0410-b5e6-96231b3b80d8
* There is no posix_category in std, use generic_category.Rafael Espindola2014-06-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210630 91177308-0d34-0410-b5e6-96231b3b80d8
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-31
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209952 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuffer: Use GetNativeSystemInfo()Alp Toker2014-05-19
| | | | | | | Removes old 4096 byte workaround. This functionality has been available since Windows XP. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209137 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove last uses of OwningPtr from llvm. As far as I can tell these method ↵Craig Topper2014-05-18
| | | | | | versions are not used by lldb, lld, or clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209103 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuffer: don't force mmap when stat failsAlp Toker2014-05-09
| | | | | | | Fix error handling introduced in r127426 that could result in MemoryBuffers not having null termination. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208396 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuffer: remove unusued definitionsAlp Toker2014-05-09
| | | | | | These were made redundant back in r186560. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208395 91177308-0d34-0410-b5e6-96231b3b80d8
* [Support/MemoryBuffer] Remove the assertion that the file size did not shrink.Argyrios Kyrtzidis2014-05-06
| | | | | | | This can happen in practice with the user changing files and we can recover from it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208143 91177308-0d34-0410-b5e6-96231b3b80d8
* [Support/MemoryBuffer] Rename IsVolatile -> IsVolatileSize and add a comment ↵Argyrios Kyrtzidis2014-05-06
| | | | | | about the use case for the new parameter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208026 91177308-0d34-0410-b5e6-96231b3b80d8
* [Support/MemoryBuffer] Move the IsVolatile check inside shouldUseMmap() and ↵Argyrios Kyrtzidis2014-05-06
| | | | | | | | | make sure to zero-initialize the rest of the buffer if we unexpectedly reach end-of-file while reading. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208021 91177308-0d34-0410-b5e6-96231b3b80d8
* [Support/MemoryBuffer] Introduce a boolean parameter (false by default) ↵Argyrios Kyrtzidis2014-05-05
| | | | | | | | | 'IsVolatile' for the open file functions. This provides a hint that the file may be changing often so mmap is avoided. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208007 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Make use of 'nullptr' in the Support library.Craig Topper2014-04-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205697 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Remove 'virtual' keyword from methods marked with 'override' keyword.Craig Topper2014-03-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203442 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Add overloads for externally used OwningPtr functions.Ahmed Charles2014-03-05
| | | | | | | | This will allow external callers of these functions to switch over time rather than forcing a breaking change all a once. These particular functions were determined by building clang/lld/lldb. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202959 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch all uses of LLVM_OVERRIDE to just use 'override' directly.Craig Topper2014-03-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202621 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuffer: Increase the alignment of small file buffers to 16Reid Kleckner2013-12-16
| | | | | | | This was manifesting as an LLVM_ASSUME_ALIGNED() failure in an ELF debug info test when building LLVM with clang in the Microsoft C++ ABI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197401 91177308-0d34-0410-b5e6-96231b3b80d8
* Change MemoryBuffer::getFile to take a Twine.Rafael Espindola2013-10-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193429 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typoMatt Arsenault2013-09-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190424 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuffer.cpp: Don't peek the next page if file is multiple of *physical* ↵NAKAMURA Takumi2013-09-04
| | | | | | | | | | pagesize(4k) but is not multiple of AllocationGranularity(64k), when a null terminator is required, on cygwin and win32. For example, r189780's SparcISelLowering.cpp has the size 98304. It crashed clang to touch a null terminator on cygwin. FIXME: It's not good to hardcode 4096 here. dwPageSize shows 4096. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189939 91177308-0d34-0410-b5e6-96231b3b80d8
* Whitespace.NAKAMURA Takumi2013-09-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189938 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuffer.cpp: Consider if PageSize were not 4096 in shouldUseMmap(). ↵NAKAMURA Takumi2013-08-22
| | | | | | | | Follow-up to r188903. The AllocationGranularity can be 65536 on Win32, even on Cygwin. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188998 91177308-0d34-0410-b5e6-96231b3b80d8
* Split getOpenFile into getOpenFile and getOpenFileSlice.Rafael Espindola2013-07-23
| | | | | | | | | | | | | | | | The main observation is that we never need both the filesize and the map size. When mapping a slice of a file, it doesn't make sense to request a null terminator and that would be the only case where the filesize would be used. There are other cleanups that should be done in this area: * A client should not have to pass the size (even an explicit -1) to say if it wants a null terminator or not, so we should probably swap the argument order. * The default should be to not require a null terminator. Very few clients require this, but many end up asking for it just because it is the default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186984 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert two uses if fstat with sys::fs::status.Rafael Espindola2013-07-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186560 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
* Remove an extra is_directory call.Rafael Espindola2013-07-15
| | | | | | I checked that opening a directory on windows does fail, so this saves a "stat". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186345 91177308-0d34-0410-b5e6-96231b3b80d8
* keep only the StringRef version of getFileOrSTDIN.Rafael Espindola2013-06-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184826 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
* Remove the old file memory mapping functions.Rafael Espindola2013-06-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183828 91177308-0d34-0410-b5e6-96231b3b80d8
* Put private class into an anonmyous namespace.Benjamin Kramer2013-03-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178420 91177308-0d34-0410-b5e6-96231b3b80d8
* [Support] Fix lifetime of file descriptors when using MemoryBuffer.Michael J. Spencer2013-03-14
| | | | | | | Clients of MemoryBuffer::getOpenFile expect it not to take ownership of the file descriptor passed in. So don't. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176995 91177308-0d34-0410-b5e6-96231b3b80d8
* [Support][MemoryBuffer] Use sys::fs::mapped_file_region instead of ↵Michael J. Spencer2013-03-12
| | | | | | | | sys::Path::MapInFilePages. This gives us memory mapped file I/O on Windows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176886 91177308-0d34-0410-b5e6-96231b3b80d8
* In llvm::MemoryBuffer::getFile() remove an unnecessary stat call check.Argyrios Kyrtzidis2013-03-01
| | | | | | | | | | The sys::fs::is_directory() check is unnecessary because, if the filename is a directory, the function will fail anyway with the same error code returned. Remove the check to avoid an unnecessary stat call. Someone needs to review on windows and see if the check is necessary there or not. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176386 91177308-0d34-0410-b5e6-96231b3b80d8
* Update a portability kludge to keep it in sync with changes in the codeDan Gohman2013-02-19
| | | | | | | | which uses it. This is not ideal, but it ought to at least restore the behavior to what it was before. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175571 91177308-0d34-0410-b5e6-96231b3b80d8
* Whitelist files and block devices instead of blacklisting fifos andDan Gohman2013-02-19
| | | | | | | character devices. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175549 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't trust st_size of a character device. This fixes usingDan Gohman2013-02-19
| | | | | | | | | | | /dev/stdin as an input when stdin is connected to a tty, for example. No test, because it's difficult to write a reasonably portable test for this. /dev/stdin isn't a character device when stdin is redirected from a file or connected to a pipe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175542 91177308-0d34-0410-b5e6-96231b3b80d8
* 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