[Lldb-commits] [PATCH] D120593: [Support] Allow the ability to change WithColor's auto detection function

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 25 15:14:06 PST 2022


JDevlieghere created this revision.
JDevlieghere added reviewers: aprantl, RKSimon, jdenny.
Herald added subscribers: dexonsmith, hiraditya.
JDevlieghere requested review of this revision.
Herald added a project: LLVM.

`WithColor` has an "auto detection mode" which looks whether the corresponding  whether the corresponding cl::opt is enabled or not. While this is great when opting into cl::opt, it's not so great for downstream users of this utility, which might have their own competing options to enable or disable colors. The `WithColor` constructor takes a color mode, but the big benefit of the class are its static `error` and `warning` helpers and default error handlers.

In order to allow users of this utility to enable or disable colors globally, this patch adds the ability to specify a global auto detection function. By default, the auto detection function behaves the way that it does today. The benefit of this patch lies in that it can be overwritten. In addition to a ability to change the auto detection function, I've also made it possible to get your hands on the default auto detection function, so you swap it back if if you so desire.

This patch allow downstream users (like LLDB) to globally disable colors with its own command line flag.


https://reviews.llvm.org/D120593

Files:
  lldb/tools/driver/Driver.cpp
  llvm/include/llvm/Support/WithColor.h
  llvm/lib/Support/WithColor.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120593.411529.patch
Type: text/x-patch
Size: 3554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220225/c55868a8/attachment.bin>


More information about the lldb-commits mailing list