diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-12-20 19:53:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-12-20 19:53:05 +0000 |
commit | 0b57cec536236d46e3dba9bd041533462f33dbb7 (patch) | |
tree | 56229dbdbbf76d18580f72f789003db17246c8d9 /contrib/llvm-project/llvm/tools/llvm-xray/llvm-xray.cpp | |
parent | 718ef55ec7785aae63f98f8ca05dc07ed399c16d (diff) |
Notes
Diffstat (limited to 'contrib/llvm-project/llvm/tools/llvm-xray/llvm-xray.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/tools/llvm-xray/llvm-xray.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/tools/llvm-xray/llvm-xray.cpp b/contrib/llvm-project/llvm/tools/llvm-xray/llvm-xray.cpp new file mode 100644 index 000000000000..9ee653e97b2d --- /dev/null +++ b/contrib/llvm-project/llvm/tools/llvm-xray/llvm-xray.cpp @@ -0,0 +1,48 @@ +//===- llvm-xray.cpp: XRay Tool Main Program ------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements the main entry point for the suite of XRay tools. All +// additional functionality are implemented as subcommands. +// +//===----------------------------------------------------------------------===// +// +// Basic usage: +// +// llvm-xray [options] <subcommand> [subcommand-specific options] +// +#include "xray-registry.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/raw_ostream.h" + +using namespace llvm; +using namespace llvm::xray; + +int main(int argc, char *argv[]) { + cl::ParseCommandLineOptions(argc, argv, + "XRay Tools\n\n" + " This program consolidates multiple XRay trace " + "processing tools for convenient access.\n"); + for (auto *SC : cl::getRegisteredSubcommands()) { + 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); + return 0; +} |