[all-commits] [llvm/llvm-project] 91679c: [clangd] Include macro expansions in documentSymbo...
Sam McCall via All-commits
all-commits at lists.llvm.org
Tue Mar 2 08:52:49 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 91679c95bbedf4f816a456028ebd23ea6c5cc08f
https://github.com/llvm/llvm-project/commit/91679c95bbedf4f816a456028ebd23ea6c5cc08f
Author: Sam McCall <sam.mccall at gmail.com>
Date: 2021-03-02 (Tue, 02 Mar 2021)
Changed paths:
M clang-tools-extra/clangd/FindSymbols.cpp
M clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
Log Message:
-----------
[clangd] Include macro expansions in documentSymbol hierarchy
Browsing macro-generated symbols is confusing.
On the one hand, it seems very *useful* to be able to see the summary of
symbols that were generated.
On the other hand, some macros spew a lot of confusing symbols into the
namespace and when used repeatedly (ABSL_FLAG) can create a lot of spam
that's hard to navigate.
Design constraints:
- the macro expansion tree need not align with the AST, though it often
does in practice.
We address this by defining the nesting based on the *primary*
location of decls, rather than their ranges.
- DocumentSymbol.children[*].range should nest within DocumentSymbol.range
(This constraint is not in LSP "breadcrumbs" breaks without it)
We adjust macro ranges so they cover their "children", rather than
just the macro expansion
- LSP does not have a "macro expansion" symbolkind, nor does it allow a
symbol to have no kind. I've arbitrarily picked "null" as this is
unlikely to conflict with anything useful.
This patch makes all macros and children visible for simplicity+consistency,
though in some cases it may be better to elide the macro node.
We may consider adding heuristics for this in future (e.g. when it expands
to one decl only?) but it doesn't seem clear-cut to me.
Differential Revision: https://reviews.llvm.org/D97615
More information about the All-commits
mailing list