summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Fix a crash for accessing a null template decl returned by ↵Haojian Wu2020-06-101-5/+31
| | | | | | | | | | | | | | | | | | | findExplicitReferences. Summary: Fixes https://github.com/clangd/clangd/issues/347. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D78626 (cherry picked from commit 7d1ee639cb9efea364bec90afe4d1161ec624a7f) Includes some test-only changes from f651c402a221a20f3bc6ea43f70b29326a357010 to support the cherry-picked tests. Test tweaked slightly as it exhibits a separate bug that was fixed on master.
* [clangd] Add the missing elaborated types in FindTarget.Haojian Wu2020-06-101-0/+7
| | | | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74025 (cherry picked from commit eaf0c89ec5f866b6cef296c542c030bb2cf8481d)
* [clangd] Handle the missing injectedClassNameType in targetDecl.Haojian Wu2020-06-101-0/+8
| | | | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73102 (cherry picked from commit 5d4e89975714875a86cb8e62b60d93eebefa4029)
* [clangd] Assert that the testcases in FindExplicitReferencesTest.All have no ↵Nathan Ridge2020-01-121-3/+7
| | | | | | | | | | | | diagnostics Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72355
* [clangd] Fix targetDecl() on certain usage of ObjC properties.Sam McCall2020-01-101-6/+6
| | | | | | | | | | | | | | | Summary: In particular there's a common chain: OpaqueValueExpr->PseudoObjectExpr->ObjCPropertyRefExpr->ObjCPropertyDecl and we weren't handling the first two edges Reviewers: dgoldman, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72494
* [clangd] Handle DeducedTemplateSpecializationType in TargetFinderNathan Ridge2020-01-091-1/+29
| | | | | | | | | | | | | | Summary: This is a workaround for https://bugs.llvm.org/show_bug.cgi?id=42914. Once that is fixed, the handling in VisitDeducedTyped() should be sufficient. Fixes https://github.com/clangd/clangd/issues/242 Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72119
* [clangd] targetDecl() returns only NamedDecls.Sam McCall2020-01-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: While it's perfectly reasonable for non-named decls such as static_assert to resolve to themselves: - nothing else ever resolves to them - features based on references (hover, highlight, find refs etc) tend to be uninteresting where only trivial references are possible - returning NamedDecl is a more convenient API (we cast to it in many places) - this aligns closer to findExplicitReferences/explicitReferenceTargets This fixes a crash in explicitReferenceTargets: if the target is a non-named decl then there's an invalid unchecked cast to NamedDecl. In practice this means when hovering over e.g. a static_assert: - before ac3f9e4842, we would show a (boring) hover card - after ac3f9e4842, we would crash - after this patch, we will show nothing Reviewers: kadircet, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72163
* Revert "[clangd] Reapply b60896fad926 Fall back to selecting ↵Sam McCall2019-12-161-2/+2
| | | | | | | token-before-cursor if token-after-cursor fails." This reverts commit a0ff8cd631add513423fc2d8afa49e9650d01fe3. Buildbot failures I can't chase further tonight.
* [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if ↵Sam McCall2019-12-161-2/+2
| | | | | | token-after-cursor fails. This reverts commit 8f876d5105507f874c0fb86bc779c9853eab3fe2.
* Revert "[clangd] Reapply b60896fad926 Fall back to selecting ↵Sam McCall2019-12-161-2/+2
| | | | | | token-before-cursor if token-after-cursor fails." This reverts commit 2500a8d5d8813a3e31fc9ba8dd45e211439a1e3d.
* [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if ↵Sam McCall2019-12-161-2/+2
| | | | | | | token-after-cursor fails. This reverts commit f0604e73a4daa35a10eb17a998657d6c4bd0e971 The issue with movability of Tweak::Selection was addressed in 7dc388bd9596bbf42633f8a8e450224e39740b60
* Revert "[clangd] Fall back to selecting token-before-cursor if ↵Nico Weber2019-12-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | token-after-cursor fails." This reverts commit b60896fad926754f715acc5d771555aaaa577e0f. Breaks building with gcc: /usr/include/c++/7/bits/stl_construct.h:75:7: error: use of deleted function ‘clang::clangd::Tweak::Selection::Selection(const clang::clangd::Tweak::Selection&)’ { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.h:28:0, from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9: /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10: note: ‘clang::clangd::Tweak::Selection::Selection(const clang::clangd::Tweak::Selection&)’ is implicitly deleted because the default definition would be ill-formed: struct Selection { ^~~~~~~~~ /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10: error: use of deleted function ‘clang::clangd::SelectionTree::SelectionTree(const clang::clangd::SelectionTree&)’ In file included from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:25:0, from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.h:28, from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9: /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/Selection.h:96:3: note: declared here SelectionTree(const SelectionTree &) = delete; ^~~~~~~~~~~~~ e.g. here: http://lab.llvm.org:8011/builders/clang-cmake-armv7-selfhost-neon/builds/2714 http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/41866
* [clangd] Fall back to selecting token-before-cursor if token-after-cursor fails.Sam McCall2019-12-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The problem: LSP specifies that Positions are between characters. Therefore when a position (or an empty range) is used to target elements of the source code, there is an ambiguity - should we look left or right of the cursor? Until now, SelectionTree resolved this to the right except in trivial cases (where there's whitespace, semicolon, or eof on the right). This meant that it's unable to e.g. out-line `int foo^()` today. Complicating this, LSP notwithstanding the cursor is *on* a character in many editors (mostly terminal-based). In these cases there's no ambiguity - we must "look right" - but there's also no way to tell in LSP. (Several features currently resolve this by using getBeginningOfIdentifier, which tries to rewind and supports end-of-identifier. But this relies on raw lexing and is limited and buggy). Precedent: well - most other languages aren't so full of densely packed symbols that we might want to target. Bias-towards-identifier works well enough. MS C++ for vscode seems to mostly use bias-toward-identifier too. The problem with this solution is it doesn't provide any way to target some things such as the constructor call in Foo^(bar()); Presented solution: When an ambiguous selection is found, we generate *both* possible selection trees. We try to run the feature on the rightward tree first, and then on the leftward tree if it fails. This is basically do-what-I-mean, the main downside is the need to do this on a feature-by-feature basis (because each feature knows what "fail" means). The most complicated instance of this is Tweaks, where the preferred selection may vary tweak-by-tweak. Wrinkles: While production behavior is pretty consistent, this introduces some inconsistency in testing, depending whether the interface we're testing is inside or outside the "retry" wrapper. In particular, for many features like Hover, the unit tests will show production behavior, while for Tweaks the harness would have to run the loop itself if we want this. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71345
* [clangd] Find reference to template parameter in 'sizeof...' expressionNathan Ridge2019-12-051-146/+163
| | | | | | | | | | | | | | Fixes https://github.com/clangd/clangd/issues/213. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70740
* [clangd] Handle the missing call expr in targetDecl.Haojian Wu2019-11-271-0/+17
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: merge_guards_bot, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70773
* [AST] Use written names instead of `type-param-0-0` in more cases when ↵Sam McCall2019-11-151-2/+1
| | | | | | | | | | | | | | | | | | | printing types and decls. Summary: This doesn't cover decls in diagnostics, which use NamedDecl::getNameForDiagnostic(). (That should also be fixed later I think). This covers some cases of https://github.com/clangd/clangd/issues/76 (hover, but not outline or sighelp) Reviewers: hokein Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70236
* [clangd] Fix namespace aliases in findExplicitReferencesIlya Biryukov2019-10-311-0/+22
| | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69624
* [clangd] Do not report anonymous entities in findExplicitReferencesIlya Biryukov2019-10-281-7/+15
| | | | | | | | | | | | | | | | | | | Summary: Otherwise every client dealing with name location should handle anonymous names in a special manner. This seems too error-prone, clients can probably handle anonymous entities they care about differently. Reviewers: hokein Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69511
* [clangd] Handle the missing constructor initializers in findExplicitReferences.Haojian Wu2019-10-241-0/+39
| | | | | | | | | | Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69241
* [clangd] Report declaration references in findExplicitReferences.Haojian Wu2019-10-181-39/+75
| | | | | | | | | | | | Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68977 llvm-svn: 375226
* Make most clangd unittests pass on WindowsNico Weber2019-10-131-0/+16
| | | | | | | | | | | | | | | | | | | | The Windows triple currently turns on delayed template parsing, which confuses several unit tests that use templates. For now, just explicitly disable delayed template parsing. This isn't ideal, but: - the Windows triple will soon no longer use delayed template parsing by default - there's precedent for this in the clangd unit tests already - let's get the clangd tests pass on Windows first before making behavioral changes Part of PR43592. llvm-svn: 374718
* [clangd] Handle template arguments in findExplicitReferencesIlya Biryukov2019-10-011-0/+33
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68137 llvm-svn: 373318
* [clangd] Handle OverloadExpr in targetDeclIlya Biryukov2019-10-011-0/+26
| | | | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: nridge, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68119 llvm-svn: 373305
* [clangd] Fix template type aliases in findExplicitReferenceIlya Biryukov2019-09-271-13/+11
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68124 llvm-svn: 373104
* [clangd] Handle type template parameters in findExplicitReferencesIlya Biryukov2019-09-271-0/+20
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68120 llvm-svn: 373067
* [clangd] Support OverloadExpr in findExplicitReferencesIlya Biryukov2019-09-271-1/+36
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68118 llvm-svn: 373057
* [clangd] A helper to find explicit references and their namesIlya Biryukov2019-09-251-0/+220
| | | | | | | | | | | | | | | | | | | | | | Summary: Allows to simplify pending code tweaks: - the upcoming DefineInline tweak (D66647) - remove using declaration (D56612) - qualify name under cursor (D56610) Another potential future application is simplifying semantic highlighting. Reviewers: kadircet Reviewed By: kadircet Subscribers: mgrang, jfb, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67826 llvm-svn: 372859
* [clangd] Add targetDecl(), which determines what declaration an AST node ↵Sam McCall2019-09-031-0/+469
refers to. Summary: This is the first part of an effort to "unbundle" our libIndex use into separate concerns (AST traversal, token<->node mapping, node<->decl mapping, decl<->decl relationshipes). Currently, clangd relies on libIndex to associate tokens, AST nodes, and decls. This leads to rather convoluted implementations of e.g. hover and extract-function, which are not naturally thought of as indexing applications. The idea is that by decoupling different concerns, we make them easier to use, test, and combine, and more efficient when only one part is needed. There are some synergies between e.g. traversal and finding relationships between decls, hopefully the benefits outweight these. Reviewers: kadircet, ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66751 llvm-svn: 370746
OpenPOWER on IntegriCloud