From 010893855823ef9f2b46587d5b4ef7738b75abfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 13 Jul 2021 16:37:26 +0200 Subject: [PATCH] [llvm][tools] Hide unrelated llvm-bcanalyzer options They otherwise show up when we link against the dynamic libLLVM.so. Differential Revision: https://reviews.llvm.org/D105893 --- test/tools/llvm-bcanalyzer/help.test | 7 ++++++ tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 29 ++++++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 test/tools/llvm-bcanalyzer/help.test diff --git a/test/tools/llvm-bcanalyzer/help.test b/test/tools/llvm-bcanalyzer/help.test new file mode 100644 index 00000000000..7e0d67562d3 --- /dev/null +++ b/test/tools/llvm-bcanalyzer/help.test @@ -0,0 +1,7 @@ +# RUN: llvm-bcanalyzer --help | FileCheck %s --check-prefix HELP --implicit-check-not='{{[Oo]}}ptions:' + +# HELP: OVERVIEW: llvm-bcanalyzer file analyzer +# HELP: USAGE +# HELP: BC Analyzer Options +# HELP: Color Options +# HELP: Generic Options diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 639a6d1ec02..ca22cc45d06 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -32,37 +32,48 @@ #include "llvm/Support/Error.h" #include "llvm/Support/InitLLVM.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" #include using namespace llvm; -static cl::opt - InputFilename(cl::Positional, cl::desc(""), cl::init("-")); +static cl::OptionCategory BCAnalyzerCategory("BC Analyzer Options"); -static cl::opt Dump("dump", cl::desc("Dump low level bitcode trace")); +static cl::opt InputFilename(cl::Positional, + cl::desc(""), + cl::init("-"), + cl::cat(BCAnalyzerCategory)); + +static cl::opt Dump("dump", cl::desc("Dump low level bitcode trace"), + cl::cat(BCAnalyzerCategory)); //===----------------------------------------------------------------------===// // Bitcode specific analysis. //===----------------------------------------------------------------------===// static cl::opt NoHistogram("disable-histogram", - cl::desc("Do not print per-code histogram")); + cl::desc("Do not print per-code histogram"), + cl::cat(BCAnalyzerCategory)); static cl::opt NonSymbolic("non-symbolic", cl::desc("Emit numeric info in dump even if" - " symbolic info is available")); + " symbolic info is available"), + cl::cat(BCAnalyzerCategory)); static cl::opt BlockInfoFilename("block-info", - cl::desc("Use the BLOCK_INFO from the given file")); + cl::desc("Use the BLOCK_INFO from the given file"), + cl::cat(BCAnalyzerCategory)); static cl::opt ShowBinaryBlobs("show-binary-blobs", - cl::desc("Print binary blobs using hex escapes")); + cl::desc("Print binary blobs using hex escapes"), + cl::cat(BCAnalyzerCategory)); static cl::opt CheckHash( "check-hash", - cl::desc("Check module hash using the argument as a string table")); + cl::desc("Check module hash using the argument as a string table"), + cl::cat(BCAnalyzerCategory)); static Error reportError(StringRef Message) { return createStringError(std::errc::illegal_byte_sequence, Message.data()); @@ -85,6 +96,8 @@ static Expected> openBitcodeFile(StringRef Path) { int main(int argc, char **argv) { InitLLVM X(argc, argv); + + cl::HideUnrelatedOptions({&BCAnalyzerCategory, &ColorCategory}); cl::ParseCommandLineOptions(argc, argv, "llvm-bcanalyzer file analyzer\n"); ExitOnError ExitOnErr("llvm-bcanalyzer: ");