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

via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 20 05:34:32 PDT 2023


cor3ntin wrote:

@tbaederr I think you need to use the preprocessor that exists ( which you get in `DiagnosticConsumer::BeginSourceFile`, I hope you can plug to `TextDiagnosticPrinter::BeginSourceFile` in particular), but you are right that you can't reuse the Lexer because of comments (and macros?).

Note that we don't technically need the preprocessor, just the underlying `IdentifierTable`. 
Then when Lexing with your custom Lexer, when you get an identifier, you should be able to get the identifier as a string, which you can pass to `IdentifierInfo *Preprocessor::getIdentifierInfo(StringRef Name)`

At least i think this would work?




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


More information about the cfe-commits mailing list