summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Index Interfaces for XrefsHaojian Wu2018-08-066-3/+77
| | | | | | | | | | | | | | Summary: This is the first step of implementing Xrefs in clangd: - add index interfaces, and related data structures. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49658 llvm-svn: 339011
* [clangd] Fix fuzzer build.Matt Morehouse2018-08-041-1/+2
| | | | llvm-svn: 338947
* [clangd] capitalize diagnostic messagesAlex Lorenz2018-08-031-2/+9
| | | | | | | | | The diagnostic messages that are sent to the client from Clangd are now always capitalized. Differential Revision: https://reviews.llvm.org/D50154 llvm-svn: 338919
* [clangd] allow clients to control the compilation database by passing inAlex Lorenz2018-08-017-15/+227
| | | | | | | | | | | | | compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request This commit allows clangd to use an in-memory compilation database that's controlled from the LSP client (-compile_args_from=lsp). It extends the 'workspace/didChangeConfiguration' request to allow the client to pass in a compilation database subset that needs to be updated in the workspace. Differential Revision: https://reviews.llvm.org/D49758 llvm-svn: 338597
* [clangd] Correct the namespace of ParsedAST forward declaration, NFC.Haojian Wu2018-08-011-1/+1
| | | | llvm-svn: 338526
* [clangd] Receive compilationDatabasePath in 'initialize' requestSimon Marchi2018-08-014-13/+27
| | | | | | | | | | | | | | | | | | Summary: That way, as soon as the "initialize" is received by the server, it can start parsing/indexing with a valid compilation database and not have to wait for a an initial 'didChangeConfiguration' that might or might not happen. Then, when the user changes configuration, a didChangeConfiguration can be sent. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewers: malaperle Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49833 llvm-svn: 338518
* [clangd] Make SymbolLocation => bool conversion explicitly.Haojian Wu2018-08-011-1/+8
| | | | | | | | | | | | | | | Summary: The implicit bool conversion could happen superisingly, e.g. when checking `if (Loc1 == Loc2)`, the compiler will convert SymbolLocation to bool before comparing (because we don't define operator `==` for SymbolLocation). Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49657 llvm-svn: 338517
* [clangd] Do not build AST if no diagnostics were requestedIlya Biryukov2018-07-311-2/+5
| | | | | | | | | | | | | | | | Summary: It can be removed from the cache before the first access anyway, so building it can be a waste of time. Reviewers: ioeric Reviewed By: ioeric Subscribers: javed.absar, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49991 llvm-svn: 338378
* [clangd] Report diagnostics even if WantDiags::No AST was reusedIlya Biryukov2018-07-311-22/+37
| | | | | | | | | | | | | | | | Summary: After r338256, clangd stopped reporting diagnostics if WantDiags::No request is followed by a WantDiags::Yes request but the AST can be reused. Reviewers: ioeric Reviewed By: ioeric Subscribers: javed.absar, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50045 llvm-svn: 338361
* [clangd] Remove outdated comment. NFCIlya Biryukov2018-07-301-2/+0
| | | | llvm-svn: 338260
* [clangd] Do not remove AST from cache if nothing changedIlya Biryukov2018-07-301-2/+5
| | | | | | | We were previously clearing the AST cache if the inputs and the preamble were the same, which is not desired. llvm-svn: 338256
* [clangd] Fix a comment. NFCIlya Biryukov2018-07-301-2/+2
| | | | llvm-svn: 338241
* [clangd] Add command-line optionRaoul Wols2018-07-291-1/+12
| | | | | | to suppress the space and the circular dot prepended in a completion label. llvm-svn: 338223
* [clangd] Return Dex IteratorsKirill Bobyrev2018-07-273-0/+397
| | | | | | | | | | | | | | | The original Dex Iterators patch (https://reviews.llvm.org/rL338017) caused problems for Clang 3.6 and Clang 3.7 due to the compiler bug which prevented inferring template parameter (`Size`) in create(And|Or)? functions. It was reverted in https://reviews.llvm.org/rL338054. In this revision the mentioned helper functions were replaced with variadic templated versions. Proposed changes were tested on multiple compiler versions, including Clang 3.6 which originally caused the failure. llvm-svn: 338116
* Revert Clangd Dex Iterators patchKirill Bobyrev2018-07-263-388/+0
| | | | | | | | | | | | This reverts two revisions: * https://reviews.llvm.org/rL338017 * https://reviews.llvm.org/rL338028 They caused crash for Clang 3.6 & Clang 3.7 buildbots, it was reported by Jeremy Morse. llvm-svn: 338054
* [clangd] Use 'const Twine&' instead of 'Twine'. NFCIlya Biryukov2018-07-262-2/+2
| | | | | | To fix clang-tidy warning llvm-svn: 338037
* [clangd] Fix (most) naming warnings from clang-tidy. NFCIlya Biryukov2018-07-2614-47/+47
| | | | llvm-svn: 338021
* [clangd] Proof-of-concept query iterators for Dex symbol indexKirill Bobyrev2018-07-263-0/+388
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces three essential types of query iterators: `DocumentIterator`, `AndIterator`, `OrIterator`. It provides a convenient API for query tree generation and serves as a building block for the next generation symbol index - Dex. Currently, many optimizations are missed to improve code readability and to serve as the reference implementation. Potential improvements are briefly mentioned in `FIXME`s and will be addressed in the following patches. Dex RFC in the mailing list: http://lists.llvm.org/pipermail/clangd-dev/2018-July/000022.html Iterators, their applications and potential extensions are explained in detail in the design proposal: https://docs.google.com/document/d/1C-A6PGT6TynyaX4PXyExNMiGmJ2jL1UwV91Kyx11gOI/edit#heading=h.903u1zon9nkj Reviewers: ioeric, sammccall, ilya-biryukov Subscribers: cfe-commits, klimek, jfb, mgrang, mgorny, MaskRay, jkorous, arphaman Differential Revision: https://reviews.llvm.org/D49546 llvm-svn: 338017
* [clangd] Give an example for symbol-builder usageKirill Bobyrev2018-07-261-4/+17
| | | | | | | | | | | | | | | | `global-symbol-builder` help message mentions `-executor=<string>` option, but doesn't give any example of what the value could be Assuming the most popular use case to be building the whole project index, help message should probably give an example of such usage. Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49785 llvm-svn: 338015
* [clangd] Do not rebuild AST if inputs have not changedIlya Biryukov2018-07-261-3/+30
| | | | | | | | | | | | | | | | | Summary: If the contents are the same, the update most likely comes from the fact that compile commands were invalidated. In that case we want to avoid rebuilds in case the compile commands are actually the same. Reviewers: ioeric Reviewed By: ioeric Subscribers: simark, javed.absar, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D49783 llvm-svn: 338012
* [clangd] Use a sigmoid style function for #usages boost in symbol quality.Eric Liu2018-07-251-2/+12
| | | | | | | | | | | | | | | | | | Summary: This has a shape to similar logarithm function but grows much slower for large #usages. Metrics: https://reviews.llvm.org/P8096 Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits, sammccall Differential Revision: https://reviews.llvm.org/D49780 llvm-svn: 337907
* [clangd] Introduce Dex symbol index search tokensKirill Bobyrev2018-07-254-0/+309
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces the core building block of the next-generation Clangd symbol index - Dex. Search tokens are the keys in the inverted index and represent a characteristic of a specific symbol: examples of search token types (Token Namespaces) are * Trigrams - these are essential for unqualified symbol name fuzzy search * Scopes for filtering the symbols by the namespace * Paths, e.g. these can be used to uprank symbols defined close to the edited file This patch outlines the generic for such token namespaces, but only implements trigram generation. The intuition behind trigram generation algorithm is that each extracted trigram is a valid sequence for Fuzzy Matcher jumps, proposed implementation utilize existing FuzzyMatcher API for segmentation and trigram extraction. However, trigrams generation algorithm for the query string is different from the previous one: it simply yields sequences of 3 consecutive lowercased valid characters (letters, digits). Dex RFC in the mailing list: http://lists.llvm.org/pipermail/clangd-dev/2018-July/000022.html The trigram generation techniques are described in detail in the proposal: https://docs.google.com/document/d/1C-A6PGT6TynyaX4PXyExNMiGmJ2jL1UwV91Kyx11gOI/edit#heading=h.903u1zon9nkj Reviewers: sammccall, ioeric, ilya-biryukovA Subscribers: cfe-commits, klimek, mgorny, MaskRay, jkorous, arphaman Differential Revision: https://reviews.llvm.org/D49591 llvm-svn: 337901
* [clangd] Guard fuzzer against empty inputs.Benjamin Kramer2018-07-241-0/+3
| | | | llvm-svn: 337860
* [clangd] Tune down quality score for class constructors so that it's ranked ↵Eric Liu2018-07-242-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | after class types. Summary: Currently, class constructors have the same score as the class types, and they are often ranked before class types. This is often not desireable and can be annoying when snippet is enabled and constructor signatures are added. Metrics: ``` ================================================================================================== OVERALL ================================================================================================== Total measurements: 111117 (+0) All measurements: MRR: 64.06 (+0.20) Top-5: 75.73% (+0.14%) Top-100: 93.71% (+0.01%) Full identifiers: MRR: 98.25 (+0.55) Top-5: 99.04% (+0.03%) Top-100: 99.16% (+0.00%) Filter length 0-5: MRR: 15.23 (+0.02) 50.50 (-0.02) 65.04 (+0.11) 70.75 (+0.19) 74.37 (+0.25) 79.43 (+0.32) Top-5: 40.90% (+0.03%) 74.52% (+0.03%) 87.23% (+0.15%) 91.68% (+0.08%) 93.68% (+0.14%) 95.87% (+0.12%) Top-100: 68.21% (+0.02%) 96.28% (+0.07%) 98.43% (+0.00%) 98.72% (+0.00%) 98.74% (+0.01%) 98.81% (+0.00%) ================================================================================================== DEFAULT ================================================================================================== Total measurements: 57535 (+0) All measurements: MRR: 58.07 (+0.37) Top-5: 69.94% (+0.26%) Top-100: 90.14% (+0.03%) Full identifiers: MRR: 97.13 (+1.05) Top-5: 98.14% (+0.06%) Top-100: 98.34% (+0.00%) Filter length 0-5: MRR: 13.91 (+0.00) 38.53 (+0.01) 55.58 (+0.21) 63.63 (+0.30) 69.23 (+0.47) 72.87 (+0.60) Top-5: 24.99% (+0.00%) 62.70% (+0.06%) 82.80% (+0.30%) 88.66% (+0.16%) 92.02% (+0.27%) 93.53% (+0.21%) Top-100: 51.56% (+0.05%) 93.19% (+0.13%) 97.30% (+0.00%) 97.81% (+0.00%) 97.85% (+0.01%) 97.79% (+0.00%) ``` Remark: - The full-id completions have +1.05 MRR improvement. - There is no noticeable impact on EXPLICIT_MEMBER_ACCESS and WANT_LOCAL. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49667 llvm-svn: 337816
* [clangd] Fix category in clangd-vscode's package.jsonSimon Marchi2018-07-231-1/+1
| | | | | | | | | | | | | | | | | Summary: When opening package.json, vscode shows: Use 'Programming Languages' instead Replacing "Languages" with this fixes it. Reviewers: ilya-biryukov Subscribers: arphaman, ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D49253 llvm-svn: 337697
* [clangd] Penalize non-instance members when accessed via class instances.Eric Liu2018-07-234-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The following are metrics for explicit member access completions. There is no noticeable impact on other completion types. Before: EXPLICIT_MEMBER_ACCESS Total measurements: 24382 All measurements: MRR: 62.27 Top10: 80.21% Top-100: 94.48% Full identifiers: MRR: 98.81 Top10: 99.89% Top-100: 99.95% 0-5 filter len: MRR: 13.25 46.31 62.47 67.77 70.40 81.91 Top-10: 29% 74% 84% 91% 91% 97% Top-100: 67% 99% 99% 99% 99% 100% After: EXPLICIT_MEMBER_ACCESS Total measurements: 24382 All measurements: MRR: 63.18 Top10: 80.58% Top-100: 95.07% Full identifiers: MRR: 98.79 Top10: 99.89% Top-100: 99.95% 0-5 filter len: MRR: 13.84 48.39 63.55 68.83 71.28 82.64 Top-10: 30% 75% 84% 91% 91% 97% Top-100: 70% 99% 99% 99% 99% 100% * Top-N: wanted result is found in the first N completion results. * MRR: Mean reciprocal rank. Remark: the change seems to have minor positive impact. Although the improvement is relatively small, down-ranking non-instance members in instance member access should reduce noise in the completion results. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49543 llvm-svn: 337681
* [clangd] Unbreak fuzzer build.Benjamin Kramer2018-07-221-1/+2
| | | | llvm-svn: 337655
* [clangd] FuzzyMatch exposes an API for its word segmentation. NFCSam McCall2018-07-202-45/+58
| | | | | | | | | | | | Summary: This is intended to be used for indexing, e.g. in D49417 Reviewers: ioeric, omtcyfz Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49540 llvm-svn: 337527
* [clangd] Also get scope for RK_pattern completion results.Eric Liu2018-07-181-2/+4
| | | | | | | For exmaple, clas field candidates in constructor initializers can be RK_Pattern, but they can still have scopes. llvm-svn: 337396
* [clangd] Extract FileSystemProvider into a separate header. NFCSam McCall2018-07-123-20/+43
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D49142 llvm-svn: 336909
* [clangd] log request/response messages with method/ID/error at INFO levelSam McCall2018-07-121-8/+29
| | | | | | | | | | | | Summary: Bodies are logged at VERBOSE level (since r336785), tweak the formatting. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D49224 llvm-svn: 336899
* [clangd] Simplify logging wrapper after r336888Sam McCall2018-07-121-14/+5
| | | | llvm-svn: 336890
* [clangd] Uprank delcarations when "using q::name" is present in the main fileKirill Bobyrev2018-07-111-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | Having `using qualified::name;` for some symbol is an important signal for clangd code completion as the user is more likely to use such symbol. This patch helps to uprank the relevant symbols by saving UsingShadowDecl in the new field of CodeCompletionResult and checking whether the corresponding UsingShadowDecl is located in the main file later in ClangD code completion routine. While the relative importance of such signal is a subject to change in the future, this patch simply bumps DeclProximity score to the value of 1.0 which should be enough for now. The patch was tested using `$ ninja check-clang check-clang-tools` No unexpected failures were noticed after running the relevant testsets. Reviewers: sammccall, ioeric Subscribers: MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D49012 llvm-svn: 336810
* [clangd] Ignore sema code complete callback with recovery context.Eric Liu2018-07-111-0/+13
| | | | | | | | | | | | | | | | | | | Summary: Sema code complete in the recovery mode is generally useless. For many cases, sema first completes in recovery context and then recovers to more useful context, in which it's favorable to ignore results from recovery (as results are often bad e.g. all builtin symbols and top-level symbols). There is also case where only sema would fail to recover e.g. completions in excluded #if block. Sema would try to give results, but the results are often useless (see the updated excluded #if block test). Reviewers: sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D49175 llvm-svn: 336801
* [clangd] Upgrade logging facilities with levels and formatv.Sam McCall2018-07-1120-110/+177
| | | | | | | | | | | | | | | | | | | | | | Summary: log() is split into four functions: - elog()/log()/vlog() have different severity levels, allowing filtering - dlog() is a lazy macro which uses LLVM_DEBUG - it logs to the logger, but conditionally based on -debug-only flag and is omitted in release builds All logging functions use formatv-style format strings now, e.g: log("Could not resolve URI {0}: {1}", URI, Result.takeError()); Existing log sites have been split between elog/log/vlog by best guess. This includes a workaround for passing Error to formatv that can be simplified when D49170 or similar lands. Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D49008 llvm-svn: 336785
* [clangd] Make sure macro information exists before increasing usage count.Eric Liu2018-07-091-6/+4
| | | | llvm-svn: 336581
* [clangd] Support indexing MACROs.Eric Liu2018-07-092-25/+121
| | | | | | | | | | | | | | Summary: This is not enabled in the global-symbol-builder or dynamic index yet. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D49028 llvm-svn: 336553
* [clangd] Remove JSON library in favor of llvm/Support/JSONSam McCall2018-07-0912-1381/+245
| | | | | | | | | | | | | | | | | | | | Summary: The library has graduated from clangd to llvm/Support. This is a mechanical change to move to the new API and remove the old one. Main API changes: - namespace clang::clangd::json --> llvm::json - json::Expr --> json::Value - Expr::asString() etc --> Value::getAsString() etc - unsigned longs need a cast (due to r336541 adding lossless integer support) Reviewers: ilya-biryukov Subscribers: mgorny, ioeric, MaskRay, jkorous, omtcyfz, cfe-commits Differential Revision: https://reviews.llvm.org/D49077 llvm-svn: 336549
* [clangd] Do not write comments into Preamble PCHIlya Biryukov2018-07-092-32/+12
| | | | | | | | | | | | | | | | | | | | Summary: To avoid wasting time deserializing them on code completion and further reparses. We do not use the comments anyway, because we cannot rely on the file contents staying the same for reparses that reuse the prebuilt preamble PCH. Reviewers: sammccall Reviewed By: sammccall Subscribers: ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48943 llvm-svn: 336540
* [clangd] Wait for first preamble before code completionIlya Biryukov2018-07-092-0/+25
| | | | | | | | | | | | | | | | Summary: To avoid doing extra work of processing headers in the preamble mutilple times in parallel. Reviewers: sammccall Reviewed By: sammccall Subscribers: javed.absar, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48940 llvm-svn: 336538
* [clangd] Make SymbolOrigin an enum class, rather than a plain enum.Sam McCall2018-07-064-14/+23
| | | | | | | I never intended to define namespace pollution like clangd::AST, clangd::Unknown etc. Oops! llvm-svn: 336431
* [clangd] Implementation of textDocument/documentSymbolMarc-Andre Laperle2018-07-0513-16/+178
| | | | | | | | | | | | | | | | | Summary: An AST-based approach is used to retrieve the document symbols rather than an in-memory index query. The index is not an ideal fit to achieve this because of the file-centric query being done here whereas the index is suited for project-wide queries. Document symbols also includes more symbols and need to keep the order as seen in the file. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Subscribers: tomgr, ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47846 llvm-svn: 336386
* [NFS] Wipe trailing whitespacesKirill Bobyrev2018-07-051-62/+63
| | | | | | | | This patch is a preparation for another one containing meaningful changes. This patch simply removes trailing whitespaces in few files affected by the upcoming patch and reformats llvm-svn: 336330
* Fix -Wunused-variable warning. NFCI.Simon Pilgrim2018-07-051-1/+1
| | | | llvm-svn: 336329
* [clangd] Log sema completion context kind and query scopes. NFCEric Liu2018-07-051-2/+9
| | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48724 llvm-svn: 336321
* Revert "[clangd] FileDistance: temporarily disable in CodeComplete, it's ↵Sam McCall2018-07-051-2/+1
| | | | | | | | | behaving badly" The bad behavior seems to have been fixed by r336242 after all. I thought it was persisting, but that was a different bug fixed by D48940 llvm-svn: 336320
* [clangd] Treat class constructor as in the same scope as the class in ranking.Eric Liu2018-07-051-0/+5
| | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48933 llvm-svn: 336318
* [clangd] Track origins of symbols (various indexes, Sema).Sam McCall2018-07-0510-10/+60
| | | | | | | | | | | | Summary: Surface it in the completion items C++ API, and when a flag is set. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48938 llvm-svn: 336309
* [clangd] only ignore collected symbols if TU has uncompilable errors.Eric Liu2018-07-041-3/+4
| | | | llvm-svn: 336260
* [clangd] Avoid collecting symbols from broken TUs in global-symbol-builder.Eric Liu2018-07-041-0/+8
| | | | | | | | | | | | | | Summary: For example, template parameter might not be resolved in a broken TU, which can result in wrong USR/SymbolID. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48881 llvm-svn: 336252
OpenPOWER on IntegriCloud