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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to