Skip to content

[clang][Diagnostics] Make 'note' color CYAN #66997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2023
Merged

Conversation

tbaederr
Copy link
Contributor

Just using BLACK makes it invisible in terminals with a dark background.

See this screenshot:

Screenshot from 2023-09-21 12-03-15

With current clang, the "note:" part of the note is almost invisible, because we select BLACK as its color.

Use CYAN instead, which is also what gcc does.

@tbaederr tbaederr added the clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer label Sep 21, 2023
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Sep 21, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 21, 2023

@llvm/pr-subscribers-clang

Changes

Just using BLACK makes it invisible in terminals with a dark background.

See this screenshot:

Screenshot from 2023-09-21 12-03-15

With current clang, the "note:" part of the note is almost invisible, because we select BLACK as its color.

Use CYAN instead, which is also what gcc does.


Full diff: https://github.com/llvm/llvm-project/pull/66997.diff

1 Files Affected:

  • (modified) clang/lib/Frontend/TextDiagnostic.cpp (+1-1)
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp
index eaa6e8d29a1dece..89c7ef505159e13 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -25,7 +25,7 @@
 using namespace clang;
 
 static const enum raw_ostream::Colors noteColor =
-  raw_ostream::BLACK;
+  raw_ostream::CYAN;
 static const enum raw_ostream::Colors remarkColor =
   raw_ostream::BLUE;
 static const enum raw_ostream::Colors fixitColor =

@tbaederr tbaederr requested a review from cjdb September 26, 2023 07:44
@cjdb
Copy link
Contributor

cjdb commented Sep 26, 2023

This doesn't really fix the problem, it just shuffles it around. I expect people with blue(ish) terminals will experience the same issue after this is applied, so we ought to try and detect what colours to print out, and then have compatible themes.

@tbaederr
Copy link
Contributor Author

I know, this only fixes the problem in the vast majority of cases. I don't know of any tool implementing dynamic background color checking so it can adjust the foreground color though.

This is a one-liner that fixes the problem on terminals with a dark background and the solution also works on light backgrounds. So, basically all of them.

@cjdb
Copy link
Contributor

cjdb commented Sep 26, 2023

This is a one-liner that fixes the problem on terminals with a dark background and the solution also works on light backgrounds. So, basically all of them.

Before approving this change, I want confirmation that it doesn't adversely impact popular themes. The Tomorrow Night Blue theme that's in my Visual Studio Code client (not my theme, but one of the defaults, I think) does need to change the hue of its blue text.

If we can't detect the background, then I think it's extra important that we test this on as many themes as possible, and with colourblind filters as well.

@cor3ntin
Copy link
Contributor

This doesn't really fix the problem, it just shuffles it around. I expect people with blue(ish) terminals will experience the same issue after this is applied, so we ought to try and detect what colours to print out, and then have compatible themes.

Not really, CYAN is only cyan if that's what your terminal decides to render the color 6 as, you can configure it to be orange if you want.

Copy link
Contributor

@cor3ntin cor3ntin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A shed by any other color would store bikes as well.

@cjdb
Copy link
Contributor

cjdb commented Sep 26, 2023

Not really, CYAN is only cyan if that's what your terminal decides to render the color 6 as, you can configure it to be orange if you want.

Oh, interesting. In that case, I see no problems.

@tbaederr
Copy link
Contributor Author

tbaederr commented Sep 27, 2023

I keep forgetting to add release notes and @AaronBallman hasn't reminded me in a while - is this worth a release note?

@cor3ntin
Copy link
Contributor

cor3ntin commented Sep 27, 2023

I keep forgetting to add release notes and @AaronBallman hasn't reminded me in a while - is this worth a release note?

Yes!

Just using BLACK makes it invisible in terminals with a dark background.
@tbaederr tbaederr merged commit 918863d into llvm:main Sep 27, 2023
legrosbuffle pushed a commit to legrosbuffle/llvm-project that referenced this pull request Sep 29, 2023
Just using BLACK makes it invisible in terminals with a dark background.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants