@@ -453,6 +453,7 @@ static ExprResult calculateConstraintSatisfaction(
453
453
Sema::InstantiatingTemplate Inst (
454
454
S, AtomicExpr->getBeginLoc (),
455
455
Sema::InstantiatingTemplate::ConstraintSubstitution{},
456
+ // FIXME: improve const-correctness of InstantiatingTemplate
456
457
const_cast <NamedDecl *>(Template), Info,
457
458
AtomicExpr->getSourceRange ());
458
459
if (Inst.isInvalid ())
@@ -1435,9 +1436,9 @@ void Sema::DiagnoseUnsatisfiedConstraint(
1435
1436
}
1436
1437
}
1437
1438
1438
- const NormalizedConstraint *
1439
- Sema::getNormalizedAssociatedConstraints (
1440
- NamedDecl *ConstrainedDecl, ArrayRef<const Expr *> AssociatedConstraints) {
1439
+ const NormalizedConstraint *Sema::getNormalizedAssociatedConstraints (
1440
+ const NamedDecl *ConstrainedDecl,
1441
+ ArrayRef<const Expr *> AssociatedConstraints) {
1441
1442
// In case the ConstrainedDecl comes from modules, it is necessary to use
1442
1443
// the canonical decl to avoid different atomic constraints with the 'same'
1443
1444
// declarations.
@@ -1461,7 +1462,7 @@ Sema::getNormalizedAssociatedConstraints(
1461
1462
}
1462
1463
1463
1464
const NormalizedConstraint *clang::getNormalizedAssociatedConstraints (
1464
- Sema &S, NamedDecl *ConstrainedDecl,
1465
+ Sema &S, const NamedDecl *ConstrainedDecl,
1465
1466
ArrayRef<const Expr *> AssociatedConstraints) {
1466
1467
return S.getNormalizedAssociatedConstraints (ConstrainedDecl,
1467
1468
AssociatedConstraints);
@@ -1527,7 +1528,8 @@ substituteParameterMappings(Sema &S, NormalizedConstraint &N,
1527
1528
Sema::InstantiatingTemplate Inst (
1528
1529
S, InstLocBegin,
1529
1530
Sema::InstantiatingTemplate::ParameterMappingSubstitution{},
1530
- Atomic.ConstraintDecl , {InstLocBegin, InstLocEnd});
1531
+ const_cast <NamedDecl *>(Atomic.ConstraintDecl ),
1532
+ {InstLocBegin, InstLocEnd});
1531
1533
if (Inst.isInvalid ())
1532
1534
return true ;
1533
1535
if (S.SubstTemplateArguments (*Atomic.ParameterMapping , MLTAL, SubstArgs))
@@ -1591,7 +1593,7 @@ NormalizedConstraint &NormalizedConstraint::getRHS() const {
1591
1593
}
1592
1594
1593
1595
std::optional<NormalizedConstraint>
1594
- NormalizedConstraint::fromConstraintExprs (Sema &S, NamedDecl *D,
1596
+ NormalizedConstraint::fromConstraintExprs (Sema &S, const NamedDecl *D,
1595
1597
ArrayRef<const Expr *> E) {
1596
1598
assert (E.size () != 0 );
1597
1599
auto Conjunction = fromConstraintExpr (S, D, E[0 ]);
@@ -1608,7 +1610,8 @@ NormalizedConstraint::fromConstraintExprs(Sema &S, NamedDecl *D,
1608
1610
}
1609
1611
1610
1612
std::optional<NormalizedConstraint>
1611
- NormalizedConstraint::fromConstraintExpr (Sema &S, NamedDecl *D, const Expr *E) {
1613
+ NormalizedConstraint::fromConstraintExpr (Sema &S, const NamedDecl *D,
1614
+ const Expr *E) {
1612
1615
assert (E != nullptr );
1613
1616
1614
1617
// C++ [temp.constr.normal]p1.1
@@ -1637,8 +1640,9 @@ NormalizedConstraint::fromConstraintExpr(Sema &S, NamedDecl *D, const Expr *E) {
1637
1640
{
1638
1641
Sema::InstantiatingTemplate Inst (
1639
1642
S, CSE->getExprLoc (),
1640
- Sema::InstantiatingTemplate::ConstraintNormalization{}, D,
1641
- CSE->getSourceRange ());
1643
+ Sema::InstantiatingTemplate::ConstraintNormalization{},
1644
+ // FIXME: improve const-correctness of InstantiatingTemplate
1645
+ const_cast <NamedDecl *>(D), CSE->getSourceRange ());
1642
1646
if (Inst.isInvalid ())
1643
1647
return std::nullopt;
1644
1648
// C++ [temp.constr.normal]p1.1
@@ -1726,9 +1730,9 @@ bool FoldExpandedConstraint::AreCompatibleForSubsumption(
1726
1730
return false ;
1727
1731
}
1728
1732
1729
- bool Sema::IsAtLeastAsConstrained (NamedDecl *D1,
1733
+ bool Sema::IsAtLeastAsConstrained (const NamedDecl *D1,
1730
1734
MutableArrayRef<const Expr *> AC1,
1731
- NamedDecl *D2,
1735
+ const NamedDecl *D2,
1732
1736
MutableArrayRef<const Expr *> AC2,
1733
1737
bool &Result) {
1734
1738
#ifndef NDEBUG
@@ -1755,7 +1759,7 @@ bool Sema::IsAtLeastAsConstrained(NamedDecl *D1,
1755
1759
return false ;
1756
1760
}
1757
1761
1758
- std::pair<NamedDecl *, NamedDecl *> Key{D1, D2};
1762
+ std::pair<const NamedDecl *, const NamedDecl *> Key{D1, D2};
1759
1763
auto CacheEntry = SubsumptionCache.find (Key);
1760
1764
if (CacheEntry != SubsumptionCache.end ()) {
1761
1765
Result = CacheEntry->second ;
@@ -1789,7 +1793,7 @@ bool Sema::IsAtLeastAsConstrained(NamedDecl *D1,
1789
1793
}
1790
1794
1791
1795
bool Sema::MaybeEmitAmbiguousAtomicConstraintsDiagnostic (
1792
- NamedDecl *D1, ArrayRef<const Expr *> AC1, NamedDecl *D2,
1796
+ const NamedDecl *D1, ArrayRef<const Expr *> AC1, const NamedDecl *D2,
1793
1797
ArrayRef<const Expr *> AC2) {
1794
1798
1795
1799
if (isSFINAEContext ())
@@ -2055,7 +2059,7 @@ FormulaType SubsumptionChecker::Normalize(const NormalizedConstraint &NC) {
2055
2059
FormulaType Res;
2056
2060
2057
2061
auto Add = [&, this ](Clause C) {
2058
- // Sort each clause and remove duplicates for faster comparisons
2062
+ // Sort each clause and remove duplicates for faster comparisons.
2059
2063
llvm::sort (C);
2060
2064
C.erase (llvm::unique (C), C.end ());
2061
2065
AddUniqueClauseToFormula (Res, std::move (C));
@@ -2102,9 +2106,9 @@ void SubsumptionChecker::AddUniqueClauseToFormula(Formula &F, Clause C) {
2102
2106
F.push_back (C);
2103
2107
}
2104
2108
2105
- std::optional<bool > SubsumptionChecker::Subsumes (NamedDecl *DP,
2109
+ std::optional<bool > SubsumptionChecker::Subsumes (const NamedDecl *DP,
2106
2110
ArrayRef<const Expr *> P,
2107
- NamedDecl *DQ,
2111
+ const NamedDecl *DQ,
2108
2112
ArrayRef<const Expr *> Q) {
2109
2113
const NormalizedConstraint *PNormalized =
2110
2114
getNormalizedAssociatedConstraints (SemaRef, DP, P);
0 commit comments