[PATCH] D152500: [clangd] Unwrap type sugar in HeuristicResolver::resolveTypeToRecordDecl()
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 14 10:51:14 PDT 2023
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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152500.531426.patch
Type: text/x-patch
Size: 1299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230614/bfdc4481/attachment-0001.bin>
More information about the cfe-commits
mailing list