[PATCH] D116630: [clangd] Handle declarators more consistently in Selection.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 4 15:21:00 PST 2022


sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: usaxena95, kadircet, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Because declarators nest inside-out, we logically need to claim tokens for
parent declarators logically before child ones.
This is the ultimate reason we had problems with DeclaratorDecl, ArrayType etc.

However actually changing the order of traversal is hard, especially for nodes
that have both declarator and non-declarator children.
Since there's only a few TypeLocs corresponding to declarators, we just
have them claim the exact tokens rather than rely on nesting.

This fixes handling of complex declarators, like
`int (*Fun(OuterT^ype))(InnerType);`.

This avoids the need for the DeclaratorDecl early-claim hack, which is
removed.
Unfortunately the DeclaratorDecl early-claims were covering up an AST
anomaly around CXXConstructExpr, so we need to fix that up too.

Based on D116623 <https://reviews.llvm.org/D116623> and D116618 <https://reviews.llvm.org/D116618>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116630

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116630.397416.patch
Type: text/x-patch
Size: 7655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220104/8fa8b255/attachment.bin>


More information about the cfe-commits mailing list