summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/FindTarget.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Fix a crash for accessing a null template decl returned by ↵Haojian Wu2020-06-101-4/+6
| | | | | | | | | | | | | | | | | | | 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/+4
| | | | | | | | | | | | 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/+5
| | | | | | | | | | | | 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] Fix null check in FindTarget.Sam McCall2020-06-101-1/+1
| | | | | | | I've hit this stack trace a few times but don't have a good reproducer. The code is unsafe by inspection, though. (cherry picked from commit 9a5c448a31bacc08e73fcae4636094f9b6e2be6a)
* [clangd] Make output order of allTargetDecls deterministicKadir Cetinkaya2020-02-191-32/+49
| | | | | | | | | | | | | | | | | Summary: Makes use of insertion order to stabilize output for multiple decls. Fixes https://bugs.llvm.org/show_bug.cgi?id=44564 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, usaxena95, cfe-commits, aemerson Tags: #clang Differential Revision: https://reviews.llvm.org/D72826 (cherry picked from commit d54d71b67e602674a255e299a22fe31dee1f3619)
* [clangd] Fix targetDecl() on certain usage of ObjC properties.Sam McCall2020-01-101-0/+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-0/+11
| | | | | | | | | | | | | | 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] Heuristically resolve dependent call through smart pointer typeNathan Ridge2020-01-071-15/+57
| | | | | | | | | | | | Summary: Fixes https://github.com/clangd/clangd/issues/227 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71644
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-041-1/+1
|
* [clangd] targetDecl() returns only NamedDecls.Sam McCall2020-01-031-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] Reorder FindTarget.h - group targetDecl() stuff and ↵Sam McCall2020-01-021-2/+2
| | | | findExplicitReferences(). NFC
* [clangd] Improve documentation for auto and implicit specsKadir Cetinkaya2019-12-191-10/+2
| | | | | | | | | | | | | | | | | | Summary: Clangd didn't fill documentation for `auto` when it wasn't available in index. Also it wasn't showing any documentations for implicit instantiations. This patch ensures auto and normal decl case behaves in the same way and also makes use of the explicit template specialization while fetching comments for implicit instantiations. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71596
* [NFC] Fix typos in Clangd and ClangKirill Bobyrev2019-12-161-6/+6
| | | | | | Reviewed by: Jim Differential Revision: https://reviews.llvm.org/D71455
* [clangd] Heuristically resolve dependent method callsNathan Ridge2019-12-121-2/+62
| | | | | | | | | | | | | | | | Summary: The heuristic is to look in the definition of the primary template, which is what you want in the vast majority of cases. Fixes https://github.com/clangd/clangd/issues/141 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71240
* [clangd] Find reference to template parameter in 'sizeof...' expressionNathan Ridge2019-12-051-0/+10
| | | | | | | | | | | | | | 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/+3
| | | | | | | | | | | | 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
* [clangd] Implement semantic highlightings via findExplicitReferencesIlya Biryukov2019-11-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: To keep the logic of finding locations of interesting AST nodes in one place. The advantage is better coverage of various AST nodes, both now and in the future: as new nodes get added to `findExplicitReferences`, semantic highlighting will automatically pick them up. The drawback of this change is that we have to traverse declarations inside our file twice in order to highlight dependent names, 'auto' and 'decltype'. Hopefully, this should not affect the actual latency too much, most time should be spent in building the AST and not traversing it. Reviewers: hokein Reviewed By: hokein Subscribers: nridge, merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69673
* [clangd] Fix namespace aliases in findExplicitReferencesIlya Biryukov2019-10-311-4/+8
| | | | | | | | | | | | 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-2/+9
| | | | | | | | | | | | | | | | | | | 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-7/+13
| | | | | | | | | | 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-47/+80
| | | | | | | | | | | | Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68977 llvm-svn: 375226
* [clangd] Handle template arguments in findExplicitReferencesIlya Biryukov2019-10-011-2/+35
| | | | | | | | | | | | | | 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/+4
| | | | | | | | | | | | | | 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-8/+17
| | | | | | | | | | | | | | 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/+5
| | | | | | | | | | | | | | 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-0/+7
| | | | | | | | | | | | | | 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] Change constness of parameters to findExplicitRefsKadir Cetinkaya2019-09-251-4/+4
| | | | | | | | | | | | | | | | | | Summary: Recursive AST requires non-const ast nodes, but it doesn't really mutate them. In addition to that, in clangd we mostly have const ast nodes. So it makes sense to move the const_cast into callee rather than having it at every caller in the future. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68027 llvm-svn: 372888
* [clangd] A helper to find explicit references and their namesIlya Biryukov2019-09-251-1/+295
| | | | | | | | | | | | | | | | | | | | | | 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] Remove redundant semi-colon.Michael Liao2019-09-031-1/+1
| | | | llvm-svn: 370763
* [clangd] Wrong attribute on debug function in r370746Sam McCall2019-09-031-1/+1
| | | | llvm-svn: 370757
* Fix MSVC "not all control paths return a value" warning. NFCI.Simon Pilgrim2019-09-031-0/+1
| | | | llvm-svn: 370750
* [clangd] Add targetDecl(), which determines what declaration an AST node ↵Sam McCall2019-09-031-0/+381
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