aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-06 23:32:36 +0000
committerChris Lattner <sabre@nondot.org>2007-05-06 23:32:36 +0000
commit5499da88331a31a9dcc24dc160f58b411fb0d34a (patch)
treee9fcb8c7924517177055f033ab3831a3dc078c64 /include/llvm/Support
parentc57ed8b2980fd155b9e0048670a7423184921d34 (diff)
downloadexternal_llvm-5499da88331a31a9dcc24dc160f58b411fb0d34a.zip
external_llvm-5499da88331a31a9dcc24dc160f58b411fb0d34a.tar.gz
external_llvm-5499da88331a31a9dcc24dc160f58b411fb0d34a.tar.bz2
Enhance MemoryBuffer to return error messages in strings if they occur.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36899 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/MemoryBuffer.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h
index 8067216..d7e0317 100644
--- a/include/llvm/Support/MemoryBuffer.h
+++ b/include/llvm/Support/MemoryBuffer.h
@@ -15,6 +15,7 @@
#define LLVM_SUPPORT_MEMORYBUFFER_H
#include "llvm/Support/DataTypes.h"
+#include <string>
namespace llvm {
@@ -52,6 +53,7 @@ public:
/// 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 @@ public:
/// 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