summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clangd
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Index main-file symbols (bug 39761)Sam McCall2019-01-143-30/+88
| | | | | | | | Patch by Nathan Ridge! Differential Revision: https://reviews.llvm.org/D55185 llvm-svn: 351041
* [clangd] Introduce loading of shards within auto-indexKadir Cetinkaya2019-01-101-1/+80
| | | | | | | | | | | | | | | | Summary: Whenever a change happens on a CDB, load shards associated with that CDB before issuing re-index actions. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55224 llvm-svn: 350847
* [clangd] Don't store completion info if the symbol is not used for code ↵Haojian Wu2019-01-101-4/+9
| | | | | | | | | | | | | | | | | | | | | completion. Summary: This would save us some memory and disk space: - Dex usage (261 MB vs 266 MB) - Disk (75 MB vs 76 MB) It would save more when we index the main file symbol D55185. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: nridge, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56314 llvm-svn: 350803
* [clangd] Add a test for SignatureHelp on dynamic index.Haojian Wu2019-01-091-0/+31
| | | | | | | | | | | | Summary: This would catch regressions caused by future changes of the index. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56483 llvm-svn: 350720
* [clangd] Fix a crash when reading an empty index file.Haojian Wu2019-01-081-0/+4
| | | | | | | | | | | | | | | Summary: Unfortunately, yaml::Input::setCurrentDocument() and yaml::Input::nextDocument() are internal APIs, the way we use them may cause a nullptr accessing when processing an empty YAML file. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56442 llvm-svn: 350633
* [clangd] Include <cstdio> instead of <stdio.h>. NFCIlya Biryukov2019-01-071-1/+1
| | | | | | This fixes the only clang-tidy check currently enabled by clangd. llvm-svn: 350540
* [clangd] Remove 'using namespace llvm' from .cpp files. NFCIlya Biryukov2019-01-0733-347/+343
| | | | | | | | The new guideline is to qualify with 'llvm::' explicitly both in '.h' and '.cpp' files. This simplifies moving the code between header and source files and is easier to keep consistent. llvm-svn: 350531
* [clangd] Fix a regression issue caused by r348365.Haojian Wu2019-01-071-4/+7
| | | | | | | | | | | | | | | | | | | | | Summary: With r348365, we now detect libc++ dir using the actual compiler path (from the compilation command), rather than the resource-dir. This new behavior will cause clangd couldn't find libc++ dir (even the libc++ is built from the source) when using a fallback compilation command (`clang xxx`) The fix is to use `<clangd_install_dir>/clang` as the actual compiler path. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56380 llvm-svn: 350515
* [clangd] Disable BackgroundIndexTest.PeriodicalIndexIlya Biryukov2019-01-071-1/+3
| | | | | | It sometimes fails on AArch64. llvm-svn: 350512
* [clangd] clang-format everything. NFCIlya Biryukov2019-01-0314-250/+208
| | | | llvm-svn: 350303
* [clangd] Cleanup syntax errors in the test, NFC.Haojian Wu2018-12-214-7/+7
| | | | llvm-svn: 349893
* [clangd] Try to workaround test failure by increasing the timeoutsIlya Biryukov2018-12-201-3/+3
| | | | | | | | Ideally we'd figure out a way to run this test without any sleeps, this workaround is only there to avoid annoying people with test failures around the holiday period when everyone is on vacation. llvm-svn: 349769
* [clangd] Don't miss the expected type in merge.Haojian Wu2018-12-201-0/+2
| | | | | | | | | | Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55918 llvm-svn: 349750
* [clangd] Fix a syntax error on the test.Haojian Wu2018-12-191-1/+1
| | | | llvm-svn: 349632
* [clangd] Try to fix buildbot failure after r349496Eric Liu2018-12-181-3/+3
| | | | | | | Increase timeout from 10ms to 100ms. See http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/27959 llvm-svn: 349502
* [clangd] BackgroundIndex rebuilds symbol index periodically.Eric Liu2018-12-181-0/+37
| | | | | | | | | | | | | | | | | | Summary: Currently, background index rebuilds symbol index on every indexed file, which can be inefficient. This patch makes it only rebuild symbol index periodically. As the rebuild no longer happens too often, we could also build more efficient dex index. Reviewers: ilya-biryukov, kadircet Reviewed By: kadircet Subscribers: dblaikie, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D55770 llvm-svn: 349496
* [clangd] Use buildCompilerInvocation to simplify the HeadersTests, NFC.Haojian Wu2018-12-141-10/+4
| | | | llvm-svn: 349148
* [clangd] Fix memory leak in ClangdTests.Haojian Wu2018-12-141-1/+3
| | | | | | | | | | | | | | | | | Summary: createInvocationFromCommandLine sets DisableFree to true by default, which leads memory leak in clangd. The fix is to use the `BuildCompilationInvocation` to create CI with the correct options (DisableFree is false). Fix https://bugs.llvm.org/show_bug.cgi?id=39991. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55702 llvm-svn: 349145
* [clangd] Fix an assertion failure in background index.Haojian Wu2018-12-141-0/+19
| | | | | | | | | | | | | | | Summary: When indexing a file which contains an uncompilable error, we will trigger an assertion failure -- the IndexFileIn data is not set, but we access them in the backgound index. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55650 llvm-svn: 349144
* [clangd] Refine the way of checking a declaration is referenced by the ↵Haojian Wu2018-12-131-0/+47
| | | | | | | | | | | | | | | | | written code. Summary: The previous solution (checking the AST) is not a reliable way to determine whether a declaration is explicitly referenced by the source code, we are still missing a few cases. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55191 llvm-svn: 349033
* [clangd] Avoid emitting Queued status when we are able to acquire the Barrier.Haojian Wu2018-12-131-2/+0
| | | | | | | | | | Reviewers: ilya-biryukov Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55359 llvm-svn: 349032
* Add explicit dependency on clangSerialization after rC348911Fangrui Song2018-12-121-0/+1
| | | | llvm-svn: 348916
* [clangd] Remove the test that sometimes deadlocksIlya Biryukov2018-12-061-23/+0
| | | | | | Will figure out how to properly rewrite it and recommit. llvm-svn: 348490
* [clangd] Update the test codeHaojian Wu2018-12-061-4/+0
| | | | | | I forgot to update it in the last round of code review. llvm-svn: 348478
* [clangd] C++ API for emitting file status.Haojian Wu2018-12-061-1/+79
| | | | | | Introduce clangd C++ API to emit the current status of file. llvm-svn: 348475
* [clangd] Fix a typo in TUSchedulerTestsHaojian Wu2018-12-061-1/+1
| | | | | | | | | | | | Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55312 llvm-svn: 348467
* [clangd] Dont provide locations for non-existent files.Kadir Cetinkaya2018-12-051-0/+12
| | | | | | | | | | | | | | Summary: We were getting assertion errors when we had bad file names, instead we should skip those. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55275 llvm-svn: 348359
* Fix compilation error when using clang 3.6.0Mikael Holmen2018-12-051-3/+3
| | | | llvm-svn: 348357
* [clangd] Partition include graph on auto-index.Kadir Cetinkaya2018-12-041-3/+59
| | | | | | | | | | | | | | Summary: Partitions include graphs in auto-index so that each shards contains only part of the include graph related to itself. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55062 llvm-svn: 348252
* [clangd] Populate include graph during static indexing action.Kadir Cetinkaya2018-11-302-0/+231
| | | | | | | | | | | | | | | Summary: This is the second part for introducing include hierarchy into index files produced by clangd. You can see the base patch that introduces structures and discusses the future of the patches in D54817 Reviewers: ilya-biryukov Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D54999 llvm-svn: 348005
* [clangd] Penalize destructor and overloaded operators in code completion.Eric Liu2018-11-301-8/+43
| | | | | | | | | | Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55061 llvm-svn: 347983
* [clangd] Drop injected class name when class scope is not explicitly specified.Eric Liu2018-11-301-0/+5
| | | | | | | | | | | | Summary: E.g. allow injected "A::A" in `using A::A^` but not in "A^". Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55065 llvm-svn: 347982
* [clangd] Canonicalize file path in URIForFile.Eric Liu2018-11-285-26/+57
| | | | | | | | | | | | | | | | | | | Summary: File paths in URIForFile can come from index or local AST. Path from index goes through URI transformation and the final path is resolved by URI scheme and could be potentially different from the original path. Hence, we should do the same transformation for all paths. We do this in URIForFile, which now converts a path to URI and back to a canonicalized path. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54845 llvm-svn: 347739
* [clangd] textDocument/SymbolInfo extensionJan Korous2018-11-272-0/+358
| | | | | | | | | | New method returning symbol info for given source position. Differential Revision: https://reviews.llvm.org/D54799 rdar://problem/46050281 llvm-svn: 347675
* [clangd] Put direct headers into srcs section.Kadir Cetinkaya2018-11-272-20/+30
| | | | | | | | | | | | | | | | | | | Summary: Currently, there's no way of knowing about header files using compilation database, since it doesn't contain header files as entries. Using this information, restoring from cache using compile commands becomes possible instead of doing directory traversal. Also, we can issue indexing actions for out-of-date headers even if source files depending on them haven't changed. Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D54817 llvm-svn: 347669
* [clangd] Prevent thread starvation in tests on loaded systems.Sam McCall2018-11-271-2/+7
| | | | | | | | | | | | | | Summary: Background index deliberately runs low-priority, but for tests this may stop them making progress. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D54938 llvm-svn: 347655
* [clangd] Do not drop diagnostics from macrosIlya Biryukov2018-11-261-1/+24
| | | | | | if they still end up being in the main file. llvm-svn: 347574
* [clangd] Enable auto-index behind a flag.Sam McCall2018-11-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Ownership and configuration: The auto-index (background index) is maintained by ClangdServer, like Dynamic. (This means ClangdServer will be able to enqueue preamble indexing in future). For now it's enabled by a simple boolean flag in ClangdServer::Options, but we probably want to eventually allow injecting the storage strategy. New 'sync' command: In order to meaningfully test the integration (not just unit-test components) we need a way for tests to ensure the asynchronous index reads/writes occur before a certain point. Because these tests and assertions are few, I think exposing an explicit "sync" command for use in tests is simpler than allowing threading to be completely disabled in the background index (as we do for TUScheduler). Bugs: I fixed a couple of trivial bugs I found while testing, but there's one I can't. JSONCompilationDatabase::getAllFiles() may return relative paths, and currently we trigger an assertion that assumes they are absolute. There's no efficient way to resolve them (you have to retrieve the corresponding command and then resolve against its directory property). In general I think this behavior is broken and we should fix it in JSONCompilationDatabase and require CompilationDatabase::getAllFiles() to be absolute. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D54894 llvm-svn: 347567
* [clangd] Initial implementation of expected typesIlya Biryukov2018-11-262-0/+158
| | | | | | | | | | | | | | | | | Summary: Provides facilities to model the C++ conversion rules without the AST. The introduced representation can be stored in the index and used to implement type-based ranking improvements for index-based completions. Reviewers: sammccall, ioeric Reviewed By: sammccall Subscribers: malaperle, mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52273 llvm-svn: 347559
* [clangd] Use testPath in the test.Haojian Wu2018-11-261-2/+2
| | | | llvm-svn: 347547
* [clangd] Auto-index watches global CDB for changes.Sam McCall2018-11-264-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Instead of receiving compilation commands, auto-index is triggered by just filenames to reindex, and gets commands from the global comp DB internally. This has advantages: - more of the work can be done asynchronously (fetching compilation commands upfront can be slow for large CDBs) - we get access to the CDB which can be used to retrieve interpolated commands for headers (useful in some cases where the original TU goes away) - fits nicely with the filename-only change observation from r347297 The interface to GlobalCompilationDatabase gets extended: when retrieving a compile command, the GCDB can optionally report the project the file belongs to. This naturally fits together with getCompileCommand: it's hard to implement one without the other. But because most callers don't care, I've ended up with an awkward optional-out-param-in-virtual method pattern - maybe there's a better one. This is the main missing integration point between ClangdServer and BackgroundIndex, after this we should be able to add an auto-index flag. Reviewers: ioeric, kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov Differential Revision: https://reviews.llvm.org/D54865 llvm-svn: 347538
* [clangd] Add support for hierarchical documentSymbolIlya Biryukov2018-11-233-58/+155
| | | | | | | | | | | | Reviewers: ioeric, sammccall, simark Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52311 llvm-svn: 347498
* [clangd] Cleanup: make the diags callback global in TUSchedulerIlya Biryukov2018-11-221-96/+142
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54760 llvm-svn: 347474
* [clangd] Cleanup error consumption code. NFCIlya Biryukov2018-11-223-42/+17
| | | | | | | - Remove reimplementations of llvm::consumeError. - Simplify test code by using EXPECT_ERROR where it fits. llvm-svn: 347472
* [clangd] Cleanup: make diagnostics callbacks from TUScheduler non-racyIlya Biryukov2018-11-222-1/+9
| | | | | | | | | | | | | | | | | | | | | | Summary: Previously, removeDoc followed by an addDoc to TUScheduler resulted in racy diagnostic responses, i.e. the old dianostics could be delivered to the client after the new ones by TUScheduler. To workaround this, we tracked a version number in ClangdServer and discarded stale diagnostics. After this commit, the TUScheduler will stop delivering diagnostics for removed files and the workaround in ClangdServer is not required anymore. Reviewers: sammccall Reviewed By: sammccall Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54829 llvm-svn: 347468
* [clangd] Cleanup: stop passing around list of supported URI schemes.Eric Liu2018-11-228-69/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Instead of passing around a list of supported URI schemes in clangd, we expose an interface to convert a path to URI using any compatible scheme that has been registered. It favors customized schemes and falls back to "file" when no other scheme works. Changes in this patch are: - URI::create(AbsPath, URISchemes) -> URI::create(AbsPath). The new API finds a compatible scheme from the registry. - Remove URISchemes option everywhere (ClangdServer, SymbolCollecter, FileIndex etc). - Unit tests will use "unittest" by default. - Move "test" scheme from ClangdLSPServer to ClangdMain.cpp, and only register the test scheme when lit-test or enable-lit-scheme is set. (The new flag is added to make lit protocol.test work; I wonder if there is alternative here.) Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54800 llvm-svn: 347467
* [clangd] Fix use-after-scope in unit testBenjamin Kramer2018-11-221-1/+1
| | | | | | | The scheduler holds a reference to `Proceed`, so it has to be destroyed after the scheduler. Found by asan. llvm-svn: 347460
* [clangd] Respect task cancellation in TUScheduler.Sam McCall2018-11-221-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: - Reads are never executed if canceled before ready-to run. In practice, we finalize cancelled reads eagerly and out-of-order. - Cancelled reads don't prevent prior updates from being elided, as they don't actually depend on the result of the update. - Updates are downgraded from WantDiagnostics::Yes to WantDiagnostics::Auto when cancelled, which allows them to be elided when all dependent reads are cancelled and there are subsequent writes. (e.g. when the queue is backed up with cancelled requests). The queue operations aren't optimal (we scan the whole queue for cancelled tasks every time the scheduler runs, and check cancellation twice in the end). However I believe these costs are still trivial in practice (compared to any AST operation) and the logic can be cleanly separated from the rest of the scheduler. Reviewers: ilya-biryukov Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54746 llvm-svn: 347450
* [clangd] Replay preamble #includes to clang-tidy checks.Sam McCall2018-11-202-12/+40
| | | | | | | | | | | | | | | | | | | | | Summary: This is needed to correctly handle checks that use IncludeInserter, which is very common. I couldn't find a totally safe example of a check to enable for testing, I picked modernize-deprecated-headers which some will probably hate. We should get configuration working... This depends on D54691 which ensures our calls to getFile(open=false) don't break subsequent accesses via the FileManager. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54694 llvm-svn: 347298
* [clangd] Allow observation of changes to global CDBs.Sam McCall2018-11-203-0/+71
| | | | | | | | | | | | | | | | | | Summary: Currently, changes *within* CDBs are not tracked (CDB has no facility to do so). However, discovery of new CDBs are tracked (all files are marked as modified). Also, files whose compilation commands are explicitly set are marked modified. The intent is to use this for auto-index. Newly discovered files will be indexed with low priority. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54475 llvm-svn: 347297
OpenPOWER on IntegriCloud