[llvm] r333176 - [Support] Add color cl category.

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Thu May 24 04:36:57 PDT 2018


Author: jdevlieghere
Date: Thu May 24 04:36:57 2018
New Revision: 333176

URL: http://llvm.org/viewvc/llvm-project?rev=333176&view=rev
Log:
[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

Modified:
    llvm/trunk/include/llvm/Support/WithColor.h
    llvm/trunk/lib/Support/WithColor.cpp
    llvm/trunk/test/tools/dsymutil/cmdline.test
    llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test
    llvm/trunk/tools/dsymutil/dsymutil.cpp
    llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Modified: llvm/trunk/include/llvm/Support/WithColor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/WithColor.h?rev=333176&r1=333175&r2=333176&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/WithColor.h (original)
+++ llvm/trunk/include/llvm/Support/WithColor.h Thu May 24 04:36:57 2018
@@ -14,6 +14,8 @@
 
 namespace llvm {
 
+extern cl::OptionCategory ColorCategory;
+
 class raw_ostream;
 
 // Symbolic names for various syntax elements.

Modified: llvm/trunk/lib/Support/WithColor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/WithColor.cpp?rev=333176&r1=333175&r2=333176&view=diff
==============================================================================
--- llvm/trunk/lib/Support/WithColor.cpp (original)
+++ llvm/trunk/lib/Support/WithColor.cpp Thu May 24 04:36:57 2018
@@ -13,9 +13,11 @@
 
 using namespace llvm;
 
+cl::OptionCategory llvm::ColorCategory("Color Options");
+
 static cl::opt<cl::boolOrDefault>
-    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) {

Modified: llvm/trunk/test/tools/dsymutil/cmdline.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/cmdline.test?rev=333176&r1=333175&r2=333176&view=diff
==============================================================================
--- llvm/trunk/test/tools/dsymutil/cmdline.test (original)
+++ llvm/trunk/test/tools/dsymutil/cmdline.test Thu May 24 04:36:57 2018
@@ -2,6 +2,8 @@ RUN: dsymutil -help 2>&1 | FileCheck --c
 HELP: OVERVIEW: manipulate archived DWARF debug symbol files.
 HELP: USAGE: dsymutil{{[^ ]*}} [options] <input files>
 HELP-NOT: -reverse-iterate
+HELP: Color Options
+HELP: -color
 HELP: Specific Options:
 HELP: -arch=<arch>
 HELP: -dump-debug-map

Modified: llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test?rev=333176&r1=333175&r2=333176&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test Thu May 24 04:36:57 2018
@@ -2,6 +2,8 @@ RUN: llvm-dwarfdump -h 2>&1 | FileCheck
 RUN: llvm-dwarfdump --help 2>&1 | FileCheck --check-prefix=HELP %s
 HELP: USAGE: llvm-dwarfdump{{[^ ]*}} [options] <input object files or .dSYM bundles>
 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

Modified: llvm/trunk/tools/dsymutil/dsymutil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/dsymutil.cpp?rev=333176&r1=333175&r2=333176&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/dsymutil.cpp (original)
+++ llvm/trunk/tools/dsymutil/dsymutil.cpp Thu May 24 04:36:57 2018
@@ -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"

Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=333176&r1=333175&r2=333176&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Thu May 24 04:36:57 2018
@@ -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"




More information about the llvm-commits mailing list