[llvm-commits] [llvm] r120002 - in /llvm/trunk: include/llvm/Support/MemoryBuffer.h lib/Support/MemoryBuffer.cpp

Chris Lattner sabre at nondot.org
Mon Nov 22 22:09:52 PST 2010


Author: lattner
Date: Tue Nov 23 00:09:51 2010
New Revision: 120002

URL: http://llvm.org/viewvc/llvm-project?rev=120002&view=rev
Log:
Revert functionality doug added in r98575 that was never
documented and only used by some clang stuff I just removed.

Modified:
    llvm/trunk/include/llvm/Support/MemoryBuffer.h
    llvm/trunk/lib/Support/MemoryBuffer.cpp

Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=120002&r1=120001&r2=120002&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original)
+++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Tue Nov 23 00:09:51 2010
@@ -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 @@
   /// 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 @@
   /// 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

Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=120002&r1=120001&r2=120002&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Tue Nov 23 00:09:51 2010
@@ -144,20 +144,18 @@
 /// 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 @@
 }
 
 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 @@
   
   // 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;
   }
   
   





More information about the llvm-commits mailing list