From: Nathan Ridge Date: Fri, 9 Jun 2023 06:39:28 +0000 (-0400) Subject: [clangd] Unwrap type sugar in HeuristicResolver::resolveTypeToRecordDecl() X-Git-Tag: upstream/17.0.6~5070 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=19c9af81b1c5dd7b3d11d235a77b7181b9368a28;p=platform%2Fupstream%2Fllvm.git [clangd] Unwrap type sugar in HeuristicResolver::resolveTypeToRecordDecl() Fixes https://github.com/clangd/clangd/issues/1663 Differential Revision: https://reviews.llvm.org/D152500 --- diff --git a/clang-tools-extra/clangd/HeuristicResolver.cpp b/clang-tools-extra/clangd/HeuristicResolver.cpp index 460b9be..e91bd0e 100644 --- a/clang-tools-extra/clangd/HeuristicResolver.cpp +++ b/clang-tools-extra/clangd/HeuristicResolver.cpp @@ -35,6 +35,9 @@ const auto TemplateFilter = [](const NamedDecl *D) { CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) { assert(T); + // Unwrap type sugar such as type aliases. + T = T->getCanonicalTypeInternal().getTypePtr(); + if (const auto *RT = T->getAs()) return dyn_cast(RT->getDecl()); diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp index fe87e4b..d54539b 100644 --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -863,6 +863,20 @@ TEST_F(TargetDeclTest, DependentExprs) { )cpp"; EXPECT_DECLS("CXXDependentScopeMemberExpr", "template T convert() const"); + + Code = R"cpp( + template + struct Waldo { + void find(); + }; + template + using Wally = Waldo; + template + void foo(Wally w) { + w.[[find]](); + } + )cpp"; + EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()"); } TEST_F(TargetDeclTest, DependentTypes) {