[clang] [clang][Diagnostics] Highlight code snippets (PR #66514)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 24 07:27:06 PDT 2023
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm/llvm-project/pull/66514/clang at github.com>
AaronBallman wrote:
> > Regardless of the approach we take in the end - what do you think about tests for this? Should we have a flag similar to `-fdiagnostics-print-source-range-info` for the code style ranges?
>
> I have no opinion. @AaronBallman ?
I could have sworn we already had one with `-fcolor-diagnostics -fansi-escape-codes` and piping the output to a file instead of the terminal? e.g.,
```
F:\source\llvm-project>llvm\out\build\x64-Debug\bin\clang.exe -Weverything -fsyntax-only -fansi-escape-codes -fcolor-diagnostics "C:\Users\aballman\OneDrive - Intel Corporation\Desktop\test.cpp" > foo.txt 2>&1
F:\source\llvm-project>cat foo.txt
←[1mC:\Users\aballman\OneDrive - Intel Corporation\Desktop\test.cpp:1:6: ←[0m←[0;1;35mwarning: ←[0m←[1mno previous prototype for function 'func' [-Wmissing-prototypes]←[0m
1 | void func(int i, unsigned u) {←[0m
| ←[0;1;32m ^
←[0m←[1mC:\Users\aballman\OneDrive - Intel Corporation\Desktop\test.cpp:1:1: ←[0m←[0;1;36mnote: ←[0mdeclare 'static' if the function is not intended to be used outside of this translation unit←[0m
1 | void func(int i, unsigned u) {←[0m
| ←[0;1;32m^
←[0m | ←[0;32mstatic
←[0m←[1mC:\Users\aballman\OneDrive - Intel Corporation\Desktop\test.cpp:2:9: ←[0m←[0;1;35mwarning: ←[0m←[1mcomparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]←[0m
2 | if (i < u) return;←[0m
| ←[0;1;32m ~ ^ ~
←[0m2 warnings generated.
```
Would it work to reuse that?
https://github.com/llvm/llvm-project/pull/66514
More information about the cfe-commits
mailing list