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

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 26 14:54:53 PDT 2022


sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice!



================
Comment at: clang-tools-extra/pseudo/lib/cxx/CXX.cpp:168
+bool guardPreviousTokenNotIdentifier(const GuardParams &P) {
+  if (P.LookaheadIndex < 2)
+    return true;
----------------
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




================
Comment at: clang-tools-extra/pseudo/lib/cxx/CXX.cpp:325
+      {(RuleID)Rule::nested_name_specifier_0coloncolon,
+       guardPreviousTokenNotIdentifier},
+
----------------
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


================
Comment at: clang-tools-extra/pseudo/test/cxx/nested-name-specifier.cpp:18
+// CHECK:  statement~simple-declaration := decl-specifier-seq ;
+// CHECK-NOT: simple-declaration := decl-specifier-seq init-declarator-list ;
+}
----------------
Maybe check:
a<b>::c is ambiguous 3 ways, with a fixme to eliminate the one that is invalid. (I.e. the declaration of ::c)


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