@@ -1558,6 +1558,7 @@ const NormalizedConstraint *Sema::getNormalizedAssociatedConstraints(
1558
1558
return NormalizedConstraint::fromAssociatedConstraints (
1559
1559
*this , nullptr , AssociatedConstraints);
1560
1560
1561
+ // FIXME: ConstrainedDeclOrNestedReq is never a NestedRequirement!
1561
1562
const NamedDecl *ND =
1562
1563
ConstrainedDeclOrNestedReq.dyn_cast <const NamedDecl *>();
1563
1564
auto CacheEntry = NormalizationCache.find (ConstrainedDeclOrNestedReq);
@@ -1640,6 +1641,31 @@ substituteParameterMappings(Sema &S, NormalizedConstraintWithParamMapping &N,
1640
1641
{InstLocBegin, InstLocEnd});
1641
1642
if (Inst.isInvalid ())
1642
1643
return true ;
1644
+
1645
+ unsigned Hash;
1646
+ llvm::FoldingSetNodeID ID;
1647
+ auto &Context = S.getASTContext ();
1648
+ if (N.getKind () == NormalizedConstraint::ConstraintKind::ConceptId) {
1649
+ ID.AddPointer (static_cast <ConceptIdConstraint &>(N)
1650
+ .getConceptId ()
1651
+ ->getNamedConcept ()
1652
+ ->getCanonicalDecl ());
1653
+ for (auto &ArgLoc : static_cast <ConceptIdConstraint &>(N)
1654
+ .getConceptId ()
1655
+ ->getTemplateArgsAsWritten ()
1656
+ ->arguments ())
1657
+ ArgLoc.getArgument ().Profile (ID, Context);
1658
+
1659
+ Hash = ID.ComputeHash ();
1660
+ if (auto Iter = S.ParameterMappingCache .find (Hash);
1661
+ Iter != S.ParameterMappingCache .end ()) {
1662
+ N.updateParameterMapping (N.mappingOccurenceList (), Iter->second ,
1663
+ N.getUsedTemplateParamList ());
1664
+ return false ;
1665
+ }
1666
+ }
1667
+ // FIXME: Cache for atomic constraints.
1668
+
1643
1669
// TransformTemplateArguments is unable to preserve the source location of a
1644
1670
// pack. The SourceLocation is necessary for the instantiation location.
1645
1671
// FIXME: The BaseLoc will be used as the location of the pack expansion,
@@ -1669,10 +1695,12 @@ substituteParameterMappings(Sema &S, NormalizedConstraintWithParamMapping &N,
1669
1695
// N.updateParameterMapping(
1670
1696
// N.mappingOccurenceList(),
1671
1697
// MutableArrayRef<TemplateArgumentLoc>(TempArgs, SubstArgs.size()));
1672
- N. updateParameterMapping (N. mappingOccurenceList () ,
1673
- MutableArrayRef<TemplateArgumentLoc>(
1674
- TempArgs, CTAI. SugaredConverted . size ()) ,
1698
+ MutableArrayRef<TemplateArgumentLoc> Mapping (TempArgs ,
1699
+ CTAI. SugaredConverted . size ());
1700
+ N. updateParameterMapping (N. mappingOccurenceList (), Mapping ,
1675
1701
N.getUsedTemplateParamList ());
1702
+ if (N.getKind () == NormalizedConstraint::ConstraintKind::ConceptId)
1703
+ S.ParameterMappingCache .insert ({Hash, Mapping});
1676
1704
return false ;
1677
1705
}
1678
1706
0 commit comments