[PATCH] D127351: clang: fix early substitution of alias templates
Matheus Izvekov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 8 17:13:55 PDT 2022
mizvekov added a comment.
@rsmith , I have marked the few spots where the change is meaningful.
================
Comment at: clang/include/clang/Sema/Template.h:488-497
+ bool EarlySubstitution;
+
public:
TemplateDeclInstantiator(Sema &SemaRef, DeclContext *Owner,
- const MultiLevelTemplateArgumentList &TemplateArgs)
+ const MultiLevelTemplateArgumentList &TemplateArgs,
+ bool EarlySubstitution)
: SemaRef(SemaRef),
----------------
mark
================
Comment at: clang/include/clang/Sema/Template.h:629-648
+
+ unsigned getNewDepth(unsigned Depth) const {
+ return Depth -
+ (EarlySubstitution ? 0 : TemplateArgs.getNumSubstitutedLevels());
+ }
+
+ class EarlySubstitutionRAII {
----------------
mark
================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:931-941
+ bool EarlySubstitution;
public:
typedef TreeTransform<TemplateInstantiator> inherited;
TemplateInstantiator(Sema &SemaRef,
const MultiLevelTemplateArgumentList &TemplateArgs,
----------------
mark
================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1194-1215
+ TemplateDeclInstantiator DeclInstantiator(
+ getSema(),
+ /* DeclContext *Owner */ Owner, TemplateArgs, EarlySubstitution);
return DeclInstantiator.SubstTemplateParams(OrigTPL);
}
concepts::TypeRequirement *
----------------
mark
================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1872
QualType Result = getSema().Context.getTemplateTypeParmType(
- T->getDepth() - TemplateArgs.getNumSubstitutedLevels(), T->getIndex(),
- T->isParameterPack(), NewTTPDecl);
+ getNewDepth(T->getDepth()), T->getIndex(), T->isParameterPack(),
+ NewTTPDecl);
----------------
mark
================
Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:2807
SemaRef.Context, Owner, D->getBeginLoc(), D->getLocation(),
- D->getDepth() - TemplateArgs.getNumSubstitutedLevels(), D->getIndex(),
- D->getIdentifier(), D->wasDeclaredWithTypename(), D->isParameterPack(),
+ getNewDepth(D->getDepth()), D->getIndex(), D->getIdentifier(),
+ D->wasDeclaredWithTypename(), D->isParameterPack(),
----------------
mark
================
Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:2965-2970
+ getNewDepth(D->getDepth()), D->getPosition(), D->getIdentifier(), T, DI,
+ ExpandedParameterPackTypes, ExpandedParameterPackTypesAsWritten);
else
Param = NonTypeTemplateParmDecl::Create(
SemaRef.Context, Owner, D->getInnerLocStart(), D->getLocation(),
+ getNewDepth(D->getDepth()), D->getPosition(), D->getIdentifier(), T,
----------------
mark
================
Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:3105-3109
+ SemaRef.Context, Owner, D->getLocation(), getNewDepth(D->getDepth()),
D->getPosition(), D->getIdentifier(), InstParams, ExpandedParams);
else
Param = TemplateTemplateParmDecl::Create(
+ SemaRef.Context, Owner, D->getLocation(), getNewDepth(D->getDepth()),
----------------
mark
================
Comment at: clang/test/AST/ast-dump-template-decls.cpp:124
// CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'void' sugar
-// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent depth 0 index 0
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent depth 1 index 0
// CHECK-NEXT: TemplateTypeParm 0x{{[^ ]*}} 'U'
----------------
mark
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127351/new/
https://reviews.llvm.org/D127351
More information about the cfe-commits
mailing list