aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--include/llvm/Support/MemoryBuffer.h13
-rw-r--r--lib/Support/MemoryBuffer.cpp26
2 files changed, 15 insertions, 24 deletions
diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h
index eb3e25d3db..41d4f88bfa 100644
--- a/include/llvm/Support/MemoryBuffer.h
+++ b/include/llvm/Support/MemoryBuffer.h
@@ -17,7 +17,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/System/DataTypes.h"
#include <string>
-#include <sys/stat.h>
namespace llvm {
@@ -63,12 +62,10 @@ public:
/// it has the specified size.
static MemoryBuffer *getFile(StringRef Filename,
std::string *ErrStr = 0,
- int64_t FileSize = -1,
- struct stat *FileInfo = 0);
+ int64_t FileSize = -1);
static MemoryBuffer *getFile(const char *Filename,
std::string *ErrStr = 0,
- int64_t FileSize = -1,
- struct stat *FileInfo = 0);
+ int64_t FileSize = -1);
/// getMemBuffer - Open the specified memory range as a MemoryBuffer. Note
/// that InputData must be null terminated.
@@ -104,12 +101,10 @@ public:
/// in *ErrStr with a reason.
static MemoryBuffer *getFileOrSTDIN(StringRef Filename,
std::string *ErrStr = 0,
- int64_t FileSize = -1,
- struct stat *FileInfo = 0);
+ int64_t FileSize = -1);
static MemoryBuffer *getFileOrSTDIN(const char *Filename,
std::string *ErrStr = 0,
- int64_t FileSize = -1,
- struct stat *FileInfo = 0);
+ int64_t FileSize = -1);
};
} // end namespace llvm
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;
}