[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
Sat Dec 7 18:11:29 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)))
----------------
HighCommander4 wrote:
> The assert is still viable and would be helpful
FWIW, I did try adding back the assert to see what other sorts of types we get in this codepath. I found the following:
* `TemplateTypeParmType` (seen in SemaCXX/err_init_conversion_failed.cpp)
* `TypedefType` (seen in CXX/drs/cwg3xx.cpp)
* `DecltypeType` (seen in CXX/expr/expr_prim/expr_prim_general/p8-0x.cpp)
* `InjectedClassNameType` (seen in CXX/temp/temp_decls/temp_variadic/p5.cpp)
* `UsingType` (seen in Modules/using-decl.cpp)
It's not clear to me what sort of handling we'd want for these various types.
https://github.com/llvm/llvm-project/pull/118236
More information about the cfe-commits
mailing list