@@ -71,8 +71,8 @@ class HeuristicResolverImpl {
71
71
72
72
// Helper function for HeuristicResolver::resolveDependentMember()
73
73
// which takes a possibly-dependent type `T` and heuristically
74
- // resolves it to a CXXRecordDecl in which we can try name lookup.
75
- CXXRecordDecl * resolveTypeToRecordDecl (const Type *T);
74
+ // resolves it to a TagDecl in which we can try name lookup.
75
+ TagDecl * resolveTypeToTagDecl (const Type *T);
76
76
77
77
// This is a reimplementation of CXXRecordDecl::lookupDependentName()
78
78
// so that the implementation can call into other HeuristicResolver helpers.
@@ -130,7 +130,7 @@ TemplateName getReferencedTemplateName(const Type *T) {
130
130
// Helper function for HeuristicResolver::resolveDependentMember()
131
131
// which takes a possibly-dependent type `T` and heuristically
132
132
// resolves it to a CXXRecordDecl in which we can try name lookup.
133
- CXXRecordDecl *HeuristicResolverImpl::resolveTypeToRecordDecl (const Type *T) {
133
+ TagDecl *HeuristicResolverImpl::resolveTypeToTagDecl (const Type *T) {
134
134
assert (T);
135
135
136
136
// Unwrap type sugar such as type aliases.
@@ -144,8 +144,9 @@ CXXRecordDecl *HeuristicResolverImpl::resolveTypeToRecordDecl(const Type *T) {
144
144
T = T->getCanonicalTypeInternal ().getTypePtr ();
145
145
}
146
146
147
- if (const auto *RT = T->getAs <RecordType>())
148
- return dyn_cast<CXXRecordDecl>(RT->getDecl ());
147
+ if (auto *TT = T->getAs <TagType>()) {
148
+ return TT->getDecl ();
149
+ }
149
150
150
151
if (const auto *ICNT = T->getAs <InjectedClassNameType>())
151
152
T = ICNT->getInjectedSpecializationType ().getTypePtrOrNull ();
@@ -278,7 +279,7 @@ HeuristicResolverImpl::resolveTypeOfCallExpr(const CallExpr *CE) {
278
279
CalleeType = FnTypePtr->getPointeeType ();
279
280
if (const FunctionType *FnType = CalleeType->getAs <FunctionType>()) {
280
281
if (const auto *D =
281
- resolveTypeToRecordDecl (FnType->getReturnType ().getTypePtr ())) {
282
+ resolveTypeToTagDecl (FnType->getReturnType ().getTypePtr ())) {
282
283
return {D};
283
284
}
284
285
}
@@ -389,11 +390,11 @@ bool findOrdinaryMember(const CXXRecordDecl *RD, CXXBasePath &Path,
389
390
bool HeuristicResolverImpl::findOrdinaryMemberInDependentClasses (
390
391
const CXXBaseSpecifier *Specifier, CXXBasePath &Path,
391
392
DeclarationName Name) {
392
- CXXRecordDecl *RD =
393
- resolveTypeToRecordDecl (Specifier-> getType (). getTypePtr ());
394
- if (!RD)
395
- return false ;
396
- return findOrdinaryMember (RD, Path, Name) ;
393
+ TagDecl *TD = resolveTypeToTagDecl (Specifier-> getType (). getTypePtr ());
394
+ if ( const auto *RD = dyn_cast_if_present<CXXRecordDecl>(TD)) {
395
+ return findOrdinaryMember (RD, Path, Name);
396
+ }
397
+ return false ;
397
398
}
398
399
399
400
std::vector<const NamedDecl *> HeuristicResolverImpl::lookupDependentName (
@@ -435,11 +436,14 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveDependentMember(
435
436
const Type *T = QT.getTypePtrOrNull ();
436
437
if (!T)
437
438
return {};
438
- if (auto *ET = T->getAs <EnumType>()) {
439
- auto Result = ET->getDecl ()->lookup (Name);
439
+ TagDecl *TD = resolveTypeToTagDecl (T);
440
+ if (!TD)
441
+ return {};
442
+ if (auto *ED = dyn_cast<EnumDecl>(TD)) {
443
+ auto Result = ED->lookup (Name);
440
444
return {Result.begin (), Result.end ()};
441
445
}
442
- if (auto *RD = resolveTypeToRecordDecl (T )) {
446
+ if (auto *RD = dyn_cast<CXXRecordDecl>(TD )) {
443
447
if (!RD->hasDefinition ())
444
448
return {};
445
449
RD = RD->getDefinition ();
0 commit comments