[PATCH] D152500: [clangd] Handle alias template in HeuristicResolver::resolveTypeToRecordDecl()
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 10 23:48:58 PDT 2023
nridge created this revision.
Herald added subscribers: jeroen.dobbelaere, kadircet, arphaman.
Herald added a project: All.
nridge updated this revision to Diff 530279.
nridge added a comment.
nridge published this revision for review.
nridge added reviewers: hokein, sammccall.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
Make the approach more general
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152500
Files:
clang-tools-extra/clangd/HeuristicResolver.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -863,6 +863,20 @@
)cpp";
EXPECT_DECLS("CXXDependentScopeMemberExpr",
"template <typename T> T convert() const");
+
+ Code = R"cpp(
+ template <typename T>
+ struct Waldo {
+ void find();
+ };
+ template <typename T>
+ using Wally = Waldo<T>;
+ template <typename T>
+ void foo(Wally<T> w) {
+ w.[[find]]();
+ }
+ )cpp";
+ EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
}
TEST_F(TargetDeclTest, DependentTypes) {
Index: clang-tools-extra/clangd/HeuristicResolver.cpp
===================================================================
--- clang-tools-extra/clangd/HeuristicResolver.cpp
+++ clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -35,6 +35,9 @@
CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
assert(T);
+ // Unwrap type sugar such as type aliases.
+ T = T->getCanonicalTypeInternal().getTypePtr();
+
if (const auto *RT = T->getAs<RecordType>())
return dyn_cast<CXXRecordDecl>(RT->getDecl());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152500.530279.patch
Type: text/x-patch
Size: 1299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230611/26c143a1/attachment.bin>
More information about the cfe-commits
mailing list