1 //===- xray-registry.h - Define registry mechanism for commands. ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Implement a simple subcommand registry.
12 //===----------------------------------------------------------------------===//
13 #ifndef TOOLS_LLVM_XRAY_XRAY_REGISTRY_H
14 #define TOOLS_LLVM_XRAY_XRAY_REGISTRY_H
16 #include "llvm/Support/CommandLine.h"
17 #include "llvm/Support/Error.h"
22 // Use |CommandRegistration| as a global initialiser that registers a function
23 // and associates it with |SC|. This requires that a command has not been
24 // registered to a given |SC|.
28 // // At namespace scope.
29 // static CommandRegistration Unused(&MySubCommand, [] { ... });
31 struct CommandRegistration
{
32 CommandRegistration(cl::SubCommand
*SC
, std::function
<Error()> Command
);
35 // Requires that |SC| is not null and has an associated function to it.
36 std::function
<Error()> dispatch(cl::SubCommand
*SC
);
41 #endif // TOOLS_LLVM_XRAY_XRAY_REGISTRY_H