Add basic error checking to MemoryBuffer::getSTDIN.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104855 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2010-05-27 17:31:51 +00:00
parent 95131fcb67
commit 30377e7809
4 changed files with 26 additions and 20 deletions

View File

@ -2205,15 +2205,14 @@ LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
char **OutMessage) {
MemoryBuffer *MB = MemoryBuffer::getSTDIN();
if (!MB->getBufferSize()) {
delete MB;
*OutMessage = strdup("stdin is empty.");
return 1;
std::string Error;
if (MemoryBuffer *MB = MemoryBuffer::getSTDIN(&Error)) {
*OutMemBuf = wrap(MB);
return 0;
}
*OutMemBuf = wrap(MB);
return 0;
*OutMessage = strdup(Error.c_str());
return 1;
}
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf) {