summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-xray
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2017-03-29 04:55:45 +0000
committerDean Michael Berris <dberris@google.com>2017-03-29 04:55:45 +0000
commitf454301b56e9dda8caecad727ba80797387abd3d (patch)
tree22597c5cf914ab85f2b880e6d9870efa4e132236 /llvm/tools/llvm-xray
parentd8ca74176e25bd4080ee81982819e2ef7a36553f (diff)
downloadbcm5719-llvm-f454301b56e9dda8caecad727ba80797387abd3d.tar.gz
bcm5719-llvm-f454301b56e9dda8caecad727ba80797387abd3d.zip
[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 llvm-svn: 298975
Diffstat (limited to 'llvm/tools/llvm-xray')
-rw-r--r--llvm/tools/llvm-xray/llvm-xray.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/tools/llvm-xray/llvm-xray.cc b/llvm/tools/llvm-xray/llvm-xray.cc
index ac5faaa408b..98303e7be15 100644
--- a/llvm/tools/llvm-xray/llvm-xray.cc
+++ b/llvm/tools/llvm-xray/llvm-xray.cc
@@ -30,12 +30,20 @@ int main(int argc, char *argv[]) {
" This program consolidates multiple XRay trace "
"processing tools for convenient access.\n");
for (auto *SC : cl::getRegisteredSubcommands()) {
- if (*SC)
+ if (*SC) {
+ // If no subcommand was provided, we need to explicitly check if this is
+ // the top-level subcommand.
+ if (SC == &*cl::TopLevelSubCommand) {
+ cl::PrintHelpMessage(false, true);
+ return 0;
+ }
if (auto C = dispatch(SC)) {
ExitOnError("llvm-xray: ")(C());
return 0;
}
+ }
}
+ // If all else fails, we still print the usage message.
cl::PrintHelpMessage(false, true);
}
OpenPOWER on IntegriCloud