[InstCombine] Signed saturation tests. NFC
[llvm-core.git] / tools / llvm-xray / xray-registry.h
blobd6fae78ea53ccc2a3b007483bb7322048c227f7b
1 //===- xray-registry.h - Define registry mechanism for commands. ----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implement a simple subcommand registry.
11 //===----------------------------------------------------------------------===//
12 #ifndef TOOLS_LLVM_XRAY_XRAY_REGISTRY_H
13 #define TOOLS_LLVM_XRAY_XRAY_REGISTRY_H
15 #include "llvm/Support/CommandLine.h"
16 #include "llvm/Support/Error.h"
18 namespace llvm {
19 namespace xray {
21 // Use |CommandRegistration| as a global initialiser that registers a function
22 // and associates it with |SC|. This requires that a command has not been
23 // registered to a given |SC|.
25 // Usage:
27 // // At namespace scope.
28 // static CommandRegistration Unused(&MySubCommand, [] { ... });
30 struct CommandRegistration {
31 CommandRegistration(cl::SubCommand *SC, std::function<Error()> Command);
34 // Requires that |SC| is not null and has an associated function to it.
35 std::function<Error()> dispatch(cl::SubCommand *SC);
37 } // namespace xray
38 } // namespace llvm
40 #endif // TOOLS_LLVM_XRAY_XRAY_REGISTRY_H