This revision was automatically updated to reflect the committed changes. Closed by commit rG19c9af81b1c5: [clangd] Unwrap type sugar in HeuristicResolver::resolveTypeToRecordDecl() (authored by nridge).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152500/new/ 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());
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());
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits