[PATCH] D114072: [clangd] Record IWYU pragma keep in the IncludeStructure

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 26 04:00:36 PST 2021


kadircet added a comment.

It's annoying that we see comments and inclusion directives out-of-order, we can try fixing it on the parser side (I think it is incidental that these are issued in that order currently, they are eagerly trying to generate a fix/diagnostic for tokens after a pp-directive. hence we can first issue the PP callback, and then diagnose for rest of the line instead).
But I don't think it matters in the long run especially when we want to handle different types of pragmas in the future (which is the plan IIRC), they might not even necessarily be in the main file, let alone being seen with right sequencing.

So I'd suggest just building a side table information about these interesting comments/pragmas we see as we go, and then merge them with rest of the information we've built inside `RecordHeaders::EndOfMainFile`.
That'll enable us to separate concerns here. Instead of piggy backing `CommentHandler` on `RecordHeaders`, we can have a separate comment handler exposed via `IncludeStructure::commentHandler()` (similar to `collect`) and let it update this side table of pragma/comment information.

WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114072/new/

https://reviews.llvm.org/D114072



More information about the cfe-commits mailing list