[PATCH] D132260: [pseudo] Eliminate a false parse of structured binding declaration.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 22 07:38:21 PDT 2022
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.
================
Comment at: clang-tools-extra/pseudo/lib/cxx/CXX.cpp:164
+bool isStructuredBinding(const ForestNode* N) {
+ assert(N->symbol() == Symbol::decl_specifier_seq);
----------------
nit: specifiesStructuredBinding?
(because the structured binding itself is something bigger)
================
Comment at: clang-tools-extra/pseudo/lib/cxx/CXX.cpp:166
+ assert(N->symbol() == Symbol::decl_specifier_seq);
+ for (const auto &Child : N->descendants()) {
+ if (Child.kind() == ForestNode::Terminal) {
----------------
If you're going to iterate over tokens, it seems more direct (and cheaper) to do it directly:
`for (const Tok& : P.Tokens.tokens(RHS[0].startTokenIndex(), RHS[1].startTokenIndex()))`
================
Comment at: clang-tools-extra/pseudo/test/cxx/structured-binding.cpp:1
+
+// RUN: clang-pseudo -grammar=cxx -source=%s --start-symbol=statement-seq --print-forest | FileCheck %s
----------------
nit: drop blank line
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132260/new/
https://reviews.llvm.org/D132260
More information about the cfe-commits
mailing list