File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,16 @@ const Type *resolveDeclsToType(const std::vector<const NamedDecl *> &Decls,
118
118
return nullptr ;
119
119
}
120
120
121
+ TemplateName getReferencedTemplateName (const Type *T) {
122
+ if (const auto *TST = T->getAs <TemplateSpecializationType>()) {
123
+ return TST->getTemplateName ();
124
+ }
125
+ if (const auto *DTST = T->getAs <DeducedTemplateSpecializationType>()) {
126
+ return DTST->getTemplateName ();
127
+ }
128
+ return TemplateName ();
129
+ }
130
+
121
131
// Helper function for HeuristicResolver::resolveDependentMember()
122
132
// which takes a possibly-dependent type `T` and heuristically
123
133
// resolves it to a CXXRecordDecl in which we can try name lookup.
@@ -142,12 +152,12 @@ CXXRecordDecl *HeuristicResolverImpl::resolveTypeToRecordDecl(const Type *T) {
142
152
if (!T)
143
153
return nullptr ;
144
154
145
- const auto *TST = T-> getAs <TemplateSpecializationType>( );
146
- if (!TST )
155
+ TemplateName TN = getReferencedTemplateName (T );
156
+ if (TN. isNull () )
147
157
return nullptr ;
148
158
149
- const ClassTemplateDecl *TD = dyn_cast_or_null<ClassTemplateDecl>(
150
- TST-> getTemplateName () .getAsTemplateDecl ());
159
+ const ClassTemplateDecl *TD =
160
+ dyn_cast_or_null<ClassTemplateDecl>(TN .getAsTemplateDecl ());
151
161
if (!TD)
152
162
return nullptr ;
153
163
Original file line number Diff line number Diff line change @@ -842,6 +842,8 @@ TEST_F(TargetDeclTest, OverloadExpr) {
842
842
}
843
843
844
844
TEST_F (TargetDeclTest, DependentExprs) {
845
+ Flags.push_back (" --std=c++20" );
846
+
845
847
// Heuristic resolution of method of dependent field
846
848
Code = R"cpp(
847
849
struct A { void foo() {} };
@@ -962,6 +964,21 @@ TEST_F(TargetDeclTest, DependentExprs) {
962
964
};
963
965
)cpp" ;
964
966
EXPECT_DECLS (" MemberExpr" , " void find()" );
967
+
968
+ // Base expression is the type of a non-type template parameter
969
+ // which is deduced using CTAD.
970
+ Code = R"cpp(
971
+ template <int N>
972
+ struct Waldo {
973
+ const int found = N;
974
+ };
975
+
976
+ template <Waldo W>
977
+ int test() {
978
+ return W.[[found]];
979
+ }
980
+ )cpp" ;
981
+ EXPECT_DECLS (" CXXDependentScopeMemberExpr" , " const int found = N" );
965
982
}
966
983
967
984
TEST_F (TargetDeclTest, DependentTypes) {
You can’t perform that action at this time.
0 commit comments