[clangd] Handle members of anon structs in SelectionTree
authorKadir Cetinkaya <kadircet@google.com>
Thu, 30 Sep 2021 13:25:42 +0000 (15:25 +0200)
committerKadir Cetinkaya <kadircet@google.com>
Fri, 1 Oct 2021 10:38:18 +0000 (12:38 +0200)
commit512aa8485010009f6ec1b8d9deea3effe67e0106
tree397a837fcb3b1f6f050e302408efc1f4b6ec1182
parent413b7ac6b535dfb4c57c2842388a2071901b9d56
[clangd] Handle members of anon structs in SelectionTree

References to fields inside anon structs contain an implicit children
for the container, which has the same SourceLocation with the field.
This was resulting in SelectionTree always picking the anon-struct rather than
the field as the selection.

This patch prevents that by claiming the range for the field early.

https://github.com/clangd/clangd/issues/877.

Differential Revision: https://reviews.llvm.org/D110825
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp