aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-06 04:41:59 +0000
committerChris Lattner <sabre@nondot.org>2007-05-06 04:41:59 +0000
commite96eec0c6966473ed8f71ecf4d2dd37daec29d36 (patch)
tree0076f64796fc206b75d4dda30e903cece4b7f2ed
parent9a22530696d75eb5057bb9285cdc204acb23e6bb (diff)
Add a helper that either opens a file or stdin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36835 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Support/MemoryBuffer.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h
index e4635d0e7a..80672165f7 100644
--- a/include/llvm/Support/MemoryBuffer.h
+++ b/include/llvm/Support/MemoryBuffer.h
@@ -76,6 +76,17 @@ public:
/// getSTDIN - Read all of stdin into a file buffer, and return it. This
/// fails if stdin is empty.
static MemoryBuffer *getSTDIN();
+
+
+ /// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin
+ /// if the Filename is "-".
+ static MemoryBuffer *getFileOrSTDIN(const char *FilenameStart,unsigned FnSize,
+ int64_t FileSize = -1) {
+ if (FnSize == 1 && FilenameStart[0] == '-')
+ return getSTDIN();
+ return getFile(FilenameStart, FnSize, FileSize);
+ }
+
};
} // end namespace llvm