[clang] [clang-tools-extra] [clang] [Sema] Preserve nested name specifier prefix in MemberPointerType (PR #118236)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 1 19:32:05 PST 2024
================
@@ -5347,13 +5347,16 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate:
- ClsType = QualType(NNS->getAsType(), 0);
+ const Type *NNSType = NNS->getAsType();
+ ClsType = QualType(NNSType, 0);
// Note: if the NNS has a prefix and ClsType is a nondependent
- // TemplateSpecializationType, then the NNS prefix is NOT included
- // in ClsType; hence we wrap ClsType into an ElaboratedType.
- // NOTE: in particular, no wrap occurs if ClsType already is an
- // Elaborated, DependentName, or DependentTemplateSpecialization.
- if (isa<TemplateSpecializationType>(NNS->getAsType()))
+ // TemplateSpecializationType or a RecordType, then the NNS prefix is
+ // NOT included in ClsType; hence we wrap ClsType into an
+ // ElaboratedType. NOTE: in particular, no wrap occurs if ClsType
+ // already is an Elaborated, DependentName, or
+ // DependentTemplateSpecialization.
+ if (isa<TemplateSpecializationType>(NNSType) ||
+ (NNSPrefix && isa<RecordType>(NNSType)))
----------------
mizvekov wrote:
It would also be cool to have an assertion here, that we are handling all cases.
I think the logic here would be something like:
```
if (isa<DependentTemplateSpecializationType>...)
// Rebuild DependentTemplateSpecializationType, adding the Prefix.
else
// either the dependent case (TemplateSpecializationType), or the non-dependent one (RecordType).
// assert(isa<TemplateSpecializationType, RecordType>...)
```
https://github.com/llvm/llvm-project/pull/118236
More information about the cfe-commits
mailing list