From 2071b7a8b26fe2c784e138d1afb7380679c9f4dd Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 24 May 2018 11:36:57 +0000 Subject: [PATCH] [Support] Add color cl category. This commit adds a color category so tools can document this option and enables it for dwarfdump and dsymuttil. rdar://problem/40498996 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333176 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/WithColor.h | 2 ++ lib/Support/WithColor.cpp | 6 ++++-- test/tools/dsymutil/cmdline.test | 2 ++ test/tools/llvm-dwarfdump/cmdline.test | 2 ++ tools/dsymutil/dsymutil.cpp | 2 +- tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 3 ++- 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/llvm/Support/WithColor.h b/include/llvm/Support/WithColor.h index ee1e05cda32..e3559b4002a 100644 --- a/include/llvm/Support/WithColor.h +++ b/include/llvm/Support/WithColor.h @@ -14,6 +14,8 @@ namespace llvm { +extern cl::OptionCategory ColorCategory; + class raw_ostream; // Symbolic names for various syntax elements. diff --git a/lib/Support/WithColor.cpp b/lib/Support/WithColor.cpp index a663c69ac3e..d71aed9126b 100644 --- a/lib/Support/WithColor.cpp +++ b/lib/Support/WithColor.cpp @@ -13,9 +13,11 @@ using namespace llvm; +cl::OptionCategory llvm::ColorCategory("Color Options"); + static cl::opt - UseColor("color", - cl::desc("use colored syntax highlighting (default=autodetect)"), + UseColor("color", cl::cat(ColorCategory), + cl::desc("Use colors in output (default=autodetect)"), cl::init(cl::BOU_UNSET)); bool WithColor::colorsEnabled(raw_ostream &OS) { diff --git a/test/tools/dsymutil/cmdline.test b/test/tools/dsymutil/cmdline.test index c9b5b2c0efa..e010169b20e 100644 --- a/test/tools/dsymutil/cmdline.test +++ b/test/tools/dsymutil/cmdline.test @@ -2,6 +2,8 @@ RUN: dsymutil -help 2>&1 | FileCheck --check-prefix=HELP %s HELP: OVERVIEW: manipulate archived DWARF debug symbol files. HELP: USAGE: dsymutil{{[^ ]*}} [options] HELP-NOT: -reverse-iterate +HELP: Color Options +HELP: -color HELP: Specific Options: HELP: -arch= HELP: -dump-debug-map diff --git a/test/tools/llvm-dwarfdump/cmdline.test b/test/tools/llvm-dwarfdump/cmdline.test index 7fb9e8389d0..1314990a7b9 100644 --- a/test/tools/llvm-dwarfdump/cmdline.test +++ b/test/tools/llvm-dwarfdump/cmdline.test @@ -2,6 +2,8 @@ RUN: llvm-dwarfdump -h 2>&1 | FileCheck --check-prefix=HELP %s RUN: llvm-dwarfdump --help 2>&1 | FileCheck --check-prefix=HELP %s HELP: USAGE: llvm-dwarfdump{{[^ ]*}} [options] HELP-NOT: -reverse-iterate +HELP: Color Options +HELP: -color HELP: Section-specific Dump Options HELP: -debug-info - Dump the .debug_info section HELP: -eh-frame diff --git a/tools/dsymutil/dsymutil.cpp b/tools/dsymutil/dsymutil.cpp index 2ffa7d85792..7487dd9694e 100644 --- a/tools/dsymutil/dsymutil.cpp +++ b/tools/dsymutil/dsymutil.cpp @@ -393,7 +393,7 @@ int main(int argc, char **argv) { std::string SDKPath = llvm::sys::fs::getMainExecutable(argv[0], P); SDKPath = llvm::sys::path::parent_path(SDKPath); - HideUnrelatedOptions(DsymCategory); + HideUnrelatedOptions({&DsymCategory, &ColorCategory}); llvm::cl::ParseCommandLineOptions( argc, argv, "manipulate archived DWARF debug symbol files.\n\n" diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 273c535925c..300a00b01be 100644 --- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/Regex.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/ToolOutputFile.h" +#include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -513,7 +514,7 @@ int main(int argc, char **argv) { llvm::InitializeAllTargetInfos(); llvm::InitializeAllTargetMCs(); - HideUnrelatedOptions({&DwarfDumpCategory, &SectionCategory}); + HideUnrelatedOptions({&DwarfDumpCategory, &SectionCategory, &ColorCategory}); cl::ParseCommandLineOptions( argc, argv, "pretty-print DWARF debug information in object files" -- 2.11.0