[all-commits] [llvm/llvm-project] f06f43: [clangd] targetDecl() returns only NamedDecls.
Sam McCall via All-commits
all-commits at lists.llvm.org
Fri Jan 3 09:18:47 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: f06f439fadf740ea9019f2eb7f26ff88198ed375
https://github.com/llvm/llvm-project/commit/f06f439fadf740ea9019f2eb7f26ff88198ed375
Author: Sam McCall <sam.mccall at gmail.com>
Date: 2020-01-03 (Fri, 03 Jan 2020)
Changed paths:
M clang-tools-extra/clangd/FindTarget.cpp
M clang-tools-extra/clangd/FindTarget.h
M clang-tools-extra/clangd/XRefs.cpp
M clang-tools-extra/clangd/refactor/Rename.cpp
M clang-tools-extra/clangd/unittests/FindTargetTests.cpp
M clang-tools-extra/clangd/unittests/HoverTests.cpp
Log Message:
-----------
[clangd] targetDecl() returns only NamedDecls.
Summary:
While it's perfectly reasonable for non-named decls such as
static_assert to resolve to themselves:
- nothing else ever resolves to them
- features based on references (hover, highlight, find refs etc) tend
to be uninteresting where only trivial references are possible
- returning NamedDecl is a more convenient API (we cast to it in many places)
- this aligns closer to findExplicitReferences/explicitReferenceTargets
This fixes a crash in explicitReferenceTargets: if the target is a
non-named decl then there's an invalid unchecked cast to NamedDecl.
In practice this means when hovering over e.g. a static_assert:
- before ac3f9e4842, we would show a (boring) hover card
- after ac3f9e4842, we would crash
- after this patch, we will show nothing
Reviewers: kadircet, ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D72163
More information about the All-commits
mailing list