[clang] [clang][Diagnostics] Highlight code snippets (PR #66514)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 22 04:15:53 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>
Message-ID:
In-Reply-To: <llvm/llvm-project/pull/66514/clang at github.com>


tbaederr wrote:

> I have concerns about Lexing twice every single file for which we display a warning.

Sure. Because of performance, memory usage or code complexity?

> Did you try something along the lines of what Richard suggested? Keeping track of where lines start does seem like a good idea.
> 
> We could even keep track of ranges of good lines which would reduce even further how much state we need to keep in the lexer.
> 
> We can then parse starting from the nearest good line start. We could still cache that further if we wanted.

So, my general procedure for diagnostics is that they shouldn't complicate the non-diagnostic code. And when we emit a diagnostic, performance is basically out the window anyway (printing to stdout is _slow_ and the way we emit code snippets is also slow, etc.)

For build servers, none of this matters since they don't colorize output at all, so this is really only interesting for actual developers who usually have a clean build (no diagnostics emitted at all), but want to have maximal usefulness of the ones they encounter while working on their project.


https://github.com/llvm/llvm-project/pull/66514


More information about the cfe-commits mailing list