[PATCH] D98483: [clang] Mark re-injected tokens appropriately during pragma handling

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 12 04:59:54 PST 2021


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/lib/Parse/ParsePragma.cpp:2610
   EoF.setKind(tok::eof);
+  EoF.setFlag(clang::Token::IsReinjected);
   AnnotTok.startToken();
----------------
It was surprisingly hard for me to see that the changes here were just marking everything in TokenArray as reinjected.

Could you do that directly with a loop at the end instead? (It's hard to imagine a significant performance difference)

(And the same in all the other modified sites)


================
Comment at: clang/lib/Parse/ParsePragma.cpp:2618
   for (; Tok.isNot(tok::eod); PP.Lex(Tok)) {
+    Tok.setFlag(clang::Token::IsReinjected);
     TokenVector.push_back(Tok);
----------------
as discussed offline, it wasn't clear to me that this was "in time" as we're not trying to affect the behavior of the subsequent PP.Lex call, not the previous one.

Maybe we could extract a function to mark an ArrayRef as reinject with a name that makes this clear.
`markAsReinjectedForRelexing()` or something...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98483



More information about the cfe-commits mailing list