brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 2dd3a53 Raw
41 lines · c
1//===- RemarkUtilRegistry.h: Implement a command registry. ----------------===//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-exception6//7//===----------------------------------------------------------------------===//8//9// Implement a simple subcommand registry.10//11//===----------------------------------------------------------------------===//12#ifndef TOOLS_LLVM_REMARKUTIL_REGISTRY_H13#define TOOLS_LLVM_REMARKUTIL_REGISTRY_H14 15#include "llvm/Support/CommandLine.h"16#include "llvm/Support/Error.h"17 18namespace llvm {19namespace remarkutil {20 21// Use |CommandRegistration| as a global initialiser that registers a function22// and associates it with |SC|. This requires that a command has not been23// registered to a given |SC|.24//25// Usage:26//27//   // At namespace scope.28//   static CommandRegistration Unused(&MySubCommand, [] { ... });29//30struct CommandRegistration {31  CommandRegistration(cl::SubCommand *SC, std::function<Error()> Command);32};33 34// Requires that |SC| is not null and has an associated function to it.35std::function<Error()> dispatch(cl::SubCommand *SC);36 37} // namespace remarkutil38} // namespace llvm39 40#endif // TOOLS_LLVM_REMARKUTIL_REGISTRY_H41