1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
Commit Graph

71 Commits

Author SHA1 Message Date
Dan Gohman
80c0b783ec Whitelist files and block devices instead of blacklisting fifos and
character devices.

llvm-svn: 175549
2013-02-19 19:36:55 +00:00
Dan Gohman
9dd8b6fc66 Don't trust st_size of a character device. This fixes using
/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
2013-02-19 18:57:53 +00:00
Chandler Carruth
206011250c Go ahead and get rid of the old page size interface and convert all the
users over to the new one. No sense maintaining this "compatibility"
layer it seems.

llvm-svn: 171331
2012-12-31 23:31:56 +00:00
Chandler Carruth
a490793037 Use the new script to sort the includes of every file under lib.
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
2012-12-03 16:50:05 +00:00
Daniel Dunbar
7939de2dd2 MemoryBuffer: Windows doesn't define S_IFIFO.
llvm-svn: 167467
2012-11-06 17:08:09 +00:00
Daniel Dunbar
13a2805e82 MemoryBuffer: Support reading named pipes in getFile().
- We only support this when the client didn't claim to know the file size.

llvm-svn: 167407
2012-11-05 21:55:40 +00:00
Craig Topper
36f4bfec12 Add LLVM_OVERRIDE to methods that override their base classes.
llvm-svn: 164471
2012-09-23 02:12:10 +00:00
Argyrios Kyrtzidis
4cbb37098a In MemoryBuffer::getOpenFile() don't verify that the mmap'ed
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

llvm-svn: 160075
2012-07-11 20:59:20 +00:00
Kaelyn Uhrain
ce97ce2905 Remove an "else" that snuck in after a "return" ;)
llvm-svn: 158844
2012-06-20 20:38:36 +00:00
Kaelyn Uhrain
4b2667930b Check that a file is not a directory before reading it into a MemoryBuffer.
llvm-svn: 158841
2012-06-20 20:21:33 +00:00
Argyrios Kyrtzidis
f5736f87f2 In MemoryBuffer::getOpenFile() make sure that the buffer is null-terminated if
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.

llvm-svn: 154082
2012-04-05 04:23:56 +00:00
Argyrios Kyrtzidis
62c208980d Add a sanity check in MemoryBuffer::getOpenFile() to make sure we don't hang
if the passed in FileSize is inaccurate.

rdar://11034179

llvm-svn: 152662
2012-03-13 20:18:42 +00:00
David Blaikie
96c1cf4949 Change default error_code ctor to a 'named ctor' so it's more self-documenting.
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)

llvm-svn: 150197
2012-02-09 19:24:12 +00:00
Benjamin Kramer
7120c3ef01 Add configure checking for pread(2) and use it to save a syscall when reading files.
llvm-svn: 145061
2011-11-22 12:31:53 +00:00
Benjamin Kramer
de9c504d6b Turn error recovery into an assert.
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.

llvm-svn: 145059
2011-11-22 11:37:11 +00:00
David Meyer
fd278b1f98 Remove unused include of sys/uio.h in MemoryBuffer.cpp. It was not correctly protected by ifdef either.
llvm-svn: 142623
2011-10-20 21:57:46 +00:00
Ivan Krasin
de2d3cf093 use 64-bit types instead of off_t/size_t to avoid the issue when
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.

llvm-svn: 139873
2011-09-15 23:13:00 +00:00
Chris Lattner
69a52dd280 random comment cleanups.
llvm-svn: 131829
2011-05-22 00:50:53 +00:00
Ted Kremenek
16f206d185 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
9e0fcfc02b We don't need a null terminator for the output file.
llvm-svn: 128098
2011-03-22 19:20:47 +00:00
Rafael Espindola
33eddc52d3 Check RequiresNullTerminator first, or we might read from an invalid address.
llvm-svn: 127853
2011-03-18 02:55:51 +00:00
Rafael Espindola
3ecf930d14 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
222ccb2bdd 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
a271db1a12 Add r127409 back now that the windows file was updated.
llvm-svn: 127417
2011-03-10 18:33:29 +00:00
Jakob Stoklund Olesen
891bfab351 Revert r127409 which broke all the Windows bots.
llvm-svn: 127413
2011-03-10 18:01:43 +00:00
Rafael Espindola
b7a2d86ef5 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
43f9672afa 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
c85935836b Add missing standard headers. Patch by Joerg Sonnenberger!
llvm-svn: 122193
2010-12-19 20:43:38 +00:00
Michael J. Spencer
86f6a9ac6e 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
15483143ec 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
d5ec932c3a Merge System into Support.
llvm-svn: 120298
2010-11-29 18:16:10 +00:00
Chris Lattner
80a065b474 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
a830fc6a45 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
b36c7df69c Rewrite MemoryBuffer::getSTDIN to use read(2) and a SmallVector buffer.
llvm-svn: 106856
2010-06-25 16:07:18 +00:00
Benjamin Kramer
1d187ed03e 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
afe7228ede 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
abeebe353c 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
ff9e611537 Add an explicit keyword.
llvm-svn: 106538
2010-06-22 13:53:29 +00:00
Dan Gohman
9789093ab7 Add basic error checking to MemoryBuffer::getSTDIN.
llvm-svn: 104855
2010-05-27 17:31:51 +00:00
Chris Lattner
269737461d 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
1ef6689d58 Remove accidental include and add a comment.
llvm-svn: 100107
2010-04-01 14:39:55 +00:00
Benjamin Kramer
71eaf27165 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
84ef0ef3b9 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
db1d98a624 Replace a temporary std::string with SmallString.
llvm-svn: 97259
2010-02-26 20:28:29 +00:00
Chris Lattner
0f8308d48a sizeof(char) is always 1.
llvm-svn: 92079
2009-12-23 23:03:24 +00:00
Chris Lattner
bd9a13086f 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
886e51b5c1 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
7d20275318 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
d4b8f9ee93 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
573333530f 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