Commit Graph

60 Commits

Author SHA1 Message Date
Nathan Ridge 1b962fdd5f [clangd] Heuristic resolution for dependent type and template names
Fixes https://github.com/clangd/clangd/issues/543

Differential Revision: https://reviews.llvm.org/D88469
2020-10-12 13:37:22 -04: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
Nathan Ridge e33ec9d904 [clangd] Target member of dependent base made visible via a using-decl
Fixes https://github.com/clangd/clangd/issues/307

Differential Revision: https://reviews.llvm.org/D86047
2020-08-18 03:03:49 -04:00
David Goldman cb29c33984 [clangd][ObjC] Improve xrefs for protocols and classes
Summary:
Previously clangd would jump to forward declarations for protocols
and classes instead of their definition/implementation.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D83501
2020-08-11 12:36:31 -04:00
Nathan Ridge 70d583ad12 [clangd] Have template template arguments target their referenced template decl
Fixes https://github.com/clangd/clangd/issues/473

Differential Revision: https://reviews.llvm.org/D85503
2020-08-10 13:27:23 -04:00
Haojian Wu 5191f70ab1 [clangd] Support new/deleta operator in TargetFinder.
Differential Revision: https://reviews.llvm.org/D85028
2020-08-03 14:10:21 +02:00
Haojian Wu cd4e8d7f6f [clangd] Fix an assertion failure in TargetFinder's heuristic resolution of dependent type.
The assertion is not true anymore after D82739, this patch just removes
it, and rename related functions.

And also fixes a missing cases.

Differential Revision: https://reviews.llvm.org/D84837
2020-07-30 08:54:22 +02:00
Haojian Wu 3ad0181169 [clangd] Fix null check after D82739.
I hit the null-deference crash when opening ASTReaderDecl.cpp.

The BaseType can be a nullptr,
2020-07-21 12:15:17 +02:00
Nathan Ridge 9946dcd3e9 [clangd] Improve heuristic resolution of dependent types in TargetFinder
* Try to apply heuristic resolution recursively to the base
   expression of a CXXDependentScopeMemberExpr.

 * Try to apply heuristic resolution recursively to the callee
   expression in a call expression.

Fixes https://github.com/clangd/clangd/issues/441

Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82739
2020-07-21 02:03:06 -04:00
Nathan Ridge 100dbd1562 [clangd] Handle deduction guides in TargetFinder and ExplicitReferenceCollector
Summary: Fixes https://github.com/clangd/clangd/issues/463.

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D84122
2020-07-21 01:44:48 -04:00
Nathan Ridge 98d763ad05 [clangd] Factor out some helper functions related to heuristic resolution in TargetFinder
Summary:
Two helpers are introduced:

 * Some of the logic previously in TargetFinder::Visit*() methods is
   factored out into resolveDependentExprToDecls().

 * Some of the logic in getMembersReferencedViaDependentName() is
   factored out into resolveTypeToRecordDecl().

D82739 will build on this and use these functions in new ways.

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D83371
2020-07-10 01:58:34 -04:00
Sam McCall b0d94964da [clangd] findExplicitReferences supports goto labels
Summary:
This means they're renamable and textDocument/highlight works

This fell out of D78454

Reviewers: adamcz

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80170
2020-05-19 16:50:35 +02:00
Sam McCall ad97ccf6b2 [clangd] Move non-clang base pieces into separate support/ lib. NFCI
Summary:
This enforces layering, reduces a sprawling clangd/ directory, and makes life
easier for embedders.

Reviewers: kbobyrev

Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79014
2020-04-29 15:57:12 +02:00
Haojian Wu 7d1ee639cb [clangd] Fix a crash for accessing a null template decl returned by findExplicitReferences.
Summary: Fixes https://github.com/clangd/clangd/issues/347.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78626
2020-04-22 21:00:20 +02:00
Haojian Wu 6a78c55e3a [clangd] Fix a crash for accessing a null field decl returned by findExplicitReferences.
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78181
2020-04-15 21:42:27 +02:00
Nathan Ridge d83541d1b8 [clangd] Color dependent names based on their heuristic target if they have one
Summary: Fixes https://github.com/clangd/clangd/issues/297

Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76896
2020-04-15 00:57:08 -04:00
Haojian Wu a533b03028 [clangd] Add missing GoToStmt in FindTarget.
Summary: so that go-to-def on label can work.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77715
2020-04-08 14:19:52 +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
Nathan Ridge 31b7f0ed6a [clangd] Extend findTarget()'s dependent name heuristic to handle enumerators
Fixes https://github.com/clangd/clangd/issues/296

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76103
2020-03-17 18:13:07 -04:00
Haojian Wu e326f52430 [clangd] Fix the incomplete template specialization in findTarget.
Summary:
FindTarget doesn't report the TemplatePattern for incomplete
specialization.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74900
2020-02-21 09:42:02 +01:00
Kirill Bobyrev 9f6d8de28a
[clangd] Support renaming designated initializers
Summary:
Clangd does not find references of designated iniitializers yet and, as a
result, is unable to rename such references. This patch addresses this issue.

Resolves: https://github.com/clangd/clangd/issues/247

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72867
2020-02-10 11:53:17 +01:00
Haojian Wu eaf0c89ec5 [clangd] Add the missing elaborated types in FindTarget.
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74025
2020-02-05 14:03:36 +01:00
Sam McCall 9a5c448a31 [clangd] Fix null check in FindTarget.
I've hit this stack trace a few times but don't have a good reproducer.
The code is unsafe by inspection, though.
2020-01-29 02:01:42 +01:00
Benjamin Kramer adcd026838 Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-28 23:25:25 +01:00
Sam McCall f4871ead55 [clangd] Support pseudo-obj expr, opaque values, and property references in findExplicitReferences()
Reviewers: ilya-biryukov, dgoldman

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72508
2020-01-28 11:13:33 +01:00
Nathan Ridge cbcd07a481 [clangd] Add C++20 concepts support to TargetFinder
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73140
2020-01-23 15:12:21 -05:00
Nathan Ridge c6c5dbc824 [clangd] Add C++20 concepts support to findExplicitReferences() and semantic highlighting
Summary: Fixes https://github.com/clangd/clangd/issues/259

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73124
2020-01-23 15:11:46 -05:00
Kadir Cetinkaya 9570f1e5a6
[clangd] Do not duplicate TemplatedDecls in findExplicitReferences
Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73101
2020-01-22 11:43:53 +01:00
Haojian Wu 5d4e899757 [clangd] Handle the missing injectedClassNameType in targetDecl.
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73102
2020-01-22 10:13:39 +01:00
Haojian Wu f651c402a2 [clangd] Capture the missing injected class names in findExplicitReferences.
Summary: Fixes https://github.com/clangd/clangd/issues/237.

Reviewers: kadircet, kbobyrev

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73088
2020-01-21 15:09:23 +01:00
Kirill Bobyrev 38bdb94120
[clangd] Fix rename for explicit destructor calls
When triggering rename of the class name in the code with explicit destructor
calls, rename fails. Consider the following piece of code:

```
class Foo;

...

Foo f;
f.~/*...*/Foo();
```

`findExplicitReferences` will report two `ReferenceLoc` for destructor call:
one is comming from `MemberExpr` (i.e. destructor call itself) and would point
to the tilde:

```
f.~/*...*/Foo();
  ^
```

And the second one is pointing to the typename and is coming from `TypeLoc`.

```
f.~/*...*/Foo();
          ^
```

This causes rename to produce incorrect textual replacements. This patch
updates `MemberExpr` handler to detect destructor calls and prevents it
from reporting a duplicate reference.

Resolves: https://github.com/clangd/clangd/issues/236

Reviewers: kadircet, hokein

Differential Revision: https://reviews.llvm.org/D72638
2020-01-21 05:33:39 +01:00
Dmitri Gribenko cbaa32650a Removed an unused include from TypeLocVisitor.h 2020-01-16 15:57:44 +01:00
Kadir Cetinkaya d54d71b67e
[clangd] Make output order of allTargetDecls deterministic
Summary:
Makes use of insertion order to stabilize output for multiple decls.

Fixes https://bugs.llvm.org/show_bug.cgi?id=44564

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, usaxena95, cfe-commits, aemerson

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72826
2020-01-16 14:47:28 +01:00
Sam McCall 4c5a4514d1 [clangd] Fix targetDecl() on certain usage of ObjC properties.
Summary:
In particular there's a common chain:
  OpaqueValueExpr->PseudoObjectExpr->ObjCPropertyRefExpr->ObjCPropertyDecl
and we weren't handling the first two edges

Reviewers: dgoldman, kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72494
2020-01-10 18:07:24 +01:00
Nathan Ridge 6a69d3c6b3 [clangd] Handle DeducedTemplateSpecializationType in TargetFinder
Summary:
This is a workaround for https://bugs.llvm.org/show_bug.cgi?id=42914.
Once that is fixed, the handling in VisitDeducedTyped() should be sufficient.

Fixes https://github.com/clangd/clangd/issues/242

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72119
2020-01-09 16:14:11 -05:00
Nathan Ridge 16f47cf607 [clangd] Heuristically resolve dependent call through smart pointer type
Summary: Fixes https://github.com/clangd/clangd/issues/227

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71644
2020-01-07 12:52:03 -05:00
Kazuaki Ishizaki b7ecf1c1c3 NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05: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
Kirill Bobyrev 3b9715cb21 [NFC] Fix typos in Clangd and Clang
Reviewed by: Jim

Differential Revision: https://reviews.llvm.org/D71455
2019-12-16 10:54:40 +01:00
Nathan Ridge ecaa936330 [clangd] Heuristically resolve dependent method calls
Summary:
The heuristic is to look in the definition of the primary template,
which is what you want in the vast majority of cases.

Fixes https://github.com/clangd/clangd/issues/141

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71240
2019-12-12 17:18:00 -05:00
Nathan Ridge 1a4ee4c88f [clangd] Find reference to template parameter in 'sizeof...' expression
Fixes https://github.com/clangd/clangd/issues/213.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70740
2019-12-05 14:30:53 -05:00
Haojian Wu 939544add9 [clangd] Handle the missing call expr in targetDecl.
Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70773
2019-11-27 16:22:20 +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
Ilya Biryukov 733777a816 [clangd] Fix namespace aliases in findExplicitReferences
Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69624
2019-10-31 13:35:25 +01:00
Ilya Biryukov 4c430a7c6f [clangd] Do not report anonymous entities in findExplicitReferences
Summary:
Otherwise every client dealing with name location should handle
anonymous names in a special manner.

This seems too error-prone, clients can probably handle anonymous
entities they care about differently.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69511
2019-10-28 14:41:34 +01:00
Haojian Wu 13fc899cde [clangd] Handle the missing constructor initializers in findExplicitReferences.
Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D69241
2019-10-24 10:38:37 +02: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
Ilya Biryukov 1d32da8249 [clangd] Handle template arguments in findExplicitReferences
Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 373318
2019-10-01 10:02:23 +00:00