Pass a std::unique_ptr& to the create??? methods is lib/Object.
[oota-llvm.git] / include / llvm / Object / MachOUniversal.h
index ba02df90714011653ffbc7f91715349084360b6b..94fe99deec52947f224325588775b9abbad51b59 100644 (file)
 #ifndef LLVM_OBJECT_MACHOUNIVERSAL_H
 #define LLVM_OBJECT_MACHOUNIVERSAL_H
 
-#include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Object/Binary.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/MachO.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/MachO.h"
 
@@ -42,7 +43,7 @@ public:
     ObjectForArch(const MachOUniversalBinary *Parent, uint32_t Index);
 
     void clear() {
-      Parent = 0;
+      Parent = nullptr;
       Index = 0;
     }
 
@@ -52,8 +53,13 @@ public:
 
     ObjectForArch getNext() const { return ObjectForArch(Parent, Index + 1); }
     uint32_t getCPUType() const { return Header.cputype; }
+    std::string getArchTypeName() const {
+      return Triple::getArchTypeName(MachOObjectFile::getArch(Header.cputype));
+    }
+
+    ErrorOr<std::unique_ptr<ObjectFile>> getAsObjectFile() const;
 
-    error_code getAsObjectFile(OwningPtr<ObjectFile> &Result) const;
+    std::error_code getAsArchive(std::unique_ptr<Archive> &Result) const;
   };
 
   class object_iterator {
@@ -77,14 +83,14 @@ public:
     }
   };
 
-  MachOUniversalBinary(MemoryBuffer *Source, error_code &ec);
+  MachOUniversalBinary(MemoryBuffer *Source, std::error_code &ec);
   static ErrorOr<MachOUniversalBinary*> create(MemoryBuffer *Source);
 
   object_iterator begin_objects() const {
     return ObjectForArch(this, 0);
   }
   object_iterator end_objects() const {
-    return ObjectForArch(0, 0);
+    return ObjectForArch(nullptr, 0);
   }
 
   uint32_t getNumberOfObjects() const { return NumberOfObjects; }
@@ -94,8 +100,8 @@ public:
     return V->isMachOUniversalBinary();
   }
 
-  error_code getObjectForArch(Triple::ArchType Arch,
-                              OwningPtr<ObjectFile> &Result) const;
+  ErrorOr<std::unique_ptr<ObjectFile>>
+  getObjectForArch(Triple::ArchType Arch) const;
 };
 
 }