[all-commits] [llvm/llvm-project] 96f5cc: [clangd] Handle declarators more consistently in S...

Sam McCall via All-commits all-commits at lists.llvm.org
Wed Jan 5 06:41:07 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 96f5cc1ee417f863f85756d1e56b1bed1bd76a7e
      https://github.com/llvm/llvm-project/commit/96f5cc1ee417f863f85756d1e56b1bed1bd76a7e
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2022-01-05 (Wed, 05 Jan 2022)

  Changed paths:
    M clang-tools-extra/clangd/Selection.cpp
    M clang-tools-extra/clangd/unittests/SelectionTests.cpp

  Log Message:
  -----------
  [clangd] Handle declarators more consistently in Selection.

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 and D116618

Differential Revision: https://reviews.llvm.org/D116630




More information about the All-commits mailing list