summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Make in-memory CDB always available as an overlay, refactor.Sam McCall2018-11-025-96/+63
| | | | | | | | | | | | | | | | | | | | | | | Summary: The new implementation is a GlobalCompilationDatabase that overlays a base. Normally this is the directory-based CDB. To preserve the behavior of compile_args_from=LSP, the base may be null. The OverlayCDB is always present, and so the extensions to populate it are always supported. It also allows overriding the flags of the fallback command. This is just unit-tested for now, but the plan is to expose this as an extension on the initialize message. This addresses use cases like https://github.com/thomasjo/atom-ide-cpp/issues/16 Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53687 llvm-svn: 345970
* [clangd] Remove didOpen extraFlags extension.Sam McCall2018-11-026-79/+2
| | | | | | | | | | | | | | | | | | | | Summary: This was added in D34947 to support YCM, but YCM actually provides *all* args, and this was never actually used. Meanwhile, we grew another extension that allows specifying all args. I did find one user of this extension: https://github.com/thomasjo/atom-ide-cpp. I'll reach out, there are multiple good alternatives: - compile_commands.txt can serve the same purpose as .clang_complete there - we can add an extension to support setting the fallback command Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53641 llvm-svn: 345969
* [clangd] Only log ignored diagnostics with -log=verbose.Sam McCall2018-11-021-1/+2
| | | | | | | | | | Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53648 llvm-svn: 345968
* [clangd] Really fix clang -Wimplicit-fallthroughFangrui Song2018-11-021-1/+4
| | | | | | | | The intention was to fall through to Function case in LLVM_ENABLE_ASSERTIONS=Off builds. Use #ifndef NDEBUG to fix -Wimplicit-fallthrough llvm-svn: 345953
* [clangd] Fix clang -Wimplicit-fallthroughFangrui Song2018-11-021-1/+1
| | | | llvm-svn: 345952
* Delete dependency on config.hKadir Cetinkaya2018-10-311-3/+2
| | | | | | | | | | | | | | | | Summary: Since llvm/Config/config.h is not available on standalone builds, use __USE_POSIX instead of HAVE_PTHREAD_H and get rid of the include. Reviewers: sammccall Reviewed By: sammccall Subscribers: lebedev.ri, krytarowski, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D53935 llvm-svn: 345729
* [clangd] fix non linux buildDavid Carlier2018-10-311-1/+1
| | | | | | | | | | | | There is no SCHED_IDLE semantic equivalent in BSD systems. Reviewers: kadircet, sammccall Revieweed By: sammccall Differential Revision: https://reviews.llvm.org/D53922 llvm-svn: 345700
* [clangd] Use thread pool for background indexing.Kadir Cetinkaya2018-10-304-7/+44
| | | | | | | | | | | | Reviewers: sammccall, ioeric Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D53651 llvm-svn: 345590
* [clangd] workspace/symbol should be async, it reads from the index.Sam McCall2018-10-253-2/+18
| | | | | | | | | | | | | | Summary: To enable this, TUScheduler has to provide a way to run async tasks without needing a preamble or AST! Reviewers: ilya-biryukov Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53644 llvm-svn: 345268
* [clangd] Clean up LSP structs around configuration. NFC, no protocol changes.Sam McCall2018-10-254-49/+45
| | | | | | | | | - align struct names/comments with LSP, remove redundant "clangd" prefixes. - don't map config structs as Optional<> when their presence/absence doesn't signal anything and all fields must have sensible "absent" values - be more lax around parsing of 'any'-typed messages llvm-svn: 345235
* [clangd] Remove unused CDB function. NFCSam McCall2018-10-252-9/+0
| | | | llvm-svn: 345233
* [clangd] Fix -compile-commands-dir flag, broken in r345031Sam McCall2018-10-252-2/+4
| | | | llvm-svn: 345232
* [clangd] Don't invalidate LSP-set compile commands when closing a file.Sam McCall2018-10-254-18/+0
| | | | | | | | | | | | | | | | Summary: It doesn't make much sense: setting them is not coupled to opening the file, it's an asynchronous notification. I don't think this is a breaking change - this behavior is hard to observe! Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53642 llvm-svn: 345231
* Fix MSVC "truncation from 'double' to 'float'" warnings. NFCI.Simon Pilgrim2018-10-241-3/+3
| | | | llvm-svn: 345184
* [clangd] Do not query index for new name completions.Kadir Cetinkaya2018-10-242-5/+7
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53192 llvm-svn: 345153
* [clangd] When replying, log the method name and latency.Sam McCall2018-10-242-25/+18
| | | | | | | | | | | | | | Summary: This information is strictly available in the log (you can find the original call) but it makes the log easier to follow in practice. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53647 llvm-svn: 345150
* [clangd] Ensure that we reply to each call exactly once. NFC (I think!)Sam McCall2018-10-242-31/+77
| | | | | | | | | | | | | | | | | | Summary: In debug builds, getting this wrong will trigger asserts. In production builds, it will send an error reply if none was sent, and drop redundant replies. (And log). No tests because this is always a programming error. (We did have some cases of this, but I fixed them with the new dispatcher). Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53399 llvm-svn: 345144
* [clangd] Don't show base class versions of members as completions.Sam McCall2018-10-241-3/+3
| | | | | | | | | | | | | | Summary: These are available via qualifiers, but signal to noise level is low. Keep required quailifier machinery around though, for cross-ns completion. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53571 llvm-svn: 345141
* [clangd] Downrank members from base classEric Liu2018-10-242-1/+6
| | | | | | | | | | | | Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53638 llvm-svn: 345140
* [clangd] Hide position line and column fields.Haojian Wu2018-10-241-2/+1
| | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53577 llvm-svn: 345134
* [clangd] Simplify auto hoverIlya Biryukov2018-10-241-27/+9
| | | | | | | | | | | | | | | | Summary: Use helper from clang. Also fixes some weird corner cases, e.g. auto (*foo)() = bar; Reviewers: kadircet, hokein Reviewed By: kadircet, hokein Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53347 llvm-svn: 345128
* [clangd] Remove outdated comment-out code. NFCIlya Biryukov2018-10-241-1/+0
| | | | llvm-svn: 345126
* [clangd] Embed fixes as CodeAction, instead of clangd_fixes. Clean up ↵Sam McCall2018-10-245-49/+52
| | | | | | | | | | | | | | | | | | | serialization. Summary: CodeAction provides us with a standard way of representing fixes inline, so use it, replacing our existing ad-hoc extension. After this, it's easy to serialize diagnostics using the structured toJSON/Protocol.h mechanism rather than assembling JSON ad-hoc. Reviewers: hokein, arphaman Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53391 llvm-svn: 345119
* [clangd] Truncate SymbolID to 16 bytes.Sam McCall2018-10-243-7/+13
| | | | | | | | | | | | | | | Summary: The goal is 8 bytes, which has a nonzero risk of collisions with huge indexes. This patch should shake out any issues with truncation at all, we can lower further later. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53587 llvm-svn: 345113
* [clangd] Lazily create CDB, remove setCompileCommandsDir.Sam McCall2018-10-232-39/+19
| | | | | | | | | | | | | | Summary: The only way to actually set the directory is at initialize time, so now CDB is lazy we can pass it to the constructor. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53572 llvm-svn: 345031
* [clangd] Remove caching of compilation database commands.Sam McCall2018-10-234-78/+4
| | | | | | | | | | | | | | | | | Summary: The CDB implementations used in open-source code are fast, and our private slow CDB will soon do the relevant caching itself. Simplifying the GlobalCDB layer in clangd is important to get auto-index implemented at the right layer. Reviewers: ioeric, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53439 llvm-svn: 345024
* [clangd] Support passing a relative path to -compile-commands-dirSam McCall2018-10-231-10/+18
| | | | | | | | | | | | | | | | | | Summary: This is useful when using clangd with CMake based projects in Visual Studio Code since when using CMake the `compile_commands.json` file is usually located in a `build` subdirectory which isn't a parent directory of the source files. Allowing passing relative paths to -compile-commands-dir allows specifying `clangd.arguments = ["-compile-commands-dir=build"]` in VSCode's settings file and having it work for each CMake based project that uses the `build` subdirectory as the build directory (instead of having to specify the absolute path to the compile commands directory for each separate project in VSCode's settings). Patch by Daan De Meyer! Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D53481 llvm-svn: 345022
* Fix range length comparison in DraftStore::UpdateDraft when Unicode ↵Sam McCall2018-10-233-7/+19
| | | | | | | | | | | | | | | | | | | | | | | characters are removed from the document Summary: See http://lists.llvm.org/pipermail/clangd-dev/2018-October/000171.html for context. I kept the error (instead of downgrading to a log message) since the range lengths differing does indicate either a bug in the client or server range calculation or the buffers being out of sync (which both seems serious enough to me to be an error). If any existing clients aside from VSCode break they should only break when accidentally typing a Unicode character which should only be a minor nuisance for a little while until the bug is fixed in the respective client. Patch by Daan De Meyer! Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, kadircet, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D53527 llvm-svn: 345020
* [clangd] Support URISchemes configuration in BackgroundIndex.Eric Liu2018-10-222-4/+9
| | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53503 llvm-svn: 344912
* [clangd] Fix unqualified make_unique after r344850. NFCSam McCall2018-10-201-2/+2
| | | | llvm-svn: 344858
* [clangd] Namespace style cleanup in cpp files. NFC.Sam McCall2018-10-2044-891/+845
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Standardize on the most common namespace setup in our *.cpp files: using namespace llvm; namespace clang { namespace clangd { void foo(StringRef) { ... } And remove redundant llvm:: qualifiers. (Except for cases like make_unique where this causes problems with std:: and ADL). This choice is pretty arbitrary, but some broad consistency is nice. This is going to conflict with everything. Sorry :-/ Squash the other configurations: A) using namespace llvm; using namespace clang; using namespace clangd; void clangd::foo(StringRef); This is in some of the older files. (It prevents accidentally defining a new function instead of one in the header file, for what that's worth). B) namespace clang { namespace clangd { void foo(llvm::StringRef) { ... } This is fine, but in practice the using directive often gets added over time. C) namespace clang { namespace clangd { using namespace llvm; // inside the namespace This was pretty common, but is a bit misleading: name lookup preferrs clang::clangd::foo > clang::foo > llvm:: foo (no matter where the using directive is). llvm-svn: 344850
* Fix MSVC "truncation from 'double' to 'float'" warning. NFCI.Simon Pilgrim2018-10-201-1/+1
| | | | llvm-svn: 344845
* Fix MSVC "not all control paths return a value" warning. NFCI.Simon Pilgrim2018-10-201-0/+1
| | | | llvm-svn: 344844
* [clangd] Set workspace root when initializing ClangdServer, disallow mutation.Sam McCall2018-10-193-23/+12
| | | | | | | | | | | | | | | | | | Summary: Rename instance variable to WorkspaceRoot to match what we call it internally. Add fixme to set it automatically. Don't do it yet, clients have assumptions that the constructor won't access the FS. Don't second-guess the provided root. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53404 llvm-svn: 344787
* [clangd] Remove the overflow log.Haojian Wu2018-10-193-2/+10
| | | | | | | | | | | | | | Summary: LLVM codebase has generated files (all are build/Target/XXX/*.inc) that exceed the MaxLine & MaxColumn. Printing these log would be noisy. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53400 llvm-svn: 344777
* [clangd] Fix msan failure after r344735 by initializing bitfieldsKrasimir Georgiev2018-10-191-0/+1
| | | | | | | | | That revision changed integer members to bitfields; the integers were default initialized before and the bitfields lost that default initialization. This started causing msan use-of-uninitialized memory in clangd tests. llvm-svn: 344773
* [clangd] Clear the semantic of RefSlab::size.Haojian Wu2018-10-185-12/+19
| | | | | | | | | | | | | | | | | Summary: The RefSlab::size can easily cause confusions, it returns the number of different symbols, rahter than the number of all references. - add numRefs() method and cache it, since calculating it everytime is nontrivial. - clear misused places. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53389 llvm-svn: 344745
* [clangd] Enforce rules around "initialize" request, and create ClangdServer ↵Sam McCall2018-10-184-15/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lazily. Summary: LSP is a slightly awkward map to C++ object lifetimes: the initialize request is part of the protocol and provides information that doesn't change over the lifetime of the server. Until now, we handled this by initializing ClangdServer and ClangdLSPServer right away, and making anything that can be set in the "initialize" request mutable. With this patch, we create ClangdLSPServer immediately, but defer creating ClangdServer until "initialize". This opens the door to passing the relevant initialize params in the constructor and storing them immutably. (That change isn't actually done in this patch). To make this safe, we have the MessageDispatcher enforce that the "initialize" method is called before any other (as required by LSP). That way each method handler can assume Server is initialized, as today. As usual, while implementing this I found places where our test cases violated the protocol. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53398 llvm-svn: 344741
* [clangd] Lay JSONRPCDispatcher to rest.Sam McCall2018-10-189-654/+407
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Most of its functionality is moved into ClangdLSPServer. The decoupling between JSONRPCDispatcher, ProtocolCallbacks, ClangdLSPServer was never real, and only served to obfuscate. Some previous implicit/magic stuff is now explicit: - the return type of LSP method calls are now in the signature - no more reply() that gets the ID using global context magic - arg tracing no longer relies on RequestArgs::stash context magic either This is mostly refactoring, but some deliberate fixes while here: - LSP method params are now by const reference - notifications and calls are now distinct namespaces. (some tests had protocol errors and needed updating) - we now reply to calls we failed to decode - outgoing calls use distinct IDs A few error codes and message IDs changed in unimportant ways (see tests). Reviewers: ioeric Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53387 llvm-svn: 344737
* [clangd] Names that are not spelled in source code are reserved.Eric Liu2018-10-186-15/+40
| | | | | | | | | | | | | | | | | | | | | | | | Summary: These are often not expected to be used directly e.g. ``` TEST_F(Fixture, X) { ^ // "Fixture_X_Test" expanded in the macro should be down ranked. } ``` Only doing this for sema for now, as such symbols are mostly coming from sema e.g. gtest macros expanded in the main file. We could also add a similar field for the index symbol. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53374 llvm-svn: 344736
* [clangd] Encode Line/Column as a 32-bits integer.Haojian Wu2018-10-187-24/+88
| | | | | | | | | | | | | | | | | | | | | | Summary: This would buy us more memory. Using a 32-bits integer is enough for most human-readable source code (up to 4M lines and 4K columns). Previsouly, we used 8 bytes for a position, now 4 bytes, it would save us 8 bytes for each Ref and each Symbol instance. For LLVM-project binary index file, we save ~13% memory. | Before | After | | 412MB | 355MB | Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53363 llvm-svn: 344735
* Fix warning about unused variable [NFC]Mikael Holmen2018-10-181-1/+1
| | | | llvm-svn: 344724
* [clangd] Support scope proximity in code completion.Eric Liu2018-10-177-29/+148
| | | | | | | | | | | | | | | | Summary: This should make all-scope completion more usable. Scope proximity for indexes will be added in followup patch. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53131 llvm-svn: 344688
* [clangd] Fix buildbot failure.Haojian Wu2018-10-171-3/+5
| | | | llvm-svn: 344680
* [clangd] Print numbers of symbols and refs as well when loading theHaojian Wu2018-10-171-2/+7
| | | | | | index. llvm-svn: 344679
* [clangd] Collect refs from headers.Haojian Wu2018-10-174-17/+42
| | | | | | | | | | | | | | | | | Summary: Add a flag to SymbolCollector to collect refs fdrom headers. Note that we collect refs from headers in static index, and we don't do it for dynamic index because of the preamble (we skip function body in preamble, collecting it will result incomplete results). Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53322 llvm-svn: 344678
* [clangd] Hide unused function. NFCSam McCall2018-10-172-9/+2
| | | | llvm-svn: 344676
* [clangd] Rename and move trivial logger to Logger.cpp. NFCSam McCall2018-10-176-33/+33
| | | | llvm-svn: 344675
* [clangd] Simplify client capabilities parsing.Sam McCall2018-10-173-192/+76
| | | | | | | | | | | | | | | | | | Summary: Instead of parsing into structs that mirror LSP, simply parse into a flat struct that contains the info we need. This is an exception to our strategy with Protocol.h, which seems justified: - the structure here is very large and deeply nested - we care about almost none of it - we should never have to serialize client capabilities Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53266 llvm-svn: 344673
* [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction. ↵Sam McCall2018-10-1711-341/+520
| | | | | | | | | | | | | | | | | | | | | | | | | | | (re-land r344620) 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: 344672
OpenPOWER on IntegriCloud