summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Remove UB introduced in rL341057Kirill Bobyrev2018-08-301-1/+0
| | | | llvm-svn: 341066
* [clangd] Report position of opening paren in singature helpIlya Biryukov2018-08-302-1/+18
| | | | | | | | | | | | | | Summary: Only accessible via the C++ API at the moment. Reviewers: sammccall Reviewed By: sammccall Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51437 llvm-svn: 341065
* [clangd] Implement iterator costKirill Bobyrev2018-08-302-3/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces iterator cost concept to improve the performance of Dex query iterators (mainly, AND iterator). Benchmarks show that the queries become ~10% faster. Before ``` ------------------------------------------------------- Benchmark Time CPU Iteration ------------------------------------------------------- DexAdHocQueries 5883074 ns 5883018 ns 117 DexRealQ 959904457 ns 959898507 ns 1 ``` After ``` ------------------------------------------------------- Benchmark Time CPU Iteration ------------------------------------------------------- DexAdHocQueries 5238403 ns 5238361 ns 130 DexRealQ 873275207 ns 873269453 ns 1 ``` Reviewed by: sammccall Differential Revision: https://reviews.llvm.org/D51310 llvm-svn: 341057
* [clangd] Switch to Dex by default for the static indexKirill Bobyrev2018-08-281-1/+2
| | | | | | | | | | | | Dex is now mature enough to be used as the default static index. This patch performs the switch but introduces a hidden flag to allow users fallback to Mem in case something happens. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D51352 llvm-svn: 340828
* [clangd] Use buffered llvm::errs() in the clangd binary.Eric Liu2018-08-281-0/+3
| | | | | | | | | | | | Summary: Unbuffered stream can cause significant (non-deterministic) latency for the logger. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51349 llvm-svn: 340822
* [clangd] Remove unused parameter. NFCIlya Biryukov2018-08-281-6/+5
| | | | llvm-svn: 340816
* [clangd] Add some trace::Spans. NFCIlya Biryukov2018-08-282-0/+2
| | | | llvm-svn: 340815
* [clangd] Use TRUE iterator instead of complete posting listKirill Bobyrev2018-08-271-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stop using `$$$` (empty) trigram and generating a posting list with all items. Since TRUE iterator is already implemented and correctly inserted when there are no real trigram posting lists, this is a valid transformation. Benchmarks show that this simple change allows ~30% speedup on dataset of real completion queries. Before ``` ------------------------------------------------------- Benchmark Time CPU Iterations ------------------------------------------------------- DexAdHocQueries 5640321 ns 5640265 ns 120 DexRealQ 939835603 ns 939830296 ns 1 ``` After ``` ------------------------------------------------------- Benchmark Time CPU Iterations ------------------------------------------------------- DexAdHocQueries 3452014 ns 3451987 ns 203 DexRealQ 667455912 ns 667455750 ns 1 ``` Reviewed by: ilya-biryukov Differential Revision: https://reviews.llvm.org/D51287 llvm-svn: 340729
* [clangd] Initial cancellation mechanism for LSP requests.Kadir Cetinkaya2018-08-2413-29/+356
| | | | | | | | | | | | Reviewers: ilya-biryukov, ioeric, hokein Reviewed By: ilya-biryukov Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50502 llvm-svn: 340607
* [clangd] Implement LIMIT iteratorKirill Bobyrev2018-08-243-36/+79
| | | | | | | | | | | | | This patch introduces LIMIT iterator, which is very important for improving the quality of search query. LIMIT iterators can be applied on top of BOOST iterators to prevent populating query request with a huge number of low-quality symbols. Reviewed by: sammccall Differential Revision: https://reviews.llvm.org/D51029 llvm-svn: 340605
* [clangd] Speculative code completion index request before Sema is run.Eric Liu2018-08-247-17/+199
| | | | | | | | | | | | | | | | | | | | | | | | Summary: For index-based code completion, send an asynchronous speculative index request, based on the index request for the last code completion on the same file and the filter text typed before the cursor, before sema code completion is invoked. This can reduce the code completion latency (by roughly latency of sema code completion) if the speculative request is the same as the one generated for the ongoing code completion from sema. As a sequence of code completions often have the same scopes and proximity paths etc, this should be effective for a number of code completions. Trace with speculative index request:{F6997544} Reviewers: hokein, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: javed.absar, jfb, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D50962 llvm-svn: 340604
* [clangd] Log memory usage of DexIndex and MemIndexKirill Bobyrev2018-08-248-0/+48
| | | | | | | | | | | | This patch prints information about built index size estimation to verbose logs. This is useful for optimizing memory usage of DexIndex and comparisons with MemIndex. Reviewed by: sammccall Differential Revision: https://reviews.llvm.org/D51154 llvm-svn: 340601
* [clangd] Allow to merge symbols on-the-fly in global-symbol-builderIlya Biryukov2018-08-241-35/+108
| | | | | | | | | | | | | | | | | | | | | | Summary: The new mode avoids serializing and deserializing YAML. This results in better performance and less memory usage. Reduce phase is now almost instant. The default is to use the old mode going through YAML serialization to allow migrating MapReduce clients that require the old mode to operate properly. After we migrate the clients, we can switch the default to the new mode. Reviewers: hokein, ioeric, kbobyrev, sammccall Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51155 llvm-svn: 340600
* [clangd] Check for include overlapping looks for only the line now.Kadir Cetinkaya2018-08-231-1/+1
| | | | | | | | | | | | | | | | Summary: Currently we match an include only if we are inside filename, with this patch we will match whenever we are on the starting line of the include. Reviewers: ilya-biryukov, hokein, ioeric Reviewed By: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D51163 llvm-svn: 340539
* [clangd] Suggest code-completions for overriding base class virtual methods.Kadir Cetinkaya2018-08-231-9/+100
| | | | | | | | | | | | | | | | | Summary: Whenever a code-completion is triggered within a class/struct/union looks at base classes and figures out non-overriden virtual functions. Than suggests completions for those. Reviewers: ilya-biryukov, hokein, ioeric Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50898 llvm-svn: 340530
* [clangd] Move function argument snippet disable mechanism from LSP rendering ↵Kadir Cetinkaya2018-08-231-15/+16
| | | | | | | | | | | | | | | | | | | to internal clangd reprensentation. Summary: We were handling the EnableFunctionArgSnippets only when we are producing LSP response. Move that code into CompletionItem generation so that internal clients can benefit from that as well. Reviewers: ilya-biryukov, ioeric, hokein Reviewed By: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D51102 llvm-svn: 340527
* [clangd] send diagnostic categories only when 'categorySupport'Alex Lorenz2018-08-224-1/+14
| | | | | | | | | | | | capability was given by the client After r339738 Clangd started sending categories with each diagnostic, but that broke the eglot client. This commit puts the categories behind a capability to fix that breakage. Differential Revision: https://reviews.llvm.org/D51077 llvm-svn: 340449
* [clangd] Get rid of regexes in CanonicalIncludesIlya Biryukov2018-08-222-679/+687
| | | | | | | | | | | | | | Summary: Replace them with suffix mappings. Reviewers: ioeric, kbobyrev Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51088 llvm-svn: 340410
* [clangd] Implement BOOST iteratorKirill Bobyrev2018-08-223-13/+113
| | | | | | | | | | | | | | | This patch introduces BOOST iterator - a substantial block for efficient and high-quality symbol retrieval. The concept of boosting allows performing computationally inexpensive scoring on the query side so that the final (expensive) scoring can only be applied on the items with the highest preliminary score while eliminating the need to score too many items. Reviewed by: ilya-biryukov Differential Revision: https://reviews.llvm.org/D50970 llvm-svn: 340409
* [clangd] Make FileIndex aware of the main fileIlya Biryukov2018-08-224-33/+64
| | | | | | | | | | | | | | | | | | | | | Summary: It was previously only indexing the preamble decls. The new implementation will index both the preamble and the main AST and report both sets of symbols, preferring the ones from the main AST whenever the symbol is present in both. The symbols in the main AST slab always store all information available in the preamble symbols, possibly adding more, e.g. definition locations. Reviewers: hokein, ioeric Reviewed By: ioeric Subscribers: kadircet, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50889 llvm-svn: 340404
* [clangd] Add callbacks on parsed AST in addition to parsed preamblesIlya Biryukov2018-08-224-27/+74
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Will be used for updating the dynamic index on updates to the open files. Currently we collect only information coming from the preamble AST. This has a bunch of limitations: - Dynamic index misses important information from the body of the file, e.g. locations of definitions. - XRefs cannot be collected at all, since we can only obtain full information for the current file (preamble is parsed with skipped function bodies, therefore not reliable). This patch only adds the new callback, actually updates to the index will be done in a follow-up patch. Reviewers: hokein Reviewed By: hokein Subscribers: kadircet, javed.absar, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50847 llvm-svn: 340401
* [clangd] Cleanup after D50897Kirill Bobyrev2018-08-221-1/+1
| | | | | | | The wrong diff that was uploaded to Phabricator was building the wrong index. llvm-svn: 340388
* [clangd] NFC: Fix broken buildKirill Bobyrev2018-08-211-6/+6
| | | | llvm-svn: 340263
* [clangd] Allow using experimental Dex indexKirill Bobyrev2018-08-215-13/+40
| | | | | | | | | | | This patch adds hidden Clangd flag ("use-dex-index") which replaces (currently) default `MemIndex` with `DexIndex` for the static index. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50897 llvm-svn: 340262
* [clangd] DexIndex implementation prototypeKirill Bobyrev2018-08-204-1/+245
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is a proof-of-concept Dex index implementation. It has several flaws, which don't allow replacing static MemIndex yet, such as: * Not being able to handle queries of small size (less than 3 symbols); a way to solve this is generating trigrams of smaller size and having such incomplete trigrams in the index structure. * Speed measurements: while manually editing files in Vim and requesting autocompletion gives an impression that the performance is at least comparable with the current static index, having actual numbers is important because we don't want to hurt the users and roll out slow code. Eric (@ioeric) suggested that we should only replace MemIndex as soon as we have the evidence that this is not a regression in terms of performance. An approach which is likely to be successful here is to wait until we have benchmark library in the LLVM core repository, which is something I have suggested in the LLVM mailing lists, received positive feedback on and started working on. I will add a dependency as soon as the suggested patch is out for a review (currently there's at least one complication which is being addressed by https://github.com/google/benchmark/pull/649). Key performance improvements for iterators are sorting by cost and the limit iterator. * Quality measurements: currently, boosting iterator and two-phase lookup stage are not implemented, without these the quality is likely to be worse than the current implementation can yield. Measuring quality is tricky, but another suggestion in the offline discussion was that the drop-in replacement should only happen after Boosting iterators implementation (and subsequent query enhancement). The proposed changes do not affect Clangd functionality or performance, `DexIndex` is only used in unit tests and not in production code. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50337 llvm-svn: 340175
* [clangd] Simplify the code using UniqueStringSaver, NFC.Haojian Wu2018-08-202-12/+9
| | | | llvm-svn: 340161
* [clangd] NFC: Cleanup Dex Iterator comments and simplify testsKirill Bobyrev2018-08-202-9/+9
| | | | | | | | | | | | | | | | | | | | | Proposed changes: * Cleanup comments in `clangd/index/dex/Iterator.h`: Vim's `gq` formatting added redundant spaces instead of newlines in few places * Few comments in `OrIterator` are wrong * Use `EXPECT_TRUE(Condition)` instead of `EXPECT_THAT(Condition, true)` (same with `EXPECT_FALSE`) * Don't expose `dump()` method to the public by misplacing `private:` This patch does not affect functionality. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50956 llvm-svn: 340157
* [clangd] Add missing lock in the lookup.Haojian Wu2018-08-201-0/+1
| | | | | | | | | | Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D50960 llvm-svn: 340156
* [clangd] Implement TRUE IteratorKirill Bobyrev2018-08-202-0/+43
| | | | | | | | | | | This patch introduces TRUE Iterator which efficiently handles posting lists containing all items within `[0, Size)` range. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50955 llvm-svn: 340155
* [clangd] Add parantheses while auto-completing functions.Kadir Cetinkaya2018-08-172-2/+15
| | | | | | | | | | | | | | | | | | | Summary: Currently we only add parantheses to the functions if snippets are enabled, which also inserts snippets for parameters into parantheses. Adding a new option to put only parantheses. Also it moves the cursor within parantheses or at the end of them by looking at whether completion item has any parameters or not. Still requires snippets support on the client side. Reviewers: ioeric, ilya-biryukov, hokein Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50835 llvm-svn: 340040
* [clangd] Fetch documentation from the Index during signature helpIlya Biryukov2018-08-173-67/+108
| | | | | | | | | | | | | | | | Summary: Sema can only be used for documentation in the current file, other doc comments should be fetched from the index. Reviewers: hokein, ioeric, kadircet Reviewed By: hokein, kadircet Subscribers: MaskRay, jkorous, mgrang, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50727 llvm-svn: 340005
* [clangd] Show function documentation in signature helpIlya Biryukov2018-08-173-40/+13
| | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clangd was trying to show documentation for the active parameter instead, which is wrong per LSP specification. Moreover, the code path that attempts to get parameter comments never succeds, because no attempt is made to parse function doc comment and extract parameter-specific parts out of it. So we also remove the code that claims to fetch parameter comments: it is not used anymore and is incorrect. Reviewers: hokein, ioeric, kadircet Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50726 llvm-svn: 340004
* [clangd] Always use the latest preambleHaojian Wu2018-08-171-2/+1
| | | | | | | | | | | | | | | | | | | | | Summary: Fix an inconsistent behavior of using `LastBuiltPreamble`/`NewPreamble` in TUScheduler (see the test for details), AST should always use NewPreamble. This patch makes LastBuiltPreamble always point to NewPreamble. Preamble rarely fails to build, even there are errors in headers, so we assume it would not cause performace issue for code completion. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50695 llvm-svn: 340001
* [clangd] NFC: Improve Dex Iterators debugging traitsKirill Bobyrev2018-08-162-3/+14
| | | | | | | | | | | | This patch improves `dex::Iterator` string representation by incorporating the information about the element which is currently being pointed to by the `DocumentIterator`. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50689 llvm-svn: 339877
* [clangd] add an extension field to LSP to transfer the diagnostic's categoryAlex Lorenz2018-08-144-0/+13
| | | | | | | | | This patch adds a 'category' extension field to the LSP diagnostic that's sent by Clangd. This extension is always on by default. Differential Revision: https://reviews.llvm.org/D50571 llvm-svn: 339738
* NFC: Enforce good formatting across multiple clang-tools-extra filesKirill Bobyrev2018-08-1429-63/+84
| | | | | | | | | | | This patch improves readability of multiple files in clang-tools-extra and enforces LLVM Coding Guidelines. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50707 llvm-svn: 339687
* [clangd] NFC: Cleanup clangd help messageKirill Bobyrev2018-08-141-2/+2
| | | | | | | | | | Add missed space, fix a typo. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50702 llvm-svn: 339673
* [clangd] Show non-instantiated decls in signatureHelpIlya Biryukov2018-08-141-1/+9
| | | | | | | | | | | | | | | | | | | | | | | Summary: To avoid producing very verbose output in substitutions involving typedefs, e.g. T -> std::vector<std::string>::iterator gets turned into an unreadable mess when printed out for libstdc++, result contains internal types (std::__Vector_iterator<...>) and expanded well-defined typedefs (std::basic_string<char>). Until we improve the presentation code in clang, going with non-instantiated decls looks like a better UX trade-off. Reviewers: hokein, ioeric, kadircet Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50645 llvm-svn: 339665
* Fix MSVC 'std::min: no matching overloaded function found' error.Simon Pilgrim2018-08-131-1/+2
| | | | llvm-svn: 339557
* [clangd] Generate incomplete trigrams for the Dex indexKirill Bobyrev2018-08-133-34/+82
| | | | | | | | | | | | | | This patch handles trigram generation "short" identifiers and queries. Trigram generator produces incomplete trigrams for short names so that the same query iterator API can be used to match symbols which don't have enough symbols to form a trigram and correctly handle queries which also are not sufficient for generating a full trigram. Reviewed by: ioeric Differential revision: https://reviews.llvm.org/D50517 llvm-svn: 339548
* [clangd] Introduce scoring mechanism for SignatureInformations.Kadir Cetinkaya2018-08-133-11/+78
| | | | | | | | | | | | Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: mgrang, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50555 llvm-svn: 339547
* [clangd] Support textEdit in addition to insertText.Kadir Cetinkaya2018-08-134-7/+54
| | | | | | | | | | | | | | | | Summary: Completion replies contains textEdits as well. Note that this change relies on https://reviews.llvm.org/D50443. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: mgrang, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50449 llvm-svn: 339543
* [clangd] Avoid duplicates in findDefinitions responseSimon Marchi2018-08-104-16/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When compile_commands.json contains some source files expressed as relative paths, we can get duplicate responses to findDefinitions. The responses only differ by the URI, which are different versions of the same file: "result": [ { ... "uri": "file:///home/emaisin/src/ls-interact/cpp-test/build/../src/first.h" }, { ... "uri": "file:///home/emaisin/src/ls-interact/cpp-test/src/first.h" } ] In getAbsoluteFilePath, we try to obtain the realpath of the FileEntry by calling tryGetRealPathName. However, this can fail and return an empty string. It may be bug a bug in clang, but in any case we should fall back to computing it ourselves if it happens. I changed getAbsoluteFilePath so that if tryGetRealPathName succeeds, we return right away (a real path is always absolute). Otherwise, we try to build an absolute path, as we did before, but we also call VFS->getRealPath to make sure to get the canonical path (e.g. without any ".." in it). Reviewers: malaperle Subscribers: hokein, ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48687 llvm-svn: 339483
* [clangd] extend the publishDiagnostics response to send back fixits to theAlex Lorenz2018-08-105-1/+50
| | | | | | | | | | | | | | client if the client supports this extension This commit extends the 'textDocument/publishDiagnostics' notification sent from Clangd to the client. When it's enabled, Clangd sends out the fixits associated with the appropriate diagnostic in the body of the 'publishDiagnostics' notification. The client can enable this extension by setting 'clangdFixSupport' to true in the textDocument capabilities during initialization. Differential Revision: https://reviews.llvm.org/D50415 llvm-svn: 339454
* [clangd] Allow consuming limited number of itemsKirill Bobyrev2018-08-102-5/+7
| | | | | | | | | | | | | | | | | This patch modifies `consume` function to allow retrieval of limited number of symbols. This is the "cheap" implementation of top-level limiting iterator. In the future we would like to have a complete limit iterator implementation to insert it into the query subtrees, but in the meantime this version would be enough for a fully-functional proof-of-concept Dex implementation. Reviewers: ioeric, ilya-biryukov Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50500 llvm-svn: 339426
* Port getLocStart -> getBeginLocStephen Kelly2018-08-093-4/+4
| | | | | | | | | | Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 llvm-svn: 339400
* [clangd] Try to fix buildbot after r339320.Eric Liu2018-08-091-1/+1
| | | | | | http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/5487 llvm-svn: 339322
* [clangd] Record the file being processed in a TUScheduler thread in context.Eric Liu2018-08-092-6/+25
| | | | | | | | | | | | | | | | | Summary: This allows implementations like different symbol indexes to know what the current active file is. For example, some customized index implementation might decide to only return results for some files. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: javed.absar, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50446 llvm-svn: 339320
* Added functionality to suggest FixIts for conversion of '->' to '.' and vice ↵Kadir Cetinkaya2018-08-088-12/+49
| | | | | | | | | | | | | | | | versa. Summary: Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: yvvan, ioeric, jkorous, arphaman, cfe-commits, kadircet Differential Revision: https://reviews.llvm.org/D50193 llvm-svn: 339224
* [clangd] Share getSymbolID implementation.Haojian Wu2018-08-075-22/+21
| | | | | | | | | | | | Summary: And remove all duplicated implementation. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50375 llvm-svn: 339116
OpenPOWER on IntegriCloud