summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "[clangd] Refactor JSON-over-stdin/stdout code into Transport ↵Krasimir Georgiev2018-10-1611-521/+341
| | | | | | | | | abstraction." This reverts commit r344620. Breaks upstream bots. llvm-svn: 344637
* [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.Sam McCall2018-10-1611-341/+521
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This paves the way for alternative transports (mac XPC, maybe messagepack?), and also generally improves layering: testing ClangdLSPServer becomes less of a pipe dream, we split up the JSONOutput monolith, etc. This isn't a final state, much of what remains in JSONRPCDispatcher can go away, handlers can call reply() on the transport directly, JSONOutput can be renamed to StreamLogger and removed, etc. But this patch is sprawling already. The main observable change (see tests) is that hitting EOF on input is now an error: the client should send the 'exit' notification. This is defensible: the protocol doesn't spell this case out. Reproducing the current behavior for all combinations of shutdown/exit/EOF clutters interfaces. We can iterate on this if desired. Reviewers: jkorous, ioeric, hokein Subscribers: mgorny, ilya-biryukov, MaskRay, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53286 llvm-svn: 344620
* [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8)Sam McCall2018-10-164-15/+103
| | | | | | | | | | | | | | Summary: I don't bother mirroring the full capabilities struct, just parse the bits we care about. I'll send a new patch to use this approach elsewhere too. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53213 llvm-svn: 344617
* Remove possibility to change compile database path at runtimeSimon Marchi2018-10-163-17/+32
| | | | | | | | | | | | | | Summary: This patch removes the possibility to change the compilation database path at runtime using the didChangeConfiguration request. Instead, it is suggested to use the setting on the initialize request, and clangd whenever the user wants to use a different build configuration. Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53220 llvm-svn: 344614
* [clangd] Allow disble down traversals from root.Eric Liu2018-10-162-7/+18
| | | | | | | | | | | | | | Summary: This is useful for symbo scope proximity, where down traversals from the global scope if not desired. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53317 llvm-svn: 344604
* [clangd] Fix threading bugs in (not-yet-used) BackgroundIndex, re-enable test.Sam McCall2018-10-162-3/+6
| | | | | | | | | | | | | | | | | | | Summary: One relatively boring bug: forgot to notify the CV after enqueue. One much more fun bug: the thread member could access instance variables before they were initialized. Although the thread was last in the init list, QueueCV etc were listed after Thread in the class, so their default constructors raced with the thread itself. We have to get very unlucky to lose this race, I saw it 0.02% of the time. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D53313 llvm-svn: 344595
* [clangd] Optionally use dex for the preamble parts of the dynamic index.Sam McCall2018-10-167-22/+52
| | | | | | | | | | | | | | | Summary: Reuse the old -use-dex-index experiment flag for this. To avoid breaking the tests, make Dex deduplicate symbols, addressing an old FIXME. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53288 llvm-svn: 344594
* [clangd] Revert include path change in Dexp. NFCSam McCall2018-10-152-4/+2
| | | | llvm-svn: 344533
* [clangd] Add createIndex in dexpHaojian Wu2018-10-151-7/+9
| | | | | | | | | | | | | | | Summary: This would allow easily injecting our internal customization. Also updates the stale "symbol-collection-file" flag. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53292 llvm-svn: 344521
* [clangd] Use SyncAPI in more places in tests. NFCSam McCall2018-10-151-0/+3
| | | | llvm-svn: 344520
* [clangd] Minimal implementation of automatic static index (not enabled).Sam McCall2018-10-153-0/+271
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: See tinyurl.com/clangd-automatic-index for design and goals. Lots of limitations to keep this patch smallish, TODOs everywhere: - no serialization to disk - no changes to dynamic index, which now has a much simpler job - no partitioning of symbols by file to avoid duplication of header symbols - no reindexing of edited files - only a single worker thread - compilation database is slurped synchronously (doesn't scale) - uses memindex, rebuilds after every file (should be dex, periodically) It's not hooked up to ClangdServer/ClangdLSPServer yet: the layering isn't clear (it should really be in ClangdServer, but ClangdLSPServer has all the CDB interactions). Reviewers: ioeric Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D53032 llvm-svn: 344513
* [clangd] Remove an unused include header, NFC.Haojian Wu2018-10-151-1/+0
| | | | llvm-svn: 344510
* [clangd] dump xrefs information in dexp tool.Haojian Wu2018-10-152-9/+93
| | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53019 llvm-svn: 344508
* [clangd] Fix some references missing in dynamic index.Haojian Wu2018-10-151-17/+19
| | | | | | | | | | | | | | | | | | | Summary: Previously, SymbolCollector postfilters all references at the end to find all references of interesting symbols. It was incorrect when indxing main AST where we don't see locations of symbol declarations and definitions in the main AST (as those are in preamble AST). The fix is to do earily check during collecting references. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53273 llvm-svn: 344507
* Move some helpers from the global namespace into anonymous ones.Benjamin Kramer2018-10-131-1/+2
| | | | llvm-svn: 344468
* [clangd] NFC fix semicolon warningJonas Toth2018-10-121-1/+1
| | | | llvm-svn: 344384
* [clangd] Return Command objects from onCodeAction, rather than ad-hoc JSON. NFCSam McCall2018-10-122-9/+9
| | | | llvm-svn: 344363
* [clangd] Support hover on "aut^o *".Haojian Wu2018-10-121-10/+14
| | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53186 llvm-svn: 344330
* [clangd] Remove no-op crash handler, we never set a crash context.Sam McCall2018-10-111-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: I think this was just copied from somewhere with the belief that it actually did some crash handling. Of course the question arises: *should* we set one? I don't think so: - clangd used to crash a lot, now it's pretty stable, because we found and fixed the crashes. I think the long-term effects of crashing hard are good. - the implementation can't do any magic, it just uses longjmp to return without running any destructors by default. This is unsafe in general (e.g. mutexes won't unlock) and will certainly end up leaking memory. Whatever UB caused the crash may still stomp all over global state, etc. I think there's an argument for isolating the background indexer (autoindex) because it's not directly under the user's control, the crash surface is larger, and it doesn't particularly need to interact with the rest of clangd. But there, fork() and communicate through the FS is safer. Reviewers: ioeric, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53034 llvm-svn: 344245
* Fix the qualification of `IntrusiveRefCntPtr` to use `llvm::`.Chandler Carruth2018-10-111-2/+4
| | | | | | | | Without this, the code only compiled if the header was included after something introduced the alias from `clang::` to `llvm::` for this type. Any modules build would fail here. llvm-svn: 344225
* Lift VFS from clang to llvm (NFC)Jonas Devlieghere2018-10-1010-44/+48
| | | | | | | | | | | | | | | | | | | This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 llvm-svn: 344140
* [clangd] Make FSProvider const-correct. NFCSam McCall2018-10-103-7/+8
| | | | llvm-svn: 344118
* [clangd] Fix an accident change in r342999.Haojian Wu2018-10-091-1/+1
| | | | llvm-svn: 344054
* [clangd] fix miscompiling lower_bound callJonas Toth2018-10-091-2/+3
| | | | llvm-svn: 344044
* [clangd] Mark colon as a safe character when percent-encoding.Kadir Cetinkaya2018-10-091-1/+3
| | | | | | | | | | | | | | Summary: Also change output of percent-encoding to use upper-case letters. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53016 llvm-svn: 344033
* [clangd] Revert back to previous heuristic for diagnostic range extraction.Kadir Cetinkaya2018-10-091-6/+2
| | | | | | | | | | | | | | Summary: Also add a few new test cases and a special case into handling of empty fixit ranges that collides with location of a diag. Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D52889 llvm-svn: 344025
* [clangd] Avoid cache main file status in preamble.Eric Liu2018-10-093-5/+23
| | | | | | | | | | | | Summary: Main file can certainly change when reusing preamble. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52991 llvm-svn: 344024
* [clangd] Update the out-of-date yaml-symbol-file flag in clangd.Haojian Wu2018-10-081-6/+6
| | | | | | | | | | | | | | Summary: The flag is stale due to the recent changes of clangd indexer, this patch renames the flag to "index-file". Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52976 llvm-svn: 343963
* [clangd] Migrate to LLVM STLExtras range APIFangrui Song2018-10-072-7/+6
| | | | llvm-svn: 343946
* [clangd] NFC: Migrate to LLVM STLExtras API where possibleKirill Bobyrev2018-10-0712-62/+48
| | | | | | | | | | | | | | This patch improves readability by migrating `std::function(ForwardIt start, ForwardIt end, ...)` to LLVM's STLExtras range-based equivalent `llvm::function(RangeT &&Range, ...)`. Similar change in Clang: D52576. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D52650 llvm-svn: 343937
* [clangd] Remove unused headers from CodeComplete.cppFangrui Song2018-10-061-3/+0
| | | | | | | queue is not used after index-provided completions' merge with those from Sema USRGeneration.h is not used after introduction of getSymbolID llvm-svn: 343912
* [clangd] Remove last usage of ast matchers from SymbolCollector. NFCSam McCall2018-10-051-4/+2
| | | | llvm-svn: 343849
* [clangd] Fix a subtle case for GetBeginningOfIdentifier.Sam McCall2018-10-051-4/+4
| | | | | | | | | | Calling getMacroArgExpansionLocation too early was causing Lexer::getRawToken to do the wrong thing - lexing the macro name instead of the arg contents. Differential Revision: https://reviews.llvm.org/D52928 llvm-svn: 343844
* [clangd] Make binary index format the default, remove dead flag.Sam McCall2018-10-051-23/+4
| | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52872 llvm-svn: 343841
* [clangd] Simplify Dex query tree logic and fix missing-posting-list bugSam McCall2018-10-044-43/+28
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The bug being fixed: when a posting list doesn't exist in the index, it was previously just dropped from the query rather than being treated as empty. Now that we have the FALSE iterator, we can use it instead. The query tree logic previously had a bunch of special cases to detect whether subtrees are empty. Now we just naively build the whole tree, and rely on the query optimizations to drop the trivial parts. Finally, there was a bug in trigram generation: the empty query would generate a single trigram "$$$" instead of no trigrams. This had no effect (there was no posting list, so the other bug cancelled it out). But we now have to fix this bug too. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52796 llvm-svn: 343802
* [clangd] Dex: FALSE iterator, peephole optimizations, fix AND bugSam McCall2018-10-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The FALSE iterator will be used in a followup patch to fix a logic bug in Dex (currently, tokens that don't have posting lists in the index are simply dropped from the query, changing semantics). It can usually be optimized away, so added the following opmitizations: - simplify booleans inside AND/OR - replace effectively-empty AND/OR with booleans - flatten nested AND/ORs While working on this, found a bug in the AND iterator: its constructor sync() assumes that ReachedEnd is set if applicable, but the constructor never sets it. This crashes if a non-first iterator is nonempty. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52789 llvm-svn: 343801
* [clangd] expose MergedIndex classSam McCall2018-10-046-125/+115
| | | | | | | | | | | | | | Summary: This allows inheriting from it, so index() can ga away and allowing TestTU::index) to be fixed. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52250 llvm-svn: 343780
* [clangd] clangd-indexer gathers refs and stores them in index files.Sam McCall2018-10-046-18/+189
| | | | | | | | | | Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52531 llvm-svn: 343778
* [clangd] Remove one-segment-skipping from Dex trigrams.Sam McCall2018-10-042-5/+3
| | | | | | | | | | | | | | | Summary: Currently queries like "ab" can match identifiers like a_yellow_bee. The value of allowing this for exactly one segment but no more seems dubious. It costs ~3% of overall ram (~9% of posting list ram) and some quality. Reviewers: ilya-biryukov, ioeric Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52885 llvm-svn: 343777
* [cland] Dex: fix/simplify short-trigram generationSam McCall2018-10-043-88/+43
| | | | | | | | | | | | | | | | Summary: 1) Instead of x$$ for a short-query trigram, just use x 2) Make rules more coherent: prefixes of length 1-2, and first char + next head 3) Fix Dex::fuzzyFind to mark results as incomplete, because short-trigram rules only yield a subset of results. Reviewers: ioeric Subscribers: ilya-biryukov, jkorous, mgrang, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52808 llvm-svn: 343775
* [clangd] Dex: FALSE iterator, peephole optimizations, fix AND bugSam McCall2018-10-042-13/+108
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The FALSE iterator will be used in a followup patch to fix a logic bug in Dex (currently, tokens that don't have posting lists in the index are simply dropped from the query, changing semantics). It can usually be optimized away, so added the following opmitizations: - simplify booleans inside AND/OR - replace effectively-empty AND/OR with booleans - flatten nested AND/ORs While working on this, found a bug in the AND iterator: its constructor sync() assumes that ReachedEnd is set if applicable, but the constructor never sets it. This crashes if a non-first iterator is nonempty. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52789 llvm-svn: 343774
* [clangd] Revert accidental flag changeSam McCall2018-10-041-1/+1
| | | | llvm-svn: 343764
* [clangd] Use canonical declarations in ReferenceFinder.Haojian Wu2018-10-041-12/+14
| | | | | | | | | | | | | | | | | | Summary: handleDeclOccurrencce reports a canonical declartion, so stick to use canonical declarations to determine whether a declaration is in the target set. Also fix a previous ref test which misses a matched label (it fails without this patch). Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52871 llvm-svn: 343763
* [clangd] Support refs() in dex. Largely cloned from MemIndex.Sam McCall2018-10-044-19/+33
| | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52726 llvm-svn: 343760
* [clangd] clangd-indexer: Drop support for MR-via-YAMLSam McCall2018-10-043-136/+32
| | | | | | | | | | | | | | Summary: It's slow, and the open-source reduce implementation doesn't scale properly. While here, tidy up some dead headers and comments. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D52517 llvm-svn: 343759
* Fix compilation warning by removing unused variable [NFC]Mikael Holmen2018-10-031-1/+1
| | | | | | | | | | | clang complained with ../tools/clang/tools/extra/clangd/FS.cpp:19:12: error: unused variable 'Err' [-Werror,-Wunused-variable] if (auto Err = FS.makeAbsolute(PathStore)) ^ 1 error generated. llvm-svn: 343661
* Reland r343589 "[clangd] Dex: add Corpus factory for iterators, rename, fold ↵Sam McCall2018-10-025-88/+94
| | | | | | | | constant. NFC"" This reverts commit r343610. llvm-svn: 343622
* Revert r343589 "[clangd] Dex: add Corpus factory for iterators, rename, fold ↵Reid Kleckner2018-10-025-94/+88
| | | | | | | | | | | | | | constant. NFC" Declaring a field with the same name as a type causes GCC to error out: Dex.h:104:10: error: declaration of 'clang::clangd::dex::Corpus clang::clangd::dex::Dex::Corpus' [-fpermissive] Corpus Corpus; ^ Iterator.h:127:7: error: changes meaning of 'Corpus' from 'class clang::clangd::dex::Corpus' [-fpermissive] class Corpus { llvm-svn: 343610
* [clangd] Zap TODONEsSam McCall2018-10-021-3/+0
| | | | llvm-svn: 343590
* [clangd] Dex: add Corpus factory for iterators, rename, fold constant. NFCSam McCall2018-10-025-88/+94
| | | | | | | | | | | | | | | | | | | Summary: - Corpus avoids having to pass size to the true iterator, and (soon) any iterator that might optimize down to true. - Shorten names of factory functions now they're scoped to the Corpus. intersect() and unionOf() rather than createAnd() or createOr() as this seems to read better to me, and fits with other short names. Opinion wanted! - DEFAULT_BOOST_SCORE --> 1. This is a multiplier, don't obfuscate identity. - Simplify variadic templates in Iterator.h Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52711 llvm-svn: 343589
OpenPOWER on IntegriCloud