xref: /freebsd/contrib/llvm-project/llvm/tools/llvm-remarkutil/RemarkUtil.cpp (revision e9ac41698b2f322d55ccf9da50a3596edb2c1800)
1 //===--------- llvm-remarkutil/RemarkUtil.cpp -----------------------------===//
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 /// Utility for remark files.
9 //===----------------------------------------------------------------------===//
10 
11 #include "RemarkUtilRegistry.h"
12 #include "llvm/Support/InitLLVM.h"
13 
14 using namespace llvm;
15 using namespace llvm::remarkutil;
16 ExitOnError ExitOnErr;
17 
18 static Error handleSubOptions() {
19   for (auto *SC : cl::getRegisteredSubcommands()) {
20     if (*SC) {
21       // If no subcommand was provided, we need to explicitly check if this is
22       // the top-level subcommand.
23       if (SC == &cl::SubCommand::getTopLevel())
24         break;
25       if (auto C = dispatch(SC)) {
26         return C();
27       }
28     }
29   }
30 
31   return make_error<StringError>(
32       "Please specify a subcommand. (See -help for options)",
33       inconvertibleErrorCode());
34 }
35 
36 int main(int argc, char *argv[]) {
37   InitLLVM X(argc, argv);
38   cl::ParseCommandLineOptions(argc, argv, "Remark file utilities\n");
39   ExitOnErr.setBanner(std::string(argv[0]) + ": error: ");
40   ExitOnErr(handleSubOptions());
41 }
42