[PATCH] D130511: [pseudo][wip] Eliminate simple-type-specifier ambiguities.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 28 01:54:34 PDT 2022


hokein added inline comments.


================
Comment at: clang-tools-extra/pseudo/lib/cxx/CXX.cpp:168
+bool guardPreviousTokenNotIdentifier(const GuardParams &P) {
+  if (P.LookaheadIndex < 2)
+    return true;
----------------
sammccall wrote:
> Is LookaheadIndex from another patch?
> I can't find it at head.
> 
> It seems a bit gratuitous here vs P.RHS.front()->startTokenIndex()... In general getting the info from RHS seems cleaner than jumping across by reasoning how many tokens it has
> 
> 
Yeah, the lookaheadIndex is from my other patch: https://reviews.llvm.org/D130591

I think using `Tok.prev()` is much better.


================
Comment at: clang-tools-extra/pseudo/lib/cxx/CXX.cpp:325
+      {(RuleID)Rule::nested_name_specifier_0coloncolon,
+       guardPreviousTokenNotIdentifier},
+
----------------
sammccall wrote:
> You could write this as `TOKEN_GUARD(coloncolon, Tok.prev().Kind != tok::identifier)`
> 
> If it's that short i like having the guard logic inline to avoid the indirection for the reader
Good point! 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130511



More information about the cfe-commits mailing list