Commit Graph

2061 Commits

Author SHA1 Message Date
Kadir Cetinkaya cc9fefec43
[clangd] Make version in PublishDiagnosticsParams optional
Summary: We were serializing it no matter what, which was against the spec

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79692
2020-05-11 10:31:10 +02:00
Richard Smith c7ebf00670 Fix clangd test that depended on a diagnostic removed in Clang. 2020-05-10 14:13:25 -07:00
Kadir Cetinkaya 35d867a790
[clangd] Filter pch related flags coming from the user
Summary:
PCH format is unstable, hence using a preamble built with a different
version of clang (or even worse, a different compiler) might result in
unexpected behaviour.

PCH creation on the other hand is something clangd wouldn't want to perform, as
it doesn't generate any output files.

This patch makes sure clangd drops any PCH related compile commands after
parsing the command line args.

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

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79669
2020-05-10 13:03:59 +02:00
Kadir Cetinkaya c746781f50
[clangd] Fix data race in BackgroundIndex test
MockFSProvider is not thread-safe. Make sure we don't modify it while
background index is working.
2020-05-09 18:15:27 +02:00
Kadir Cetinkaya 84cbd472e5
[clangd] Fix a data race in RecordsLatencies test 2020-05-09 15:42:21 +02:00
Haojian Wu ad811a2728 [clangd] Update the new clangd url, NFC. 2020-05-08 15:11:44 +02:00
Adam Czachorowski 8e7bb37dfb [clangd] Fix crash in AddUsing tweak due to non-identifier DeclName
Patch by Adam Czachorowski!

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79582
2020-05-08 14:26:21 +02:00
Kirill Bobyrev 9c198b550e
[clangd] NFC: Use deprecated grpc++ headers for compatibility
Summary:
Ubuntu 18.04 and older versions do not provide latest gRCP packages and the
ones that are in the repository use deprecated headers. Use these headers to
make builds possible.

https://packages.ubuntu.com/bionic/amd64/libgrpc++-dev/filelist

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79487
2020-05-08 11:04:52 +02:00
Adam Czachorowski 9108715321 [clangd] Fix AddUsing tweak for out-of-line functions.
Summary:
We used getEnclosingNamespaceContext(), which calls getParent() rather
than getLexicalParent(), so we would end up adding the "using" line in
places that do not affect the cursor location, or just return an error
when declaration was in another file.

Patch by Adam Czachorowski!

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79496
2020-05-07 12:50:04 +02:00
Kadir Cetinkaya 717bef6623
[clangd] Preserve line information while build PreamblePatch
Summary: Depends on D78740.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78743
2020-05-07 12:24:28 +02:00
Kadir Cetinkaya 6d6d48add8
[clangd] Reland 'Handle PresumedLocations in IncludeCollector'
Summary:
This will enable extraction of correct line locations in preamble patch
for includes.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78740
2020-05-06 17:57:03 +02:00
Adam Czachorowski 319787315d [clangd] Do not offer "Add using" tweak in header files.
Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79488
2020-05-06 15:50:54 +02:00
Kadir Cetinkaya 9b509bca85
Revert "[clangd] Handle PresumedLocations in IncludeCollector"
This reverts commit 4f7917c269 as it is
breaking windows build bots.
2020-05-06 13:17:08 +02:00
Kadir Cetinkaya 4f7917c269
[clangd] Handle PresumedLocations in IncludeCollector
Summary:
This will enable extraction of correct line locations in preamble patch
for includes.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78740
2020-05-06 13:06:49 +02:00
Kadir Cetinkaya d870016bfc
[clangd] Get rid of Inclusion::R
Summary:
This is only used by documentlink and go-to-definition. We are pushing
range detection logic from Inclusion creation to users. This would make using
stale preambles easier.

For document links we make use of the spelledtokens stored in tokenbuffers to
figure out file name range.

For go-to-def, we keep storing the line number we've seen the include directive.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79315
2020-05-05 12:23:58 +02:00
Kirill Bobyrev 07f8ca6ab1 [clangd] NFC: Cleanup unused headers and libraries
Summary: Extended version of D78843.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79313
2020-05-05 11:46:28 +02:00
Hans Wennborg 3c2c7760d9 Fix building with GCC5 after e64f99c51a
It was failing with:

  /work/llvm.monorepo/clang-tools-extra/clangd/ClangdServer.cpp: In lambda function:
  /work/llvm.monorepo/clang-tools-extra/clangd/ClangdServer.cpp:374:75:
  error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’
                                                  trace::Metric::Distribution);
                                                                             ^
2020-05-04 11:12:39 +02:00
Sam McCall 6fe20a44fd [clangd] Fix yet-another gratuitous llvm::Error crash 2020-05-03 22:13:58 +02:00
Kadir Cetinkaya 81e48ae2b4
[clangd] Reland LSP latency test 2020-05-03 21:06:57 +02:00
Kadir Cetinkaya 7016043d0d
[clangd] Change include to be relative to current directory 2020-05-03 18:09:50 +02:00
Kadir Cetinkaya af28c74e8f
[clangd] Drop duplicate header 2020-05-03 15:20:20 +02:00
Kadir Cetinkaya 6c24b59ca1
[clangd] Fix name hiding in TestTracer and disable racy test for now 2020-05-03 11:51:23 +02:00
Kadir Cetinkaya e64f99c51a
[clangd] Metric tracking through Tracer
Summary: Introduces an endpoint to Tracer for tracking metrics on
internal events.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78429
2020-05-03 10:50:32 +02:00
Sam McCall b283ae7af8 [ADT] Add locale-independent isSpace() to StringExtras. NFC
Use this in clangd, will follow up with replacements for isspace where
locale-dependent is clearly not intended.
2020-05-02 15:20:05 +02:00
Sam McCall fa1f4cf843 [clangd] Rename FormattedString -> Markup, move to support. NFC 2020-05-02 14:53:47 +02:00
Sam McCall ec170b7ccd [clangd] Fix whitespace between chunks in markdown paragraphs.
Summary:
Old model: chunks are always separated by one space.
           This makes it impossible to render "Foo `bar`." correctly.

New model: chunks are separated by space if the left had trailing space, or
           the right had leading space, or space was explicitly requested.
           (Only leading/trailing space in plaintext chunks count, not code)

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79139
2020-05-02 14:39:54 +02:00
Sam McCall 2cf93ef9fe [clangd] Render doc-comment code spans with `backticks` in plaintext mode
Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79142
2020-04-30 20:16:51 +02:00
Sam McCall 54d7db165d [clangd] Move inserted include from detail -> documentation.
Summary: Many clients try to display all the detail inline, with poor results.

See https://github.com/clangd/clangd/issues/284

Reviewers: hokein

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79106
2020-04-30 19:58:53 +02:00
Sam McCall a3a27a7aee [clangd] Render code complete documentation as plaintext/markdown.
Summary:
Structure is parsed from the raw comment using the existing heuristics used
for hover.

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79157
2020-04-30 19:00:49 +02:00
Kadir Cetinkaya ad2da0521a
[clangd] Get rid of move semantics to unbreak windows build bots 2020-04-30 16:43:50 +02:00
Kadir Cetinkaya 594be179c9
[clangd] Second attempt at fixing VS2019 build bots 2020-04-30 15:37:33 +02:00
Kadir Cetinkaya 932a2b8264
[clangd] Fix VS2019 build bots too 2020-04-30 14:01:09 +02:00
Kadir Cetinkaya 7a3be975b9
[clangd][Hover] Get rid of unused private field in Paragraph 2020-04-30 12:13:18 +02:00
Kadir Cetinkaya 0dedb43153
[clangd] Fix windows build bots without rvalue refs 2020-04-30 10:25:22 +02:00
Kadir Cetinkaya 97c407db77
[clangd] Make use of URIs in FileShardedIndex
Summary:
This makes FileShardedIndex more robust and gets rid of the need for a
URIToFileCache, as it is done by the callers now and it is only once per file,
rather than once per symbol.

Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79079
2020-04-30 09:47:59 +02:00
Sam McCall 30d17d8852 [clangd] Parse `foo` in documentation comments and render as code.
Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77456
2020-04-30 00:22:15 +02:00
Sam McCall e7a7deb60a [clangd] Fix BUILD_SHARED_LIBS build more. 2020-04-29 22:46:41 +02:00
Sam McCall bc029fa6c5 [clangd] Still need pthreads in clangDaemon. 2020-04-29 21:41:12 +02:00
Kirill Bobyrev 4645ef17ff
[clangd] Add CMake dependencies for Protobuf-generated files
Summary:
Dependencies ensure that Protobufs are generated before all libraries
depending on the headers are **built**, not linked.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79085
2020-04-29 17:01:03 +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
Richard Smith c35f3f8679 Fix up clangd after clang commit llvmorg-11-init-13375-g0a088ead85f.
It's not clear whether clangd should really consider #import to mark a
header as self-contained or not, but this change preserves the old (and
unit-tested) behavior.
2020-04-28 23:49:35 -07:00
Sam McCall 4e769e93b9 Reland "Add a facility to get system cache directory and use it in clangd"
This reverts commit faf2dce1dd.
2020-04-29 00:56:36 +02:00
Eric Christopher faf2dce1dd Temporarily revert "Add a facility to get system cache directory and use it in clangd"
This reverts commit ad38f4b371.

As it broke building the unittests:

.../sources/llvm-project/llvm/unittests/Support/Path.cpp:334:5: error: use of undeclared identifier 'set'
    set(Value);
    ^
1 error generated.
2020-04-28 15:49:46 -07:00
Vojtěch Štěpančík ad38f4b371 Add a facility to get system cache directory and use it in clangd
Summary:
This patch adds a function that is similar to `llvm::sys::path::home_directory`, but provides access to the system cache directory.

For Windows, that is %LOCALAPPDATA%, and applications should put their files under %LOCALAPPDATA%\Organization\Product\.

For *nixes, it adheres to the XDG Base Directory Specification, so it first looks at the XDG_CACHE_HOME environment variable and falls back to ~/.cache/.

Subsequently, the Clangd Index storage leverages this new API to put index files somewhere else than the users home directory.

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

Reviewers: sammccall, chandlerc, Bigcheese

Reviewed By: sammccall

Subscribers: hiraditya, ilya-biryukov, MaskRay, jkorous, dexonsmith, arphaman, kadircet, ormris, usaxena95, cfe-commits, llvm-commits

Tags: #clang-tools-extra, #clang, #llvm

Differential Revision: https://reviews.llvm.org/D78501
2020-04-28 23:18:31 +02:00
Kirill Bobyrev 9ff3f339e8
[clangd] Fix remote index build without shared libs mode
Summary:
Generated Protobuf library has to be in CLANG_EXPORTS and should also be
installed appropriately. The easiest way to do that is via CMake's
add_clang_library. That unfortunately applies "one directory - one
clang_(library|tool)" policy so .proto files should be in a separate directory
and complicates the layout.

This setup works both in shared and static libs mode.

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

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D78885
2020-04-28 19:16:37 +02:00
Arthur Eubanks 8000d506af [clangd] Strip /showIncludes in clangd compile commands
In command lines with /showIncludes, clangd would output includes to stdout, breaking clients.

Summary: Fixes https://github.com/clangd/clangd/issues/322.

Reviewers: sammccall, kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78836
2020-04-26 18:57:39 -07:00
Sam McCall 6880c4dfa3 [clangd] Fold buildAST into ParsedAST::build. NFCI 2020-04-27 00:14:03 +02:00
Sam McCall 6d7637dc46 [clangd] Disable delayed template parsing in the main file
Summary:
This is on by default in windows and breaks most features in template bodies.
We'd already disabled it in code completion, now disable it for building ASTs.

Potential regressions:
 - we may give spurious errors where files with templates relying on delayed
   parsing are directly opened
 - we may misparse such template bodies that are instantiated (and therefore
   *were* previously parsed)

Still *probably* a win overall. Avoiding the regressions entirely would be
substantial work and we don't have plans for it now.

Fixes https://github.com/clangd/clangd/issues/302 (again)

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78848
2020-04-26 14:29:38 +02:00
Nathan Ridge 230cae89db [clangd] Enable textual fallback for go-to-definition on dependent names
Reviewers: sammccall

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76451
2020-04-26 00:38:38 -04:00
Kadir Cetinkaya a940a246f5
[clangd] Disable dependency-output lit test on windows 2020-04-25 13:55:38 +02:00