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
This commit is contained in:
Daniel Dunbar
2009-11-10 00:43:58 +00:00
parent 0855dee564
commit d65267ee62
4 changed files with 33 additions and 41 deletions
+6 -3
View File
@@ -160,14 +160,17 @@ bool Linker::LinkInFile(const sys::Path &File, bool &is_native) {
// Check for a file of name "-", which means "read standard input"
if (File.str() == "-") {
std::auto_ptr<Module> M;
if (MemoryBuffer *Buffer = MemoryBuffer::getSTDIN()) {
MemoryBuffer *Buffer = MemoryBuffer::getSTDIN();
if (!Buffer->getBufferSize()) {
delete Buffer;
Error = "standard input is empty";
} else {
M.reset(ParseBitcodeFile(Buffer, Context, &Error));
delete Buffer;
if (M.get())
if (!LinkInModule(M.get(), &Error))
return false;
} else
Error = "standard input is empty";
}
return error("Cannot link stdin: " + Error);
}