summaryrefslogtreecommitdiff
path: root/tools/opt/opt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/opt/opt.cpp')
-rw-r--r--tools/opt/opt.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 4ef1a6e39c..14e02d0e46 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -260,15 +260,12 @@ int main(int argc, char **argv) {
// Load the input module...
std::auto_ptr<Module> M;
- MemoryBuffer *Buffer
- = MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size());
-
- if (Buffer == 0)
- ErrorMessage = "Error reading file '" + InputFilename + "'";
- else
+ if (MemoryBuffer *Buffer
+ = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
M.reset(ParseBitcodeFile(Buffer, &ErrorMessage));
+ delete Buffer;
+ }
- delete Buffer;
if (M.get() == 0) {
cerr << argv[0] << ": ";
if (ErrorMessage.size())