#ifndef LLVM_SUPPORT_REGISTRY_H
#define LLVM_SUPPORT_REGISTRY_H
+#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"
-
#include <memory>
namespace llvm {
std::unique_ptr<T> instantiate() const { return Ctor(); }
};
-
/// Traits for registry entries. If using other than SimpleRegistryEntry, it
/// is necessary to define an alternate traits class.
template <typename T>
class RegistryTraits {
- RegistryTraits() LLVM_DELETED_FUNCTION;
+ RegistryTraits() = delete;
public:
typedef SimpleRegistryEntry<T> entry;
static const char *descof(const entry &Entry) { return Entry.getDesc(); }
};
-
/// A global registry used in conjunction with static constructors to make
/// pluggable components (like targets or garbage collectors) "just work" when
/// linked with an executable.
class iterator;
private:
- Registry() LLVM_DELETED_FUNCTION;
+ Registry() = delete;
static void Announce(const entry &E) {
for (listener *Cur = ListenerHead; Cur; Cur = Cur->Next)
}
};
-
/// Iterators for registry entries.
///
class iterator {
static iterator begin() { return iterator(Head); }
static iterator end() { return iterator(nullptr); }
+ static iterator_range<iterator> entries() {
+ return iterator_range<iterator>(begin(), end());
+ }
/// Abstract base class for registry listeners, which are informed when new
/// entries are added to the registry. Simply subclass and instantiate:
}
public:
- listener() : Prev(ListenerTail), Next(0) {
+ listener() : Prev(ListenerTail), Next(nullptr) {
if (Prev)
Prev->Next = this;
else
}
};
-
/// A static registration template. Use like such:
///
/// Registry<Collector>::Add<FancyGC>
};
/// Registry::Parser now lives in llvm/Support/RegistryParser.h.
-
};
// Since these are defined in a header file, plugins must be sure to export
template <typename T, typename U>
typename Registry<T,U>::listener *Registry<T,U>::ListenerTail;
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_REGISTRY_H