MC/Mach-O: Shuffle enums a bit to make it harder to inadvertently use the wrong
[oota-llvm.git] / lib / Object / ObjectFile.cpp
index 0ef730bd4eb842227d7733dc7fb892f86400fdcc..aa483f357f5deba8d828a931d3158d4776024f23 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Object/ObjectFile.h"
+#include "llvm/ADT/OwningPtr.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include "llvm/System/Path.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/system_error.h"
 
 using namespace llvm;
 using namespace object;
@@ -62,5 +64,8 @@ ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) {
 }
 
 ObjectFile *ObjectFile::createObjectFile(StringRef ObjectPath) {
-  return createObjectFile(MemoryBuffer::getFile(ObjectPath));
+  OwningPtr<MemoryBuffer> File;
+  if (error_code ec = MemoryBuffer::getFile(ObjectPath, File))
+    return NULL;
+  return createObjectFile(File.take());
 }