aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-10 00:43:58 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-10 00:43:58 +0000
commit80ab6551aafc61c32f496dcce7531a4621be653b (patch)
tree50e8a65a2608845d4b1ea618b68a672d452fb725 /lib/VMCore
parent526dd742a7832e90f52ac99c24a4370d3d98d347 (diff)
downloadexternal_llvm-80ab6551aafc61c32f496dcce7531a4621be653b.zip
external_llvm-80ab6551aafc61c32f496dcce7531a4621be653b.tar.gz
external_llvm-80ab6551aafc61c32f496dcce7531a4621be653b.tar.bz2
Fix MemoryBuffer::getSTDIN to *not* return null if stdin is empty, this is a lame API.
Also, Stringrefify some more MemoryBuffer functions, and add two performance FIXMEs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86630 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Core.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index 1a34180..73fe17a 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -1987,13 +1987,15 @@ int LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
int LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
char **OutMessage) {
- if (MemoryBuffer *MB = MemoryBuffer::getSTDIN()) {
- *OutMemBuf = wrap(MB);
- return 0;
+ MemoryBuffer *MB = MemoryBuffer::getSTDIN();
+ if (!MB->getBufferSize()) {
+ delete MB;
+ *OutMessage = strdup("stdin is empty.");
+ return 1;
}
-
- *OutMessage = strdup("stdin is empty.");
- return 1;
+
+ *OutMemBuf = wrap(MB);
+ return 0;
}
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf) {