llvm.org GIT mirror llvm / 8985450
[XRay][tools] Handle "no subcommand" case for llvm-xray Summary: Currently the llvm-xray commandline tool fails to handle the case for when no subcommand is provided in a graceful manner. This fixes that to print the help message explaining the subcommands and the available options. Reviewers: pcc, pelikan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31409 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298975 91177308-0d34-0410-b5e6-96231b3b80d8 Dean Michael Berris 3 years ago
2 changed file(s) with 12 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-xray | FileCheck %s
1
2 ; CHECK: OVERVIEW: XRay Tools
2929 " This program consolidates multiple XRay trace "
3030 "processing tools for convenient access.\n");
3131 for (auto *SC : cl::getRegisteredSubcommands()) {
32 if (*SC)
32 if (*SC) {
33 // If no subcommand was provided, we need to explicitly check if this is
34 // the top-level subcommand.
35 if (SC == &*cl::TopLevelSubCommand) {
36 cl::PrintHelpMessage(false, true);
37 return 0;
38 }
3339 if (auto C = dispatch(SC)) {
3440 ExitOnError("llvm-xray: ")(C());
3541 return 0;
3642 }
43 }
3744 }
3845
46 // If all else fails, we still print the usage message.
3947 cl::PrintHelpMessage(false, true);
4048 }