diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-04-15 05:53:26 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-04-15 05:53:26 +0000 |
commit | 9c940420835adfc7ea3066beda3b5c3c327f0332 (patch) | |
tree | b1288d7560e94a2a3020c60209389d9b5aeba847 /include | |
parent | 5a21a893c0e935a5f1c16988d8d894e3ab88797b (diff) | |
download | llvm-9c940420835adfc7ea3066beda3b5c3c327f0332.tar.gz llvm-9c940420835adfc7ea3066beda3b5c3c327f0332.tar.bz2 llvm-9c940420835adfc7ea3066beda3b5c3c327f0332.tar.xz |
Use unique_ptr for the result of Registry entries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206248 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/Registry.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/include/llvm/Support/Registry.h b/include/llvm/Support/Registry.h index 3da2d7ca7e..b0c2e89985 100644 --- a/include/llvm/Support/Registry.h +++ b/include/llvm/Support/Registry.h @@ -14,24 +14,27 @@ #ifndef LLVM_SUPPORT_REGISTRY_H #define LLVM_SUPPORT_REGISTRY_H +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" +#include <memory> + namespace llvm { /// A simple registry entry which provides only a name, description, and /// no-argument constructor. template <typename T> class SimpleRegistryEntry { const char *Name, *Desc; - T *(*Ctor)(); + std::unique_ptr<T> (*Ctor)(); public: - SimpleRegistryEntry(const char *N, const char *D, T *(*C)()) + SimpleRegistryEntry(const char *N, const char *D, std::unique_ptr<T> (*C)()) : Name(N), Desc(D), Ctor(C) {} const char *getName() const { return Name; } const char *getDesc() const { return Desc; } - T *instantiate() const { return Ctor(); } + std::unique_ptr<T> instantiate() const { return Ctor(); } }; @@ -195,7 +198,7 @@ namespace llvm { entry Entry; node Node; - static T *CtorFn() { return new V(); } + static std::unique_ptr<T> CtorFn() { return make_unique<V>(); } public: Add(const char *Name, const char *Desc) |