[llvm-commits] CVS: llvm/include/llvm/Support/MemoryBuffer.h

Chris Lattner sabre at nondot.org
Sun May 6 16:32:59 PDT 2007



Changes in directory llvm/include/llvm/Support:

MemoryBuffer.h updated: 1.2 -> 1.3
---
Log message:

Enhance MemoryBuffer to return error messages in strings if they occur.


---
Diffs of the changes:  (+14 -2)

 MemoryBuffer.h |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)


Index: llvm/include/llvm/Support/MemoryBuffer.h
diff -u llvm/include/llvm/Support/MemoryBuffer.h:1.2 llvm/include/llvm/Support/MemoryBuffer.h:1.3
--- llvm/include/llvm/Support/MemoryBuffer.h:1.2	Sat May  5 23:41:59 2007
+++ llvm/include/llvm/Support/MemoryBuffer.h	Sun May  6 18:32:36 2007
@@ -15,6 +15,7 @@
 #define LLVM_SUPPORT_MEMORYBUFFER_H
 
 #include "llvm/Support/DataTypes.h"
+#include <string>
 
 namespace llvm {
 
@@ -52,6 +53,7 @@
   /// specified, this means that the client knows that the file exists and that
   /// it has the specified size.
   static MemoryBuffer *getFile(const char *FilenameStart, unsigned FnSize,
+                               std::string *ErrStr = 0,
                                int64_t FileSize = -1);
 
   /// getMemBuffer - Open the specified memory range as a MemoryBuffer.  Note
@@ -79,14 +81,24 @@
   
   
   /// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin
-  /// if the Filename is "-".
+  /// if the Filename is "-".  If an error occurs, this returns null and fills
+  /// in *ErrStr with a reason.
   static MemoryBuffer *getFileOrSTDIN(const char *FilenameStart,unsigned FnSize,
+                                      std::string *ErrStr = 0,
                                       int64_t FileSize = -1) {
     if (FnSize == 1 && FilenameStart[0] == '-')
       return getSTDIN();
-    return getFile(FilenameStart, FnSize, FileSize);
+    return getFile(FilenameStart, FnSize, ErrStr, FileSize);
   }
   
+  /// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin
+  /// if the Filename is "-".  If an error occurs, this returns null and fills
+  /// in *ErrStr with a reason.
+  static MemoryBuffer *getFileOrSTDIN(const std::string &FN,
+                                      std::string *ErrStr = 0,
+                                      int64_t FileSize = -1) {
+    return getFileOrSTDIN(&FN[0], FN.size(), ErrStr, FileSize);
+  }
 };
 
 } // end namespace llvm






More information about the llvm-commits mailing list