[clang-tools-extra] 19c9af8 - [clangd] Unwrap type sugar in HeuristicResolver::resolveTypeToRecordDecl()
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 14 10:51:12 PDT 2023
Author: Nathan Ridge
Date: 2023-06-14T13:51:00-04:00
New Revision: 19c9af81b1c5dd7b3d11d235a77b7181b9368a28
URL: https://github.com/llvm/llvm-project/commit/19c9af81b1c5dd7b3d11d235a77b7181b9368a28
DIFF: https://github.com/llvm/llvm-project/commit/19c9af81b1c5dd7b3d11d235a77b7181b9368a28.diff
LOG: [clangd] Unwrap type sugar in HeuristicResolver::resolveTypeToRecordDecl()
Fixes https://github.com/clangd/clangd/issues/1663
Differential Revision: https://reviews.llvm.org/D152500
Added:
Modified:
clang-tools-extra/clangd/HeuristicResolver.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/HeuristicResolver.cpp b/clang-tools-extra/clangd/HeuristicResolver.cpp
index 460b9be592baa..e91bd0e87a8b7 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<RecordType>())
return dyn_cast<CXXRecordDecl>(RT->getDecl());
diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index fe87e4be3940e..d54539b53badd 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 <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) {
More information about the cfe-commits
mailing list