Commit Graph

14 Commits

Author SHA1 Message Date
Nathan Ridge 9510b09402 [clangd] Factor out the heuristic resolver code into its own class
The patch also does some cleanup on the interface of the entry
points from TargetFinder into the heuristic resolution code.

Since the heuristic resolver is created in a place where the
ASTContext is available, it can store the ASTContext and the
NameFactory hack can be removed.

Differential revision: https://reviews.llvm.org/D92290
2021-02-16 04:10:52 -05:00
Nathan Ridge 4718ec0166 [clangd] Avoid recursion in TargetFinder::add()
Fixes https://github.com/clangd/clangd/issues/633

Differential Revision: https://reviews.llvm.org/D94382
2021-01-12 13:57:54 -05:00
Alexander Kornienko 027899dab6 Remove references to the ast_type_traits namespace
Follow up to cd62511496 /
https://reviews.llvm.org/D74499

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D92994
2020-12-11 00:58:46 +01:00
Haojian Wu f24649b77d [clangd] Don't set the Underlying bit on targets of UsingDecls.
With this patch, we don't treat `using ns::X` as a first-class declaration like `using Z = ns::Y`, reference to X that goes through this using-decl is considered a direct reference (without the Underlying bit).

Fix the workaround in https://reviews.llvm.org/D87225 and https://reviews.llvm.org/D74054.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D88472
2020-10-07 10:01:04 +02:00
Kazuaki Ishizaki dd5571d51a [clang-tools-extra] NFC: Fix trivial typo in documents and comments
Differential Revision: https://reviews.llvm.org/D77458
2020-04-05 15:28:40 +09:00
Sam McCall f06f439fad [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
2020-01-03 18:18:40 +01:00
Sam McCall acc4ffbb47 [clangd] Reorder FindTarget.h - group targetDecl() stuff and findExplicitReferences(). NFC 2020-01-02 18:01:29 +01:00
Kadir Cetinkaya ac3f9e4842
[clangd] Improve documentation for auto and implicit specs
Summary:
Clangd didn't fill documentation for `auto` when it wasn't available in
index. Also it wasn't showing any documentations for implicit instantiations.

This patch ensures auto and normal decl case behaves in the same way and also
makes use of the explicit template specialization while fetching comments for
implicit instantiations.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71596
2019-12-19 11:55:22 +01:00
Ilya Biryukov 87e0cb4f1a [clangd] Implement semantic highlightings via findExplicitReferences
Summary:
To keep the logic of finding locations of interesting AST nodes in one
place.

The advantage is better coverage of various AST nodes, both now and in
the future: as new nodes get added to `findExplicitReferences`, semantic
highlighting will automatically pick them up.

The drawback of this change is that we have to traverse declarations
inside our file twice in order to highlight dependent names, 'auto'
and 'decltype'. Hopefully, this should not affect the actual latency
too much, most time should be spent in building the AST and not
traversing it.

Reviewers: hokein

Reviewed By: hokein

Subscribers: nridge, merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69673
2019-11-05 19:15:24 +01:00
Haojian Wu 65f61c0030 [clangd] Report declaration references in findExplicitReferences.
Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

llvm-svn: 375226
2019-10-18 12:07:19 +00:00
Kadir Cetinkaya 007e4fe901 [clangd] Change constness of parameters to findExplicitRefs
Summary:
Recursive AST requires non-const ast nodes, but it doesn't really
mutate them. In addition to that, in clangd we mostly have const ast nodes. So
it makes sense to move the const_cast into callee rather than having it at every
caller in the future.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

llvm-svn: 372888
2019-09-25 15:44:26 +00:00
Haojian Wu c00627f4dc [clangd] Add missing header guard, NFC.
llvm-svn: 372860
2019-09-25 12:54:53 +00:00
Ilya Biryukov f96d2e1754 [clangd] A helper to find explicit references and their names
Summary:
Allows to simplify pending code tweaks:
  - the upcoming DefineInline tweak (D66647)
  - remove using declaration (D56612)
  - qualify name under cursor (D56610)

Another potential future application is simplifying semantic highlighting.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: mgrang, jfb, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

llvm-svn: 372859
2019-09-25 12:40:22 +00:00
Sam McCall 489cc589c5 [clangd] Add targetDecl(), which determines what declaration an AST node refers to.
Summary:
This is the first part of an effort to "unbundle" our libIndex use into separate
concerns (AST traversal, token<->node mapping, node<->decl mapping,
decl<->decl relationshipes).

Currently, clangd relies on libIndex to associate tokens, AST nodes, and decls.
This leads to rather convoluted implementations of e.g. hover and
extract-function, which are not naturally thought of as indexing applications.

The idea is that by decoupling different concerns, we make them easier
to use, test, and combine, and more efficient when only one part is needed.
There are some synergies between e.g. traversal and finding
relationships between decls, hopefully the benefits outweight these.

Reviewers: kadircet, ilya-biryukov

Subscribers: mgorny, MaskRay, jkorous, arphaman, jfb, cfe-commits

Tags: #clang

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

llvm-svn: 370746
2019-09-03 11:35:50 +00:00