summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/MemoryBuffer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Don't own the buffer in object::Binary.Rafael Espindola2014-08-191-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries (like Archive) and we had to create dummy buffers just to handle that. It is also a bad fit for IRObjectFile where the Module wants to own the buffer too. Keeping this ownership would make supporting IR inside native objects particularly painful. This patch focuses in lib/Object. If something elsewhere used to own an Binary, now it also owns a MemoryBuffer. This patch introduces a few new types. * MemoryBufferRef. This is just a pair of StringRefs for the data and name. This is to MemoryBuffer as StringRef is to std::string. * OwningBinary. A combination of Binary and a MemoryBuffer. This is needed for convenience functions that take a filename and return both the buffer and the Binary using that buffer. The C api now uses OwningBinary to avoid any change in semantics. I will start a new thread to see if we want to change it and how. llvm-svn: 216002
* Fix typo.Eric Christopher2014-08-091-1/+1
| | | | llvm-svn: 215266
* Reword comment slightly.Eric Christopher2014-08-081-4/+3
| | | | llvm-svn: 215248
* getNewMemBuffer memsets the buffer to zeros,Yaron Keren2014-08-061-1/+1
| | | | | | the caller don't have to initialize it. llvm-svn: 214994
* MemoryBuffer: Don't use mmap when FileSize is multiple of 4k on Cygwin.NAKAMURA Takumi2014-08-041-0/+8
| | | | | | | | | | | On Cygwin, getpagesize() returns 64k(AllocationGranularity). In r214580, the size of X86GenInstrInfo.inc became 1499136. FIXME: We should reorganize again getPageSize() on Win32. MapFile allocates address along AllocationGranularity but view is mapped by physical page. llvm-svn: 214681
* Update the MemoryBuffer API to use ErrorOr.Rafael Espindola2014-07-061-69/+48
| | | | llvm-svn: 212405
* Finishing touch for the std::error_code transition.Rafael Espindola2014-06-131-1/+2
| | | | | | | | | | | 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. llvm-svn: 210920
* Fix build on windows.Rafael Espindola2014-06-131-1/+1
| | | | llvm-svn: 210873
* Remove 'using std::errro_code' from lib.Rafael Espindola2014-06-131-53/+54
| | | | llvm-svn: 210871
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-121-0/+1
| | | | | | This should make sure that most new uses use the std prefix. llvm-svn: 210835
* Remove system_error.h.Rafael Espindola2014-06-121-1/+1
| | | | | | | This is a minimal change to remove the header. I will remove the occurrences of "using std::error_code" in a followup patch. llvm-svn: 210803
* Don't import make_error_code into the llvm namespace.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210772
* Don't put generic_category in the llvm namespace.Rafael Espindola2014-06-121-3/+3
| | | | llvm-svn: 210737
* Use std::error_code instead of llvm::error_code.Rafael Espindola2014-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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++. llvm-svn: 210687
* There is no posix_category in std, use generic_category.Rafael Espindola2014-06-111-3/+3
| | | | llvm-svn: 210630
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-311-3/+3
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. llvm-svn: 209952
* MemoryBuffer: Use GetNativeSystemInfo()Alp Toker2014-05-191-9/+0
| | | | | | | Removes old 4096 byte workaround. This functionality has been available since Windows XP. llvm-svn: 209137
* Remove last uses of OwningPtr from llvm. As far as I can tell these method ↵Craig Topper2014-05-181-52/+0
| | | | | | versions are not used by lldb, lld, or clang. llvm-svn: 209103
* MemoryBuffer: don't force mmap when stat failsAlp Toker2014-05-091-3/+2
| | | | | | | Fix error handling introduced in r127426 that could result in MemoryBuffers not having null termination. llvm-svn: 208396
* MemoryBuffer: remove unusued definitionsAlp Toker2014-05-091-8/+0
| | | | | | These were made redundant back in r186560. llvm-svn: 208395
* [Support/MemoryBuffer] Remove the assertion that the file size did not shrink.Argyrios Kyrtzidis2014-05-061-3/+0
| | | | | | This can happen in practice with the user changing files and we can recover from it. llvm-svn: 208143
* [Support/MemoryBuffer] Rename IsVolatile -> IsVolatileSize and add a comment ↵Argyrios Kyrtzidis2014-05-061-22/+23
| | | | | | about the use case for the new parameter. llvm-svn: 208026
* [Support/MemoryBuffer] Move the IsVolatile check inside shouldUseMmap() and ↵Argyrios Kyrtzidis2014-05-061-7/+13
| | | | | | | | make sure to zero-initialize the rest of the buffer if we unexpectedly reach end-of-file while reading. llvm-svn: 208021
* [Support/MemoryBuffer] Introduce a boolean parameter (false by default) ↵Argyrios Kyrtzidis2014-05-051-18/+32
| | | | | | | | 'IsVolatile' for the open file functions. This provides a hint that the file may be changing often so mmap is avoided. llvm-svn: 208007
* [C++11] Make use of 'nullptr' in the Support library.Craig Topper2014-04-071-3/+3
| | | | llvm-svn: 205697
* [C++11] Remove 'virtual' keyword from methods marked with 'override' keyword.Craig Topper2014-03-101-4/+4
| | | | llvm-svn: 203442
* [C++11] Add overloads for externally used OwningPtr functions.Ahmed Charles2014-03-051-20/+68
| | | | | | | | 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. llvm-svn: 202959
* Switch all uses of LLVM_OVERRIDE to just use 'override' directly.Craig Topper2014-03-021-4/+4
| | | | llvm-svn: 202621
* MemoryBuffer: Increase the alignment of small file buffers to 16Reid Kleckner2013-12-161-2/+3
| | | | | | | 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. llvm-svn: 197401
* Change MemoryBuffer::getFile to take a Twine.Rafael Espindola2013-10-251-8/+12
| | | | llvm-svn: 193429
* Fix typoMatt Arsenault2013-09-101-1/+1
| | | | llvm-svn: 190424
* MemoryBuffer.cpp: Don't peek the next page if file is multiple of *physical* ↵NAKAMURA Takumi2013-09-041-0/+9
| | | | | | | | | 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. llvm-svn: 189939
* Whitespace.NAKAMURA Takumi2013-09-041-1/+1
| | | | llvm-svn: 189938
* MemoryBuffer.cpp: Consider if PageSize were not 4096 in shouldUseMmap(). ↵NAKAMURA Takumi2013-08-221-1/+1
| | | | | | | | Follow-up to r188903. The AllocationGranularity can be 65536 on Win32, even on Cygwin. llvm-svn: 188998
* Split getOpenFile into getOpenFile and getOpenFileSlice.Rafael Espindola2013-07-231-7/+25
| | | | | | | | | | | | | | | | 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. llvm-svn: 186984
* Convert two uses if fstat with sys::fs::status.Rafael Espindola2013-07-181-14/+13
| | | | llvm-svn: 186560
* Add a wrapper for open.Rafael Espindola2013-07-161-8/+4
| | | | | | | This centralizes the handling of O_BINARY and opens the way for hiding more differences (like how open behaves with directories). llvm-svn: 186447
* Remove an extra is_directory call.Rafael Espindola2013-07-151-11/+0
| | | | | | I checked that opening a directory on windows does fail, so this saves a "stat". llvm-svn: 186345
* keep only the StringRef version of getFileOrSTDIN.Rafael Espindola2013-06-251-8/+0
| | | | llvm-svn: 184826
* Remove the program class.Rafael Espindola2013-06-121-1/+1
| | | | | | | It was only used to implement ExecuteAndWait and ExecuteNoWait. Expose just those two functions and make Execute and Wait implementations details. llvm-svn: 183864
* Remove the old file memory mapping functions.Rafael Espindola2013-06-121-2/+1
| | | | llvm-svn: 183828
* Put private class into an anonmyous namespace.Benjamin Kramer2013-03-301-0/+2
| | | | llvm-svn: 178420
* [Support] Fix lifetime of file descriptors when using MemoryBuffer.Michael J. Spencer2013-03-141-1/+2
| | | | | | | Clients of MemoryBuffer::getOpenFile expect it not to take ownership of the file descriptor passed in. So don't. llvm-svn: 176995
* [Support][MemoryBuffer] Use sys::fs::mapped_file_region instead of ↵Michael J. Spencer2013-03-121-35/+44
| | | | | | | | sys::Path::MapInFilePages. This gives us memory mapped file I/O on Windows. llvm-svn: 176886
* In llvm::MemoryBuffer::getFile() remove an unnecessary stat call check.Argyrios Kyrtzidis2013-03-011-0/+3
| | | | | | | | | | 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. llvm-svn: 176386
* Update a portability kludge to keep it in sync with changes in the codeDan Gohman2013-02-191-2/+7
| | | | | | | which uses it. This is not ideal, but it ought to at least restore the behavior to what it was before. llvm-svn: 175571
* Whitelist files and block devices instead of blacklisting fifos andDan Gohman2013-02-191-3/+4
| | | | | | character devices. llvm-svn: 175549
* Don't trust st_size of a character device. This fixes usingDan Gohman2013-02-191-3/+3
| | | | | | | | | | /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. llvm-svn: 175542
* Go ahead and get rid of the old page size interface and convert all theChandler Carruth2012-12-311-2/+2
| | | | | | | users over to the new one. No sense maintaining this "compatibility" layer it seems. llvm-svn: 171331
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-3/+3
| | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud