use the new MemoryBuffer interfaces to simplify error reporting in clients.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36900 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2007-05-06 23:45:49 +00:00
parent 5499da8833
commit 065344dfd5
11 changed files with 27 additions and 48 deletions

View File

@@ -118,13 +118,11 @@ int main(int argc, char **argv) {
// Read in the bytecode file...
std::string ErrorMessage;
Module *M;
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&BytecodeFile[0],
BytecodeFile.size());
if (Buffer == 0)
ErrorMessage = "Error reading file '" + BytecodeFile + "'";
else
if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BytecodeFile,
&ErrorMessage)) {
M = ParseBitcodeFile(Buffer, &ErrorMessage);
delete Buffer;
delete Buffer;
}
if (M == 0) {
std::cerr << argv[0] << ": " << BytecodeFile << ": "
<< ErrorMessage << "\n";