unique_ptrify LoadedObjectInfo::clone
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 22 May 2015 00:05:05 +0000 (00:05 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 22 May 2015 00:05:05 +0000 (00:05 +0000)
As noted in the original review, this is unused in tree & is used by
Julia... that's problematic. This API coudl easily be deleted/modified
by accident without any validation that it remains correct.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237976 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/DIContext.h
include/llvm/ExecutionEngine/RuntimeDyld.h

index d8830da56b518cdf352cdf036fae088b9a264792..da1b5e985d85cdf5cc8314ec2052557fb6ea3bc6 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/DataTypes.h"
 #include <string>
+#include <memory>
 
 namespace llvm {
 
@@ -165,11 +166,7 @@ public:
   virtual bool getLoadedSectionContents(StringRef Name, StringRef &Data) const {
     return false;
   }
-
-  /// Obtain a copy of this LoadedObjectInfo.
-  ///
-  /// The caller is responsible for deallocation once the copy is no longer required.
-  virtual LoadedObjectInfo *clone() const = 0;
+  virtual std::unique_ptr<LoadedObjectInfo> clone() const = 0;
 };
 
 }
index ac0151aa7ec1ee506312df304616bf0545958685..b882f133adba50b427fea62c3a7bc44c167f791b 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "JITSymbolFlags.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Memory.h"
 #include "llvm/DebugInfo/DIContext.h"
 #include <memory>
@@ -80,8 +81,8 @@ public:
     LoadedObjectInfoHelper(RuntimeDyldImpl &RTDyld, unsigned BeginIdx,
                            unsigned EndIdx)
         : LoadedObjectInfo(RTDyld, BeginIdx, EndIdx) {}
-    llvm::LoadedObjectInfo *clone() const override {
-      return new Derived(static_cast<const Derived &>(*this));
+    std::unique_ptr<llvm::LoadedObjectInfo> clone() const override {
+      return llvm::make_unique<Derived>(static_cast<const Derived &>(*this));
     }
   };