Changes from Git (git http://labmaster3.local/git/llvm-project.git)


  1. [clangd] Rethink how SelectionTree deals with macros and #includes. (details)
Commit 19daa21f841ad45290c923689ee3d25198651a4c by sam.mccall
[clangd] Rethink how SelectionTree deals with macros and #includes.
Summary: The exclusive-claim model is successful at resolving conflicts
over tokens between parent/child or siblings. However claims at the
spelled-token level do the wrong thing for macro expansions, where
siblings can be equally associated with the macro invocation. Moreover,
any model that only uses the endpoints in a range can fail when a macro
invocation occurs inside the node.
To address this, we use the existing TokenBuffer in more depth. Claims
are expressed in terms of expanded tokens, so there is no need to worry
about macros, includes etc.
Once we know which expanded tokens were claimed, they are mapped onto
spelled tokens for hit-testing. This mapping is fairly flexible,
currently the handling of macros is pretty simple (map macro args onto
spellings, other macro expansions onto the macro name token). This
mapping is in principle token-by-token for correctness (though there's
some batching for performance).
The aggregation of the selection enum is now more principled as we need
to be able to aggregate several hit-test results together.
For simplicity i removed the ability to determine selectedness of
(That was originally implemented in 90a5bf92ff97b1, but doesn't seem to
be very important or worth the complexity any longer).
The expandedTokens(SourceLocation) helper could be added locally, but
seems to make sense on TokenBuffer.
Fixes Fixes
Reviewers: hokein
Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95,
cfe-commits, ilya-biryukov
Tags: #clang
Differential Revision:
The file was modifiedclang-tools-extra/clangd/unittests/SelectionTests.cpp
The file was modifiedclang/lib/Tooling/Syntax/Tokens.cpp
The file was modifiedclang-tools-extra/clangd/unittests/TweakTests.cpp
The file was modifiedclang/include/clang/Tooling/Syntax/Tokens.h
The file was modifiedclang-tools-extra/clangd/Selection.cpp
The file was modifiedclang-tools-extra/clangd/Selection.h
The file was modifiedclang/unittests/Tooling/Syntax/TokensTest.cpp