Chris Lattner
6078926e26
random comment cleanups.
...
llvm-svn: 131829
2011-05-22 00:50:53 +00:00
Ted Kremenek
e203bbb47e
Add MemoryBuffer::getBufferKind() to report whether a memory buffer uses malloc'ed or mmap'ed memory. This is for performance analysis.
...
llvm-svn: 130432
2011-04-28 20:34:18 +00:00
Rafael Espindola
2475adce37
We don't need a null terminator for the output file.
...
llvm-svn: 128098
2011-03-22 19:20:47 +00:00
Rafael Espindola
7c9cc46165
Check RequiresNullTerminator first, or we might read from an invalid address.
...
llvm-svn: 127853
2011-03-18 02:55:51 +00:00
Rafael Espindola
ab959a2e68
Use RequiresNullTerminator to create buffers without a null terminator
...
instead of copying.
llvm-svn: 127835
2011-03-17 22:18:42 +00:00
Rafael Espindola
cbe6a1ae86
Don't compute the file size if we don't need to.
...
llvm-svn: 127426
2011-03-10 20:54:07 +00:00
Rafael Espindola
258a605fce
Add r127409 back now that the windows file was updated.
...
llvm-svn: 127417
2011-03-10 18:33:29 +00:00
Jakob Stoklund Olesen
e413d9d341
Revert r127409 which broke all the Windows bots.
...
llvm-svn: 127413
2011-03-10 18:01:43 +00:00
Rafael Espindola
ea5a137e55
Add support for MemoryBuffers that are not null terminated and add
...
support for creating buffers that cover only a part of a file.
llvm-svn: 127409
2011-03-10 16:10:30 +00:00
Rafael Espindola
56e41f7f0b
Don't open the file again in the gold plugin. To be able to do this, update
...
MemoryBuffer::getOpenFile to not close the file descriptor.
llvm-svn: 125128
2011-02-08 22:40:47 +00:00
Nick Lewycky
0de20af7ba
Add missing standard headers. Patch by Joerg Sonnenberger!
...
llvm-svn: 122193
2010-12-19 20:43:38 +00:00
Michael J. Spencer
39a0ffc394
MemoryBuffer now return an error_code and returns a OwningPtr<MemoryBuffer> via an out parm.
...
llvm-svn: 121958
2010-12-16 03:29:14 +00:00
Michael J. Spencer
7b6fef82d4
Support/MemoryBuffer: Replace all uses of std::string *ErrMsg with error_code &ec. And fix clients.
...
llvm-svn: 121379
2010-12-09 17:36:48 +00:00
Michael J. Spencer
447762da85
Merge System into Support.
...
llvm-svn: 120298
2010-11-29 18:16:10 +00:00
Chris Lattner
6bf4e6d8b2
add a MemoryBuffer::getOpenFile method, which turns an open
...
file descriptor into a MemoryBuffer (and closes the FD).
llvm-svn: 120065
2010-11-23 22:20:27 +00:00
Chris Lattner
2dd97d2d60
Revert functionality doug added in r98575 that was never
...
documented and only used by some clang stuff I just removed.
llvm-svn: 120002
2010-11-23 06:09:51 +00:00
Benjamin Kramer
58e6c2eded
Rewrite MemoryBuffer::getSTDIN to use read(2) and a SmallVector buffer.
...
llvm-svn: 106856
2010-06-25 16:07:18 +00:00
Benjamin Kramer
948dd57945
Bring back the empty vector workaround I removed in r106839. Looks like MSVC needs it.
...
llvm-svn: 106841
2010-06-25 12:51:01 +00:00
Benjamin Kramer
ce2a92220f
Tweak MemoryBuffer to allocate the class itself, the name and possibly the
...
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.
llvm-svn: 106839
2010-06-25 11:50:40 +00:00
Dan Gohman
b377e2828d
Add overloads for getFile and getFileOrSTDIN which take a const char *
...
instead of a StringRef, avoiding the need to copy the string in the
common case.
llvm-svn: 106754
2010-06-24 16:25:50 +00:00
Dan Gohman
2ceaa71bdb
Add an explicit keyword.
...
llvm-svn: 106538
2010-06-22 13:53:29 +00:00
Dan Gohman
c36b1f35f0
Add basic error checking to MemoryBuffer::getSTDIN.
...
llvm-svn: 104855
2010-05-27 17:31:51 +00:00
Chris Lattner
0e45d24a4e
stringref-ize the MemoryBuffer::get apis. This requires
...
a co-committed clang patch.
llvm-svn: 100485
2010-04-05 22:42:30 +00:00
Benjamin Kramer
15630f8238
Remove accidental include and add a comment.
...
llvm-svn: 100107
2010-04-01 14:39:55 +00:00
Benjamin Kramer
10b0f3b314
Various improvements to MemoryBuffer::getFile:
...
- 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.
llvm-svn: 100106
2010-04-01 14:35:22 +00:00
Douglas Gregor
6d7d7b5197
Extend MemoryBuffer::getFile() to take an optional "stat" structure
...
pointer. If given, the structure will be set with the stat information from
the file actually read.
llvm-svn: 98575
2010-03-15 20:32:14 +00:00
Benjamin Kramer
7f98b46dc1
Replace a temporary std::string with SmallString.
...
llvm-svn: 97259
2010-02-26 20:28:29 +00:00
Chris Lattner
bd7b13f07f
sizeof(char) is always 1.
...
llvm-svn: 92079
2009-12-23 23:03:24 +00:00
Chris Lattner
0e3b78a6c2
return more useful error messages by using strerror to format errno
...
instead of returning an ambiguous reason.
llvm-svn: 90275
2009-12-01 22:51:41 +00:00
Daniel Dunbar
124fc5e252
Fix MemoryBuffer::getSTDIN to *not* return null if stdin is empty, this is a lame API.
...
Also, Stringrefify some more MemoryBuffer functions, and add two performance FIXMEs.
llvm-svn: 86630
2009-11-10 00:43:58 +00:00
Duncan Sands
d732f396a2
A value is only assigned to errno if NumRead equals -1, so do
...
not reason based on errno if NumRead has a different value.
llvm-svn: 86046
2009-11-04 20:50:23 +00:00
Duncan Sands
4afa0838d7
Make this code more robust by not thinking we are making progress
...
if zero bytes were read.
llvm-svn: 85922
2009-11-03 19:10:22 +00:00
Eli Friedman
a97f07f22d
Tweak MemoryBuffer::getSTDIN so that it returns after the first EOF.
...
It doesn't matter for piped input, but it's annoying when typing at the
console.
llvm-svn: 71998
2009-05-18 08:44:04 +00:00
Evan Cheng
cf4bd2319c
Switch from new[] + delete[] to malloc + free since llvm does not catch C++ exceptions.
...
llvm-svn: 64448
2009-02-13 08:24:55 +00:00
Evan Cheng
333db7abbd
If new[] fails, return 0 rather then trying to dereference a null pointer.
...
llvm-svn: 64444
2009-02-13 07:54:34 +00:00
Evan Cheng
86cb31862f
Fix more -Wshorten-64-to-32 warnings.
...
llvm-svn: 50659
2008-05-05 18:30:58 +00:00
Gabor Greif
659e5c4bc9
fcntl.h is pretty standard on unix (without the sys/)
...
llvm-svn: 50475
2008-04-30 08:53:22 +00:00
Bill Wendling
fc9f25dab0
Fix compilation errors on MSVC. Patch by Argiris Kirtzidis!
...
llvm-svn: 49055
2008-04-01 22:09:20 +00:00
Chris Lattner
6f2ffdb73f
Change the MemoryBuffer::getFile* methods to take just a pointer to the
...
start of a filename, not a filename+length. All clients can produce a
null terminated name, and the system api's require null terminated
strings anyway.
llvm-svn: 49041
2008-04-01 18:04:03 +00:00
Chris Lattner
a542518315
Reimplement MemoryBuffer::getFile with three enhancements:
...
1) stop using MappedFile.
2) if profitable use the sys::path::MapInFilePages api to
read the file.
3) otherwise fallback to read.
When sys::path::MapInFilePages is implemented, this provides
several benefits:
#1 : this avoids fragmenting memory for small files.
#2 : this avoids extraneous stat calls when the file size is known.
#3 : this only keeps the file descriptor open while reading the
file, not for the duration of the lifetime of the memory
buffer. This fixes a serious clang FD 'leak' problem.
I believe that this will work on a win32 machine, but I don't have
one to test on. I'd appreciate it if someone could check.
llvm-svn: 49031
2008-04-01 06:05:21 +00:00
Chris Lattner
bcfa564759
Remove the MappedFile::charBase member, rename base -> getBase() and
...
make getBase() return a const-correct pointer.
llvm-svn: 49025
2008-04-01 03:40:53 +00:00
Chris Lattner
62385ba3a0
Remove MappedFile support for mapping files for write and exec
...
and shared. This complicates the design, is not used, and probably
doesn't even work.
llvm-svn: 49022
2008-04-01 03:10:22 +00:00
Chris Lattner
f3ebc3f3d2
Remove attribution from file headers, per discussion on llvmdev.
...
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Chris Lattner
44158478bb
Fix the Linker testcase regressions, by making MemoryBuffer::getFileOrSTDIN return
...
a valid but empty buffer if stdin is empty.
llvm-svn: 44219
2007-11-18 18:52:28 +00:00
Chris Lattner
f5ea386698
Add new MemoryBuffer::getMemBufferCopy method.
...
llvm-svn: 42815
2007-10-09 21:46:38 +00:00
Reid Spencer
155533cf73
Make getSTDIN return null if the standard input is empty, as the header file
...
documentation implies and as its uses depend.
llvm-svn: 40939
2007-08-08 20:01:58 +00:00
Nick Lewycky
5105adfcd1
Fix undefined behaviour reported by the new --enable-expensive-checks option.
...
llvm-svn: 37829
2007-07-01 03:06:30 +00:00
Chris Lattner
436370bac8
fix a memory leak
...
llvm-svn: 36981
2007-05-11 00:43:26 +00:00
Jeff Cohen
b6e144cffe
Unbreak VC++ build.
...
llvm-svn: 36901
2007-05-07 15:21:46 +00:00
Chris Lattner
275757a05e
Enhance MemoryBuffer to return error messages in strings if they occur.
...
llvm-svn: 36899
2007-05-06 23:32:36 +00:00