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
This commit is contained in:
Chris Lattner 2010-11-23 06:09:51 +00:00
parent 0e11dfc4a6
commit 9f9bd8e4af
2 changed files with 15 additions and 24 deletions

View File

@ -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

View File

@ -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;
}