[clang] [clang-tools-extra] [clang] [Sema] Preserve nested name specifier prefix in MemberPointerType (PR #118236)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 1 19:05:55 PST 2024
================
@@ -5347,15 +5347,18 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate:
- ClsType = QualType(NNS->getAsType(), 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()))
+ const Type *NNSType = NNS->getAsType();
+ ClsType = QualType(NNSType, 0);
+ // If ClsType is an Elaborated, DependentName, or
+ // DependentTemplateSpecialization, it already stores the NNS prefix.
+ // Otherwise, wrap it in an Elaborated type to have a place to store
+ // the NNS prefix.
+ if (!(isa<ElaboratedType>(NNSType) ||
+ isa<DependentNameType>(NNSType) ||
+ isa<DependentTemplateSpecializationType>(NNSType))) {
----------------
HighCommander4 wrote:
@mizvekov Thanks for having a look!
I don't have any evidence of us actually getting an ElaboratedType or DependentNameType here, I was just basing this on the comment which mentioned these types.
I revised the patch to make a more targeted change (wrap `RecordType` when there is a qualifier present), which still addresses the original issue I was having in clangd, and (hopefully) passes tests. I would be grateful of your opinion about whether there is a more appropriate condition we should be using.
https://github.com/llvm/llvm-project/pull/118236
More information about the cfe-commits
mailing list