@@ -1542,6 +1542,7 @@ const NormalizedConstraint *Sema::getNormalizedAssociatedConstraints(
1542
1542
return NormalizedConstraint::fromAssociatedConstraints (
1543
1543
*this , nullptr , AssociatedConstraints);
1544
1544
1545
+ // FIXME: ConstrainedDeclOrNestedReq is never a NestedRequirement!
1545
1546
const NamedDecl *ND =
1546
1547
ConstrainedDeclOrNestedReq.dyn_cast <const NamedDecl *>();
1547
1548
auto CacheEntry = NormalizationCache.find (ConstrainedDeclOrNestedReq);
@@ -1624,6 +1625,31 @@ substituteParameterMappings(Sema &S, NormalizedConstraintWithParamMapping &N,
1624
1625
{InstLocBegin, InstLocEnd});
1625
1626
if (Inst.isInvalid ())
1626
1627
return true ;
1628
+
1629
+ unsigned Hash;
1630
+ llvm::FoldingSetNodeID ID;
1631
+ auto &Context = S.getASTContext ();
1632
+ if (N.getKind () == NormalizedConstraint::ConstraintKind::ConceptId) {
1633
+ ID.AddPointer (static_cast <ConceptIdConstraint &>(N)
1634
+ .getConceptId ()
1635
+ ->getNamedConcept ()
1636
+ ->getCanonicalDecl ());
1637
+ for (auto &ArgLoc : static_cast <ConceptIdConstraint &>(N)
1638
+ .getConceptId ()
1639
+ ->getTemplateArgsAsWritten ()
1640
+ ->arguments ())
1641
+ ArgLoc.getArgument ().Profile (ID, Context);
1642
+
1643
+ Hash = ID.ComputeHash ();
1644
+ if (auto Iter = S.ParameterMappingCache .find (Hash);
1645
+ Iter != S.ParameterMappingCache .end ()) {
1646
+ N.updateParameterMapping (N.mappingOccurenceList (), Iter->second ,
1647
+ N.getUsedTemplateParamList ());
1648
+ return false ;
1649
+ }
1650
+ }
1651
+ // FIXME: Cache for atomic constraints.
1652
+
1627
1653
// TransformTemplateArguments is unable to preserve the source location of a
1628
1654
// pack. The SourceLocation is necessary for the instantiation location.
1629
1655
// FIXME: The BaseLoc will be used as the location of the pack expansion,
@@ -1653,10 +1679,12 @@ substituteParameterMappings(Sema &S, NormalizedConstraintWithParamMapping &N,
1653
1679
// N.updateParameterMapping(
1654
1680
// N.mappingOccurenceList(),
1655
1681
// MutableArrayRef<TemplateArgumentLoc>(TempArgs, SubstArgs.size()));
1656
- N. updateParameterMapping (N. mappingOccurenceList () ,
1657
- MutableArrayRef<TemplateArgumentLoc>(
1658
- TempArgs, CTAI. SugaredConverted . size ()) ,
1682
+ MutableArrayRef<TemplateArgumentLoc> Mapping (TempArgs ,
1683
+ CTAI. SugaredConverted . size ());
1684
+ N. updateParameterMapping (N. mappingOccurenceList (), Mapping ,
1659
1685
N.getUsedTemplateParamList ());
1686
+ if (N.getKind () == NormalizedConstraint::ConstraintKind::ConceptId)
1687
+ S.ParameterMappingCache .insert ({Hash, Mapping});
1660
1688
return false ;
1661
1689
}
1662
1690
0 commit comments