Replace the DisableColors with a ColorMode which can be set to Auto, Enabled and Disabled. The purpose of this change is to make it possible to ignore raw_ostream::has_colors() not only for disabling colors, but also for enabling them.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Seems reasonable. Should there be some kind of unit-testing involved?
It might be nice (not now but in the future) to change the interface of the WithColor constructors, to change the DisableColors boolean into the ColorMode enum too.
It is a good idea. WithColor does not have unit tests yet (llvm/unittests/Support/WithColorTest.cpp)
It might be nice (not now but in the future) to change the interface of the WithColor constructors, to change the DisableColors boolean into the ColorMode enum too.
llvm/unittests/Support/WithColorTest.cpp | ||
---|---|---|
39 ↗ | (On Diff #268257) | Not sure if this works on Windows, I'll have to double check. |
LGTM, assuming the unit test works.
llvm/unittests/Support/WithColorTest.cpp | ||
---|---|---|
39 ↗ | (On Diff #268257) | I tried checking, but had trouble applying the parent patch for some reason. Not sure why, sorry. |
With the new approach this change isn't strictly necessary for D81058 to work, but I still think it's an (small) improvement over the status quo. I'm happy to either land or abandon the patch, whatever the community feels is most desirable.
llvm/include/llvm/Support/WithColor.h | ||
---|---|---|
52 | Please update the comments in this file. |
I'm always a fan of replacing bool arguments with a useful enum, so I'm happy if you think there's still some use in the patch.
Please update the comments in this file.