Commit Graph

1783 Commits

Author SHA1 Message Date
Kadir Cetinkaya 1b996faa15
[clangd][Hover] Change arrow in return type back to →
Summary:
Currently 🡺 is used in hover response to represent return types, but it
is not widely available. Changing this back to original to support more clients.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73336
2020-01-24 13:05:21 +01:00
Sam McCall 7d20e80225 [clangd] Show background index status using LSP 3.15 work-done progress notifications
Summary:
It simply shows the completed/total items on the background queue, e.g.
 indexing: 233/1000
The denominator is reset to zero every time the queue goes idle.

The protocol is fairly complicated here (requires creating a remote "progress"
resource before sending updates). We implement the full protocol, but I've added
an extension allowing it to be skipped to reduce the burden on clients - in
particular the lit test takes this shortcut.

The addition of background index progress to DiagnosticConsumer seems ridiculous
at first glance, but I believe that interface is trending in the direction of
"ClangdServer callbacks" anyway. It's due for a rename, but otherwise actually
fits.

Reviewers: kadircet, usaxena95

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

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D73218
2020-01-24 12:21:08 +01:00
Sam McCall d3260bf5b2 [clangd] Errors in TestTU cause test failures unless suppressed with error-ok.
Summary:
The historic behavior of TestTU is to gather diagnostics and otherwise ignore
them. So if a test has a syntax error, and doesn't assert diagnostics, it
silently misbehaves.
This can be annoying when developing tests, as evidenced by various tests
gaining "assert no diagnostics" where that's not really the point of the test.

This patch aims to make that default behavior. For the first error
(not warning), TestTU will call ADD_FAILURE().

This can be suppressed with a comment containing "error-ok". For now that will
suppress any errors in the TU. We can make this stricter later -verify style.
(-verify itself is hard to reuse because of DiagnosticConsumer interfaces...)
A magic-comment was chosen over a TestTU option because of table-driven tests.

In addition to the behavior change, this patch:
  - adds //error-ok where we're knowingly testing invalid code
    (e.g. for diagnostics, crash-resilience, or token-level tests)
  - fixes a bunch of errors in the checked-in tests, mostly trivial (missing ;)
  - removes a bunch of now-redundant instances of "assert no diagnostics"

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73199
2020-01-24 11:16:27 +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
Kadir Cetinkaya 1fbb1d6df0
[clangd] Drop returntype/type when hovering over type-ish names
Summary:
Some names, e.g. constructor/destructor/conversions, already contain
the type info, no need to duplicate them in the hoverinfo.

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

Reviewers: sammccall, ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73110
2020-01-21 17:10:09 +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
Kadir Cetinkaya fb3d9153c0
[clangd] Fix DocumentOutline for concepts
Summary: Fixes https://github.com/clangd/clangd/issues/256

Reviewers: kbobyrev

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73056
2020-01-20 20:20:27 +01:00
Haojian Wu 3de9a5db62 [clangd] Avoid redundant testcases in rename unittest, NFC.
Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73035
2020-01-20 17:01:05 +01:00
Kadir Cetinkaya 1f946ee2fa
[clang][CodeComplete] Propogate printing policy to FunctionDecl
Summary:
Printing policy was not propogated to functiondecls when creating a
completion string which resulted in canonical template parameters like
`foo<type-parameter-0-0>`. This patch propogates printing policy to those as
well.

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

Reviewers: ilya-biryukov

Subscribers: jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72715
2020-01-20 12:20:20 +01:00
Haojian Wu 61b5634080 [clangd] Remove a stale FIXME, NFC. 2020-01-20 12:07:30 +01:00
Kadir Cetinkaya 4df94d5b51
Revert "[clangd][test] Disable a particular testcase in FindExplicitReferencesTest when LLVM_ENABLE_EXPENSIVE_CHECKS"
This reverts commit 42b3c38903.

Should've been fixed by d54d71b67e
2020-01-17 08:51:13 +01:00
Jan Korous 42b3c38903 [clangd][test] Disable a particular testcase in FindExplicitReferencesTest when LLVM_ENABLE_EXPENSIVE_CHECKS
The test is failing on our CI bots.
Seems like the order of results for one target is undefined.

(post-commit review)
Differential Revision: https://reviews.llvm.org/D72883
2020-01-16 15:07:08 -08:00
Michael Liao 40514a7d7a [clangd] Add workaround for GCC5 host compilers. NFC. 2020-01-16 16:05:22 -05:00
Kadir Cetinkaya 0474fe465d
[clangd] Print underlying type for decltypes in hover
Summary: Fixes https://github.com/clangd/clangd/issues/249

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72498
2020-01-16 19:56:54 +01:00
Kadir Cetinkaya a881fcafaa
[clangd] Make define outline code action visible
Summary: This got forgotten during the process.

Reviewers: sammccall, usaxena95

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72840
2020-01-16 19:55:02 +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
Kadir Cetinkaya b08e8353a8
[clangd] Dont display `<unknown>` kinds in hover board
Summary:
Currently when hovering over an `auto` or `decltype` that resolve to a
builtin-type, clangd would display `<unknown>` as the kind of the symbol.

Drop that to make rendering nicer.

Reviewers: usaxena95

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72777
2020-01-16 11:47:00 +01:00
Kadir Cetinkaya 041650da67
[clangd] Extract string literals in macro arguments to unbreak gcc buildbots 2020-01-15 17:59:10 +01:00
Kadir Cetinkaya 60adfb83cd
[clangd] Fix windows buildbots 2020-01-15 16:22:36 +01:00
Kadir Cetinkaya 44f9c7a820
[clangd] Rearrange type, returntype and parameters in hover card
Summary:
Moves type/returntype into its own line as it is more readable in cases
where the type is long.

Also gives parameter lists a heading, `Parameters:` to make them stand out.

Leaves the `right arrow` instead of `Returns: ` before Return Type to make
output more symmetric.

```
function foo

Returns: ret_type
Parameters:
- int x
```

vs

```
function foo

🡺 ret_type
Parameters:
- int x
```

Reviewers: sammccall, ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72623
2020-01-15 15:55:46 +01:00
Kadir Cetinkaya d74a3d470c
[clangd] Add a ruler after header in hover
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72622
2020-01-15 15:54:38 +01:00
Kadir Cetinkaya 4d14bfaa2c
[clangd] Show hower info for expressions
Summary:
This currently populates only the Name with the expression's type and
Value if expression is evaluatable.

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

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72500
2020-01-15 15:14:37 +01:00
Kadir Cetinkaya f5465e74ef
[clangd] Include expression in DecltypeTypeLoc sourcerange while building SelectionTree
Summary:
Currently AST only contains the location for `decltype` keyword,
therefore we were skipping expressions inside decltype while building selection
tree.

This patch extends source range in such cases to contain the expression as well.
A proper fix would require changes to Sema and DecltypeTypeLoc to contain these
location information.

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

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72594
2020-01-13 20:33:13 +01:00
Kadir Cetinkaya 15078d7202
[clangd] Render header of hover card as a heading
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72625
2020-01-13 20:24:09 +01:00
Oliver Stannard b96ec492d3 [clangd] Remove raw string literals in macros
Older (but still supported) versions of GCC don't handle C++11 raw
string literals in macro parameters correctly.
2020-01-13 11:45:05 +00:00
Utkarsh Saxena 734aa1d133 [clangd] Publish xref for macros from Index and AST.
Summary:
With this patch the `findReferences` API will return Xref for macros.
If the symbol under the cursor is a macro then we collect the references to it from:
1. Main file by looking at the ParsedAST. (These were added to the ParsedAST in https://reviews.llvm.org/D70008)
2. Files other than the mainfile by looking at the:
	* static index (Added in https://reviews.llvm.org/D70489)
	* file index (Added in https://reviews.llvm.org/D71406)
This patch collects all the xref from the above places and outputs it in `findReferences` API.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72395
2020-01-13 11:11:18 +01:00
Nathan Ridge 79a09d8bf4 [clangd] Show template arguments in type hierarchy when possible
Summary: Fixes https://github.com/clangd/clangd/issues/31

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71533
2020-01-12 22:31:40 -05:00
Nathan Ridge 1ad1308b69 [clangd] Assert that the testcases in FindExplicitReferencesTest.All have no diagnostics
Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72355
2020-01-12 22:18:21 -05: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
Kadir Cetinkaya abfa27e4f0
[clangd] Fix markdown rendering in VSCode
Summary:
Eventough it is OK to have a new line without any preceding spaces in
some markdown specifications, VSCode requires two spaces before a new line to
break a line inside a paragraph.

Reviewers: sammccall, ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72462
2020-01-10 09:51:20 +01:00
Kadir Cetinkaya ffd0f11675
[clangd] Improve type printing in hover
Summary:
Do not include tag keywords when printing types for symbol names, as it
will come from SymbolKind.
Also suppress them while printing definitions to prevent them occuring in
template arguments.
Make use of `getAsString`, instead of `print` in all places to have a consistent
style across the file.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72450
2020-01-10 09:51:20 +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
Kadir Cetinkaya 189aa5b7a4
[clangd] Adjust diagnostic range to be inside main file
Summary:
LSP requires diagnostics to lay inside main file. In clangd we keep
diagnostics in three different cases:
- already in main file
- adjusted to a header included in main file
- has a note covering some range in main file

In the last case, we were not adjusting the diagnostics range to be in main
file, therefore these diagnostics ended up pointing some arbitrary locations.

This patch fixes that issue by adjusting the range of diagnostics to be the
first note inside main file when converting to LSP.

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72458
2020-01-09 18:02:33 +01:00
David Goldman ea9888b8f6 [clangd] Respect `--sysroot` argument if it is set
Summary:
- Since `--sysroot` is a superset of the `-isysroot` argument, we
  shouldn't add the `-isysroot` if we detect a `--sysroot` flag.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72415
2020-01-09 11:02:58 -05:00
Kadir Cetinkaya 287a874d1c
[clangd] Refurbish HoverInfo::present
Summary: Improves basic hover presentation logic to include more info.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71555
2020-01-09 11:26:25 +01:00
Utkarsh Saxena 583ba07884 [clangd] Add xref for macros to FileIndex.
Summary:
Adds macro references to the dynamic index.
Tests added.
Also exposed a new API to convert path to URI in URI.h

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71406
2020-01-08 08:27:50 +01:00
Alexandre Ganea 75eacbf1a9 Fix issues reported by -Wrange-loop-analysis when building with latest Clang (trunk). NFC.
Fixes warning: loop variable 'E' of type 'const llvm::StringRef' creates a copy from type 'const llvm::StringRef' [-Wrange-loop-analysis]
2020-01-07 13:58:26 -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
Nathan Ridge 751d4dae32 [clangd] Assert that the testcases in LocateSymbol.All have no diagnostics
Summary: Also fix some bugs in the testcases which this exposed.

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72066
2020-01-07 12:13:32 -05:00
Kadir Cetinkaya a000f2e53f
[clangd] Introduce bulletlists
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71422
2020-01-07 15:21:11 +01:00
Sam McCall c69ae835d0 [clangd] Add path mappings functionality
Summary: Add path mappings to clangd which translate file URIs on inbound and outbound LSP messages. This mapping allows clangd to run in a remote environment (e.g. docker), where the source files and dependencies may be at different locations than the host. See http://lists.llvm.org/pipermail/clangd-dev/2019-January/000231.htm for more.

Patch by William Wagner!

Reviewers: sammccall, ilya-biryukov

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64305
2020-01-07 12:40:51 +01: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
Kadir Cetinkaya b2eaac3e3e
[clangd] Replace shortenNamespace with getQualification
Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71652
2020-01-03 09:05:30 +01:00
Kazuaki Ishizaki 7ab9acd8f4 Fix trivial typos in comments; NFC 2020-01-02 13:41:43 -05:00