summaryrefslogtreecommitdiffstats
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
commit7284541754f2504b841b35c75278cfb78d5df1ca (patch)
tree003c93e18fb5f495b033df4e540fcd48d2cb1029
parent4060c7ac63d8d29909bdc6a98be338f089ee98ab (diff)
downloadbcm5719-llvm-7284541754f2504b841b35c75278cfb78d5df1ca.tar.gz
bcm5719-llvm-7284541754f2504b841b35c75278cfb78d5df1ca.zip
Add a helper that either opens a file or stdin.
llvm-svn: 36835
-rw-r--r--llvm/include/llvm/Support/MemoryBuffer.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/MemoryBuffer.h b/llvm/include/llvm/Support/MemoryBuffer.h
index e4635d0e7ab..80672165f7f 100644
--- a/llvm/include/llvm/Support/MemoryBuffer.h
+++ b/llvm/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
OpenPOWER on IntegriCloud