[PowerPC] Recommit r340016 after fixing the reported issue
[llvm-core.git] / tools / llvm-xray / xray-registry.h
blob6eab016273f52073b754d96bdbeff2d4c3ee3e7a
1 //===- xray-registry.h - Define registry mechanism for commands. ----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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"
19 namespace llvm {
20 namespace xray {
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|.
26 // Usage:
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);
38 } // namespace xray
39 } // namespace llvm
41 #endif // TOOLS_LLVM_XRAY_XRAY_REGISTRY_H