Path: blob/main/contrib/llvm-project/llvm/tools/llvm-xray/llvm-xray.cpp
35231 views
//===- llvm-xray.cpp: XRay Tool Main Program ------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements the main entry point for the suite of XRay tools. All9// additional functionality are implemented as subcommands.10//11//===----------------------------------------------------------------------===//12//13// Basic usage:14//15// llvm-xray [options] <subcommand> [subcommand-specific options]16//17#include "xray-registry.h"18#include "llvm/Support/CommandLine.h"19#include "llvm/Support/raw_ostream.h"2021using namespace llvm;22using namespace llvm::xray;2324int main(int argc, char *argv[]) {25cl::ParseCommandLineOptions(argc, argv,26"XRay Tools\n\n"27" This program consolidates multiple XRay trace "28"processing tools for convenient access.\n");29for (auto *SC : cl::getRegisteredSubcommands()) {30if (*SC) {31// If no subcommand was provided, we need to explicitly check if this is32// the top-level subcommand.33if (SC == &cl::SubCommand::getTopLevel()) {34cl::PrintHelpMessage(false, true);35return 0;36}37if (auto C = dispatch(SC)) {38ExitOnError("llvm-xray: ")(C());39return 0;40}41}42}4344// If all else fails, we still print the usage message.45cl::PrintHelpMessage(false, true);46return 0;47}484950