summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clangd
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Change index scope convention from "outer::inner" to "outer::inner::"Sam McCall2018-01-193-12/+9
| | | | | | | | | | | | | | | | | | | Global scope is "" (was "") Top-level namespace scope is "ns::" (was "ns") Nested namespace scope is "ns::ns::" (was "ns::ns") This composes more naturally: - qname = scope + name - full scope = resolved scope + unresolved scope (D42073 was the trigger) It removes a wart from the old way: "foo::" has one more separator than "". Another alternative that has these properties is "::ns", but that lacks the property that both the scope and the name are substrings of the qname as produced by clang. This is re-landing r322996 which didn't build. llvm-svn: 323000
* Revert "[clangd] Change index scope convention from "outer::inner" to ↵Sam McCall2018-01-193-9/+12
| | | | | | | | "outer::inner::"" This reverts commit r322996. llvm-svn: 322998
* [clangd] Change index scope convention from "outer::inner" to "outer::inner::"Sam McCall2018-01-193-12/+9
| | | | | | | | | | | | | | | | | Global scope is "" (was "") Top-level namespace scope is "ns::" (was "ns") Nested namespace scope is "ns::ns::" (was "ns::ns") This composes more naturally: - qname = scope + name - full scope = resolved scope + unresolved scope (D42073 was the trigger) It removes a wart from the old way: "foo::" has one more separator than "". Another alternative that has these properties is "::ns", but that lacks the property that both the scope and the name are substrings of the qname as produced by clang. llvm-svn: 322996
* [clangd] Merge index-provided completions with those from Sema.Sam McCall2018-01-191-76/+100
| | | | | | | | | | | | | | | | | | | Summary: - we match on USR, and do a field-by-field merge if both have results - scoring is post-merge, with both sets of information available (for now, sema priority is used if available, static score for index results) - limit is applied to the complete result set (previously index ignored limit) - CompletionItem is only produces for the returned results - If the user doesn't type a scope, we send the global scope for completion (we can improve this after D42073) Reviewers: ioeric Subscribers: klimek, ilya-biryukov, mgrang, cfe-commits Differential Revision: https://reviews.llvm.org/D42181 llvm-svn: 322945
* [clangd] Collect enum constants in SymbolCollectorHaojian Wu2018-01-191-0/+37
| | | | | | | | | | | | | | | | Summary: * ignore nameless symbols * include enum constant declarataion Reviewers: ilya-biryukov, jkorous-apple Reviewed By: ilya-biryukov Subscribers: ioeric, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D42074 llvm-svn: 322929
* [clangd] Remove unused IncludeGlobals completion option, always pass true to ↵Sam McCall2018-01-181-5/+4
| | | | | | sema llvm-svn: 322856
* [clangd] CodeCompleteTests cleanup: naming, ordering, helpers. NFCSam McCall2018-01-181-164/+157
| | | | llvm-svn: 322824
* [clangd] Use fuzzy match to select top N index results.Sam McCall2018-01-181-6/+11
| | | | | | | | | | | | | | | | | | | | | Summary: This makes performance slower but more predictable (it always processes every symbol). We need to find ways to make this fast, possibly by precomputing short queries or capping the number of scored results. But our current approach is too naive. It also no longer returns results in a "good" order. In fact it's pathological: the top N results are ranked from worst to best. Indexes aren't responsible for ranking and MergedIndex can't do a good job, so I'm pleased that this will make any hidden assumptions we have more noticeable :-) Reviewers: hokein Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D42060 llvm-svn: 322821
* [clangd] Avoid combinatorial explosion in CodeCompleteTests.Sam McCall2018-01-161-20/+20
| | | | | | | | | | | | | | | | | Summary: This test dominates our unit test runtime, and the change speeds it up by 10x. We lose coverage of some combinations of flags, but I'm not sure that's finding many bugs. 3300 -> 300ms on my machine (3800 -> 800ms for the whole of CompletionTest). Reviewers: ilya-biryukov Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42063 llvm-svn: 322547
* [clangd] Merge results from static/dynamic index.Sam McCall2018-01-152-4/+42
| | | | | | | | | | | | | | | | Summary: We now hide the static/dynamic split from the code completion, behind a new implementation of the SymbolIndex interface. This will reduce the complexity of the sema/index merging that needs to be done by CodeComplete, at a fairly small cost in flexibility. Reviewers: hokein Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D42049 llvm-svn: 322480
* [clangd] Fix uninitialized-read found by asanSam McCall2018-01-131-0/+1
| | | | llvm-svn: 322443
* [clangd] Code completion uses Sema for NS-level things in the current file.Sam McCall2018-01-121-5/+41
| | | | | | | | | | | | | | | Summary: To stay fast, it avoids deserializing anything outside the current file, by disabling the LoadExternal code completion option added in r322377, when the index is enabled. Reviewers: hokein Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41996 llvm-svn: 322387
* [clangd] Include debugging tags for both static and dynamic index. NFCSam McCall2018-01-121-2/+2
| | | | llvm-svn: 322379
* [clangd] Incorporate fuzzy-match into result rankings.Sam McCall2018-01-121-16/+24
| | | | | | | | | | | | Summary: The scoring function is fuzzy-match-quality * existing quality score. Reviewers: ioeric Subscribers: klimek, cfe-commits, ilya-biryukov Differential Revision: https://reviews.llvm.org/D40780 llvm-svn: 322377
* [clangd] Don't navigate to forward class declaration when go to definition.Haojian Wu2018-01-121-0/+12
| | | | | | | | | | | | | | | | Summary: For some cases, GoToDefinition will navigate to the forward class declaration, we should always navigate to the class definition. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41661 llvm-svn: 322370
* [clangd] Pass Context to onDiagnosticsReady callbackIlya Biryukov2018-01-102-5/+7
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41907 llvm-svn: 322199
* [clangd] Add more filters for collected symbols.Eric Liu2018-01-102-12/+72
| | | | | | | | | | | | | | | | Summary: o We only collect symbols in namespace or translation unit scopes. o Add an option to only collect symbols in included headers. Reviewers: hokein, ilya-biryukov Reviewed By: hokein, ilya-biryukov Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41823 llvm-svn: 322193
* [clangd] Add static index for the global code completion.Haojian Wu2018-01-101-13/+18
| | | | | | | | | | | | | | | | | | | | Summary: Use the YAML-format symbols (generated by the global-symbol-builder tool) to do the global code completion. It is **experimental** only , but it allows us to experience global code completion on a relatively small project. Tested with LLVM project. Reviewers: sammccall, ioeric Reviewed By: sammccall, ioeric Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41668 llvm-svn: 322191
* [clangd] Remove duplicates from code completionIlya Biryukov2018-01-101-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch removes hidden items from code completion. Items can be hidden, e.g., by other items in the child scopes. This patch addresses a particular problem of a duplicate completion item for the class in the following example: struct Adapter { void method(); }; void Adapter::method() { Adapter^ } We should probably investigate if there are other duplicates in completion and remove them, possibly adding assertions that it never happens. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D41901 llvm-svn: 322185
* [clangd] Add more symbol information for code completion.Eric Liu2018-01-092-8/+72
| | | | | | | | | | | | Reviewers: hokein, sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41345 llvm-svn: 322097
* [clangd] Use ToolExecutor to write the global-symbol-builder tool.Eric Liu2018-01-091-1/+1
| | | | | | | | | | | | | | | Summary: This enables more execution modes like standalone and Mapreduce-style execution. See also D41729 Reviewers: hokein, sammccall Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41730 llvm-svn: 322084
* [clangd] Catch more symbols in SymbolCollector.Haojian Wu2018-01-091-2/+40
| | | | | | | | | | | | | | | | | | Summary: We currently only collect external-linkage symbols in the collector, which results in missing some typical symbols (like no-linkage type alias symbols). This patch relaxes the constraint a bit to allow collecting more symbols. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41759 llvm-svn: 322067
* [clangd] Properly set filterText for index-based completion itemsIlya Biryukov2017-12-291-4/+14
| | | | | | | It was previously set to an identifier that the user typed, leading to surprising behavior in VSCode (probably in other editors too). llvm-svn: 321554
* [clangd] Use Builder for symbol slabs, and use sorted-vector for storageSam McCall2017-12-234-38/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This improves a few things: - the insert -> freeze -> read sequence is now enforced/communicated by the type system - SymbolSlab::const_iterator iterates over symbols, not over id-symbol pairs - we avoid permanently storing a second copy of the IDs, and the string map's hashtable The slab size is now down to 21.8MB for the LLVM project. Of this only 2.7MB is strings, the rest is #symbols * `sizeof(Symbol)`. `sizeof(Symbol)` is currently 96, which seems too big - I think SymbolInfo isn't efficiently packed. That's a topic for another patch! Also added simple API to see the memory usage/#symbols of a slab, since it seems likely we will continue to care about this. Reviewers: ilya-biryukov Subscribers: klimek, mgrang, cfe-commits Differential Revision: https://reviews.llvm.org/D41506 llvm-svn: 321412
* [clangd] Index symbols share storage within a slab.Sam McCall2017-12-213-3/+5
| | | | | | | | | | | | | | | | | Summary: Symbols are not self-contained - it's only safe to hand them out if you guarantee the lifetime of the underlying data. Before this lands, I'm going to measure the before/after memory usage of the LLVM index loaded into memory in a single slab. Reviewers: hokein Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41483 llvm-svn: 321272
* [clangd] Pull CodeCompletionString handling logic into its own file and add ↵Eric Liu2017-12-203-1/+144
| | | | | | | | | | | | unit test. Reviewers: sammccall Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41450 llvm-svn: 321193
* [clangd] Remove an unused lambda capture.Eric Liu2017-12-201-1/+1
| | | | llvm-svn: 321192
* [clangd] Switch xrefs and documenthighlight to annotated-code unit tests. NFCSam McCall2017-12-206-37/+395
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The goal here is again to make it easier to read and write the tests. I've extracted `parseTextMarker` from CodeCompleteTests into an `Annotations` class, adding features to it: - as well as points `^s` it allows ranges `[[...]]` - multiple points and ranges are supported - points and ranges may be named: `$name^` and `$name[[...]]` These features are used for the xrefs tests. This also paves the way for replacing the lit diagnostics.test with more readable unit tests, using named ranges. Alternative considered: `TestSelectionRange` in clang-refactor/TestSupport Main problems were: - delimiting the end of ranges is awkward, requiring counting - comment syntax is long and at least as cryptic for most cases - no separate syntax for point vs range, which keeps xrefs tests concise - Still need to convert to Position everywhere - Still need helpers for common case of expecting exactly one point/range (I'll probably promote the extra `PrintTo`s from some of the core Protocol types into `operator<<` in `Protocol.h` itself in a separate, prior patch...) Reviewers: ioeric Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41432 llvm-svn: 321184
* [clangd] Add debug printers for basic protocol types. NFCSam McCall2017-12-201-4/+0
| | | | llvm-svn: 321161
* [clangd] Igore cases in index fuzzy find.Eric Liu2017-12-201-0/+10
| | | | llvm-svn: 321157
* [clangd] Build dynamic index and use it for code completion.Eric Liu2017-12-191-0/+32
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41289 llvm-svn: 321092
* [clangd] Fix warnings/compiler pickiness after r321083Sam McCall2017-12-191-1/+1
| | | | llvm-svn: 321086
* [clangd] Index-based code completion.Eric Liu2017-12-192-5/+105
| | | | | | | | | | | | | | Summary: Use symbol index to populate completion results for qualfified IDs e.g. "nx::A^". Reviewers: ilya-biryukov, sammccall Reviewed By: ilya-biryukov, sammccall Subscribers: rwols, klimek, mgorny, cfe-commits, sammccall Differential Revision: https://reviews.llvm.org/D41281 llvm-svn: 321083
* [clangd] Expose offset <-> LSP position functions, and fix bugsSam McCall2017-12-193-0/+78
| | | | | | | | | | | | | | | | | | | | | | | Summary: - Moved these functions to SourceCode.h - added unit tests - fix off by one in positionToOffset: Offset - 1 in final calculation was wrong - fixed formatOnType which had an equal and opposite off-by-one - positionToOffset and offsetToPosition both consistently clamp to beginning/end of file when input is out of range - gave variables more descriptive names - removed windows line ending fixmes where there is nothing to fix - elaborated on UTF-8 fixmes This will conflict with Eric's D41281, but in a pretty easy-to-resolve way. Reviewers: ioeric Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41351 llvm-svn: 321073
* [clangd] Support filtering by fixing scopes in fuzzyFind.Eric Liu2017-12-193-25/+102
| | | | | | | | | | | | | | Summary: When scopes are specified, only match symbols from scopes. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41367 llvm-svn: 321067
* [clangd] Add unit tests for signature help. SigHelp/CodeComplete lit tests ↵Sam McCall2017-12-191-1/+89
| | | | | | are smoke only. llvm-svn: 321065
* [clangd] Build in-memory index on symbols in files.Eric Liu2017-12-153-92/+194
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41276 llvm-svn: 320807
* [clangd] Implemented tracing using ContextIlya Biryukov2017-12-141-3/+5
| | | | | | | | | | | | Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: klimek, luckygeck, cfe-commits Differential Revision: https://reviews.llvm.org/D40488 llvm-svn: 320706
* [clangd] Add a FileSymbols container that manages symbols from multiple files.Eric Liu2017-12-142-0/+92
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41232 llvm-svn: 320701
* [clangd] Fix a potential use-after-move bug.Eric Liu2017-12-141-1/+2
| | | | llvm-svn: 320695
* [clangd] Construct SymbolSlab from YAML format.Haojian Wu2017-12-141-0/+45
| | | | | | | | | | | | | | Summary: This will be used together with D40548 for the global index source (experimental). Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits, ioeric Differential Revision: https://reviews.llvm.org/D41178 llvm-svn: 320694
* [clangd] Symbol index interfaces and an in-memory index implementation.Eric Liu2017-12-142-0/+115
| | | | | | | | | | | | | | | | | | | | Summary: o Index interfaces to support using different index sources (e.g. AST index, global index) for code completion, cross-reference finding etc. This patch focuses on code completion. The following changes in the original patch has been split out. o Implement an AST-based index. o Add an option to replace sema code completion for qualified-id with index-based completion. o Implement an initial naive code completion index which matches symbols that have the query string as substring. Reviewers: malaperle, sammccall Reviewed By: sammccall Subscribers: hokein, klimek, malaperle, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D40548 llvm-svn: 320688
* [clangd] Fix the unitttest build error on buildbot.Haojian Wu2017-12-141-0/+1
| | | | llvm-svn: 320678
* [clangd] clang-format the source code. NFCIlya Biryukov2017-12-132-5/+5
| | | | llvm-svn: 320577
* [clangd] Implemented logging using ContextIlya Biryukov2017-12-132-69/+72
| | | | | | | | | | | | Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40486 llvm-svn: 320576
* [clangd] Introduce a "Symbol" class.Haojian Wu2017-12-122-0/+111
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: * The "Symbol" class represents a C++ symbol in the codebase, containing all the information of a C++ symbol needed by clangd. clangd will use it in clangd's AST/dynamic index and global/static index (code completion and code navigation). * The SymbolCollector (another IndexAction) will be used to recollect the symbols when the source file is changed (for ASTIndex), or to generate all C++ symbols for the whole project. In the long term (when index-while-building is ready), clangd should share a same "Symbol" structure and IndexAction with index-while-building, but for now we want to have some stuff working in clangd. Reviewers: ioeric, sammccall, ilya-biryukov, malaperle Reviewed By: sammccall Subscribers: malaperle, klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D40897 llvm-svn: 320486
* [clangd] clang-format the code. NFCIlya Biryukov2017-12-121-2/+3
| | | | llvm-svn: 320476
* [clangd] Introduced a Context that stores implicit dataIlya Biryukov2017-12-122-0/+58
| | | | | | | | | | | | | | | | Summary: It will be used to pass around things like Logger and Tracer throughout clangd classes. Reviewers: sammccall, ioeric, hokein, bkramer Reviewed By: sammccall Subscribers: klimek, bkramer, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D40485 llvm-svn: 320468
* [clangd] Convert lit code completion tests to unit-tests. NFCSam McCall2017-12-082-66/+278
| | | | | | | | | | | | Summary: This improves readability of tests and error messages. Reviewers: ioeric Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D40952 llvm-svn: 320148
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 llvm-svn: 319840
OpenPOWER on IntegriCloud