xref: /llvm-project/llvm/tools/llvm-remarkutil/RemarkUtil.cpp (revision 30d8e0837d68a11430cc4c0f24cd743e14219a7d)
1*30d8e083SZain Jaffal //===--------- llvm-remarkutil/RemarkUtil.cpp -----------------------------===//
27d80b94cSJessica Paquette //
37d80b94cSJessica Paquette // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
47d80b94cSJessica Paquette // See https://llvm.org/LICENSE.txt for license information.
57d80b94cSJessica Paquette // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67d80b94cSJessica Paquette //
77d80b94cSJessica Paquette //===----------------------------------------------------------------------===//
87d80b94cSJessica Paquette /// Utility for remark files.
97d80b94cSJessica Paquette //===----------------------------------------------------------------------===//
107d80b94cSJessica Paquette 
11*30d8e083SZain Jaffal #include "RemarkUtilRegistry.h"
127d80b94cSJessica Paquette #include "llvm/Support/InitLLVM.h"
137d80b94cSJessica Paquette 
147d80b94cSJessica Paquette using namespace llvm;
15*30d8e083SZain Jaffal using namespace llvm::remarkutil;
16*30d8e083SZain Jaffal ExitOnError ExitOnErr;
177d80b94cSJessica Paquette 
handleSubOptions()18*30d8e083SZain Jaffal static Error handleSubOptions() {
19*30d8e083SZain Jaffal   for (auto *SC : cl::getRegisteredSubcommands()) {
20*30d8e083SZain Jaffal     if (*SC) {
21*30d8e083SZain Jaffal       // If no subcommand was provided, we need to explicitly check if this is
22*30d8e083SZain Jaffal       // the top-level subcommand.
23*30d8e083SZain Jaffal       if (SC == &cl::SubCommand::getTopLevel())
24*30d8e083SZain Jaffal         break;
25*30d8e083SZain Jaffal       if (auto C = dispatch(SC)) {
26*30d8e083SZain Jaffal         return C();
277d80b94cSJessica Paquette       }
287d80b94cSJessica Paquette     }
29a4591a61SJessica Paquette   }
30a4591a61SJessica Paquette 
317d80b94cSJessica Paquette   return make_error<StringError>(
327d80b94cSJessica Paquette       "Please specify a subcommand. (See -help for options)",
337d80b94cSJessica Paquette       inconvertibleErrorCode());
347d80b94cSJessica Paquette }
357d80b94cSJessica Paquette 
main(int argc,char * argv[])36*30d8e083SZain Jaffal int main(int argc, char *argv[]) {
377d80b94cSJessica Paquette   InitLLVM X(argc, argv);
387d80b94cSJessica Paquette   cl::ParseCommandLineOptions(argc, argv, "Remark file utilities\n");
397d80b94cSJessica Paquette   ExitOnErr.setBanner(std::string(argv[0]) + ": error: ");
40*30d8e083SZain Jaffal   ExitOnErr(handleSubOptions());
417d80b94cSJessica Paquette }
42