[clang] [Clang][Sema] Use correct TemplateName when transforming TemplateSpecializationType (PR #93411)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sun May 26 08:39:14 PDT 2024
================
@@ -7216,9 +7216,30 @@ TreeTransform<Derived>::TransformElaboratedType(TypeLocBuilder &TLB,
return QualType();
}
- QualType NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc());
- if (NamedT.isNull())
- return QualType();
+ QualType NamedT;
+ if (SemaRef.getLangOpts().CPlusPlus20 && QualifierLoc &&
+ isa<TemplateSpecializationType>(TL.getNamedTypeLoc().getType())) {
+ TemplateSpecializationTypeLoc SpecTL =
+ TL.getNamedTypeLoc().castAs<TemplateSpecializationTypeLoc>();
+ const TemplateSpecializationType *TST =
+ SpecTL.getType()->castAs<TemplateSpecializationType>();
+ CXXScopeSpec SS;
+ SS.Adopt(QualifierLoc);
+ if (TemplateDecl *TD = TST->getTemplateName().getAsTemplateDecl()) {
+ TemplateName InstName = getDerived().RebuildTemplateName(
+ SS, TL.getTemplateKeywordLoc(), *TD->getIdentifier(),
+ TL.getNamedTypeLoc().getBeginLoc(), /*ObjectType=*/QualType(),
+ /*FirstQualifierInScope=*/nullptr, /*AllowInjectedClassName=*/false);
+ if (InstName.isNull())
+ return QualType();
+ NamedT = TransformTemplateSpecializationType(TLB, SpecTL, InstName);
----------------
zyn0217 wrote:
Did you mean `getDerived().TransformTemplateSpecializationType()`?
https://github.com/llvm/llvm-project/pull/93411
More information about the cfe-commits
mailing list