aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/MemoryBuffer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-23 06:09:51 +0000
committerChris Lattner <sabre@nondot.org>2010-11-23 06:09:51 +0000
commit9f9bd8e4af8c5e7ae02eb5de418a49a6fdafb3f1 (patch)
tree9d68657d1c5f2a039c37268f3e58f71aba23605c /lib/Support/MemoryBuffer.cpp
parent0e11dfc4a6f7e3a3d3bc0365e1da43bc2fa0aac2 (diff)
Revert functionality doug added in r98575 that was never
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
Diffstat (limited to 'lib/Support/MemoryBuffer.cpp')
-rw-r--r--lib/Support/MemoryBuffer.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp
index 542162d513..da4685309d 100644
--- a/lib/Support/MemoryBuffer.cpp
+++ b/lib/Support/MemoryBuffer.cpp
@@ -144,20 +144,18 @@ MemoryBuffer *MemoryBuffer::getNewMemBuffer(size_t Size, StringRef BufferName) {
/// returns an empty buffer.
MemoryBuffer *MemoryBuffer::getFileOrSTDIN(StringRef Filename,
std::string *ErrStr,
- int64_t FileSize,
- struct stat *FileInfo) {
+ int64_t FileSize) {
if (Filename == "-")
return getSTDIN(ErrStr);
- return getFile(Filename, ErrStr, FileSize, FileInfo);
+ return getFile(Filename, ErrStr, FileSize);
}
MemoryBuffer *MemoryBuffer::getFileOrSTDIN(const char *Filename,
std::string *ErrStr,
- int64_t FileSize,
- struct stat *FileInfo) {
+ int64_t FileSize) {
if (strcmp(Filename, "-") == 0)
return getSTDIN(ErrStr);
- return getFile(Filename, ErrStr, FileSize, FileInfo);
+ return getFile(Filename, ErrStr, FileSize);
}
//===----------------------------------------------------------------------===//
@@ -188,13 +186,13 @@ public:
}
MemoryBuffer *MemoryBuffer::getFile(StringRef Filename, std::string *ErrStr,
- int64_t FileSize, struct stat *FileInfo) {
+ int64_t FileSize) {
SmallString<256> PathBuf(Filename.begin(), Filename.end());
- return MemoryBuffer::getFile(PathBuf.c_str(), ErrStr, FileSize, FileInfo);
+ return MemoryBuffer::getFile(PathBuf.c_str(), ErrStr, FileSize);
}
MemoryBuffer *MemoryBuffer::getFile(const char *Filename, std::string *ErrStr,
- int64_t FileSize, struct stat *FileInfo) {
+ int64_t FileSize) {
int OpenFlags = O_RDONLY;
#ifdef O_BINARY
OpenFlags |= O_BINARY; // Open input file in binary mode on win32.
@@ -208,16 +206,14 @@ MemoryBuffer *MemoryBuffer::getFile(const char *Filename, std::string *ErrStr,
// If we don't know the file size, use fstat to find out. fstat on an open
// file descriptor is cheaper than stat on a random path.
- if (FileSize == -1 || FileInfo) {
- struct stat MyFileInfo;
- struct stat *FileInfoPtr = FileInfo? FileInfo : &MyFileInfo;
-
+ if (FileSize == -1) {
+ struct stat FileInfo;
// TODO: This should use fstat64 when available.
- if (fstat(FD, FileInfoPtr) == -1) {
+ if (fstat(FD, &FileInfo) == -1) {
if (ErrStr) *ErrStr = sys::StrError();
return 0;
}
- FileSize = FileInfoPtr->st_size;
+ FileSize = FileInfo.st_size;
}