llvm::Registry

A linker-supported registry of pluggable component factories.

Synopsis

Declared in <llvm/Support/Registry.h>

template<
    typename T,
    typename... CtorParamTypes>
class Registry;

Description

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.

To provide a Registry interface, follow these steps:

1. Define your plugin base interface. The interface must have a virtual destructor and the appropriate dllexport/dllimport/visibility annotation.

namespace your_ns { class YOURLIB_ABI SomethingPluginBase { virtual ~SomethingPluginBase() = default; virtual void TheInterface() = 0; }; }

2. Declare an alias to your Registry for convenience.

namespace your_ns { using YourRegistry = llvm::Registry<SomethingPluginBase>; }

3. Declare the specialization of the Registry with LLVM_DECLARE_REGISTRY in the global namespace. The declaration must be placed before any use of the YourRegistry.

LLVM_DECLARE_REGISTRY(your_ns::YourRegistry)

4. In a .cpp file, define the specialization with LLVM_DEFINE_REGISTRY in the global namespace.

LLVM_DEFINE_REGISTRY(your_ns::YourRegistry)

Types

NameDescription
Add A static registration template. Use like such:
iterator Iterators for registry entries.
node Node in linked list of entries.

Type Aliases

NameDescription
entry Registry entry type holding a name, description, and factory.
type The plugin interface type stored in this registry.

Static Member Functions

NameDescription
add_node Add a node to the Registry: this is the interface between the plugin and the executable.
begin Return an iterator to the first registered entry.
end Return an iterator past the last registered entry.
entries Return the range of all registered entries.

Static Data Members

NameDescription
HasCtorParamTypes True when the registry entry factory takes extra constructor parameters.

Friends

NameDescription
llvm::Registry::nodeNode in linked list of entries.