OSDN Git Service

[Support] Add color cl category.
authorJonas Devlieghere <jonas@devlieghere.com>
Thu, 24 May 2018 11:36:57 +0000 (11:36 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Thu, 24 May 2018 11:36:57 +0000 (11:36 +0000)
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
lib/Support/WithColor.cpp
test/tools/dsymutil/cmdline.test
test/tools/llvm-dwarfdump/cmdline.test
tools/dsymutil/dsymutil.cpp
tools/llvm-dwarfdump/llvm-dwarfdump.cpp

index ee1e05c..e3559b4 100644 (file)
@@ -14,6 +14,8 @@
 
 namespace llvm {
 
+extern cl::OptionCategory ColorCategory;
+
 class raw_ostream;
 
 // Symbolic names for various syntax elements.
index a663c69..d71aed9 100644 (file)
 
 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) {
index c9b5b2c..e010169 100644 (file)
@@ -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] <input files>
 HELP-NOT: -reverse-iterate
+HELP: Color Options
+HELP: -color
 HELP: Specific Options:
 HELP: -arch=<arch>
 HELP: -dump-debug-map
index 7fb9e83..1314990 100644 (file)
@@ -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] <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
index 2ffa7d8..7487dd9 100644 (file)
@@ -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"
index 273c535..300a00b 100644 (file)
@@ -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"