Clean up handling of constrained parameters in lambdas.

No functionality change intended.
This commit is contained in:
Richard Smith 2021-05-12 14:19:23 -07:00
parent 4c88cfb1dc
commit e0acfed7ed
4 changed files with 10 additions and 10 deletions

View File

@ -1125,7 +1125,9 @@ void TypePrinter::printAutoBefore(const AutoType *T, raw_ostream &OS) {
printBefore(T->getDeducedType(), OS);
} else {
if (T->isConstrained()) {
OS << T->getTypeConstraintConcept()->getName();
// FIXME: Track a TypeConstraint as type sugar, so that we can print the
// type as it was written.
T->getTypeConstraintConcept()->getDeclName().print(OS, Policy);
auto Args = T->getTypeConstraintArguments();
if (!Args.empty())
printTemplateArgumentList(

View File

@ -2386,10 +2386,10 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm,
}
if (AttachTypeConstraint(
TC->getNestedNameSpecifierLoc(), TC->getConceptNameInfo(),
TC->getNamedConcept(), &InstArgs, Inst,
TC->getNamedConcept(), TemplArgInfo ? &InstArgs : nullptr, Inst,
TTP->isParameterPack()
? cast<CXXFoldExpr>(TC->getImmediatelyDeclaredConstraint())
->getEllipsisLoc()
->getEllipsisLoc()
: SourceLocation()))
return nullptr;
}

View File

@ -2581,7 +2581,6 @@ Decl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
TemplateTypeParmDecl *D) {
// TODO: don't always clone when decls are refcounted.
assert(D->getTypeForDecl()->isTemplateTypeParmType());
Optional<unsigned> NumExpanded;

View File

@ -6515,11 +6515,9 @@ QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
ConceptDecl *NewCD = nullptr;
TemplateArgumentListInfo NewTemplateArgs;
NestedNameSpecifierLoc NewNestedNameSpec;
if (TL.getTypePtr()->isConstrained()) {
NewCD = cast_or_null<ConceptDecl>(
getDerived().TransformDecl(
TL.getConceptNameLoc(),
TL.getTypePtr()->getTypeConstraintConcept()));
if (T->isConstrained()) {
NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
@ -6541,7 +6539,8 @@ QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
QualType Result = TL.getType();
if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
T->isDependentType()) {
T->isDependentType() || T->isConstrained()) {
// FIXME: Maybe don't rebuild if all template arguments are the same.
llvm::SmallVector<TemplateArgument, 4> NewArgList;
NewArgList.reserve(NewArgList.size());
for (const auto &ArgLoc : NewTemplateArgs.arguments())