Author: Younan Zhang
Date: 2026-11-01T02:43:14+08:00
New Revision: c5fcf07c0da69b6dcd11df879c52f879bb743560

URL: 
https://github.com/llvm/llvm-project/commit/c5fcf07c0da69b6dcd11df879c52f879bb743560
DIFF: 
https://github.com/llvm/llvm-project/commit/c5fcf07c0da69b6dcd11df879c52f879bb743560.diff

LOG: [Clang][NFC] Improve ConstraintSatisfaction (#230369)

This reduces size of ConstraintSatisfaction and
ASTConstraintSatisfaction, from 184 bytes to 32 bytes and from 8 bytes
to 4 bytes respectively.

As a result this has to convert SatisfactionCache from a
ContextualFoldingSet to DenseMap to get rid of unused template argument
list on stack.

Hopefully this could improve our RSS consumption when deducing template
arguments (we have to pay an extra ConstraintSatisfaction cost even no
concepts are involved)

Added: 
    

Modified: 
    clang/include/clang/AST/ASTConcept.h
    clang/include/clang/AST/ExprConcepts.h
    clang/include/clang/Sema/Sema.h
    clang/lib/AST/ASTConcept.cpp
    clang/lib/AST/ASTImporter.cpp
    clang/lib/AST/ComputeDependence.cpp
    clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp
    clang/lib/Sema/Sema.cpp
    clang/lib/Sema/SemaConcept.cpp
    clang/lib/Sema/SemaDeclCXX.cpp
    clang/lib/Sema/SemaExprCXX.cpp
    clang/lib/Sema/SemaTemplateInstantiate.cpp
    clang/lib/Sema/TreeTransform.h
    clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/ASTConcept.h 
b/clang/include/clang/AST/ASTConcept.h
index 839146f40445b2..45ac18ae78325a 100644
--- a/clang/include/clang/AST/ASTConcept.h
+++ b/clang/include/clang/AST/ASTConcept.h
@@ -44,31 +44,15 @@ using UnsatisfiedConstraintRecord =
 
 /// The result of a constraint satisfaction check, containing the necessary
 /// information to diagnose an unsatisfied constraint.
-class ConstraintSatisfaction : public llvm::FoldingSetNode {
-  // The template-like entity that 'owns' the constraint checked here (can be a
-  // constrained entity or a concept).
-  const NamedDecl *ConstraintOwner = nullptr;
-  llvm::SmallVector<TemplateArgument, 4> TemplateArgs;
-
+class ConstraintSatisfaction {
 public:
-
-  ConstraintSatisfaction() = default;
-
-  ConstraintSatisfaction(const NamedDecl *ConstraintOwner,
-                         ArrayRef<TemplateArgument> TemplateArgs)
-      : ConstraintOwner(ConstraintOwner), TemplateArgs(TemplateArgs) {}
-
   bool IsSatisfied = false;
   bool ContainsErrors = false;
 
   /// \brief The substituted constraint expr, if the template arguments could 
be
   /// substituted into them, or a diagnostic if substitution resulted in an
   /// invalid expression.
-  llvm::SmallVector<UnsatisfiedConstraintRecord, 4> Details;
-
-  void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) {
-    Profile(ID, C, ConstraintOwner, TemplateArgs);
-  }
+  llvm::SmallVector<UnsatisfiedConstraintRecord, 1> Details;
 
   static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C,
                       const NamedDecl *ConstraintOwner,
@@ -86,13 +70,24 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode {
 /// necessary information to diagnose an unsatisfied constraint.
 ///
 /// This is safe to store in an AST node, as opposed to ConstraintSatisfaction.
-struct ASTConstraintSatisfaction final :
-    llvm::TrailingObjects<ASTConstraintSatisfaction,
-                          UnsatisfiedConstraintRecord> {
-  std::size_t NumRecords;
+class ASTConstraintSatisfaction final
+    : llvm::TrailingObjects<ASTConstraintSatisfaction,
+                            UnsatisfiedConstraintRecord> {
+  friend TrailingObjects;
+  friend class ASTStmtWriter;
+  friend class ASTStmtReader;
+
+  unsigned NumRecords : 30;
   bool IsSatisfied : 1;
   bool ContainsErrors : 1;
 
+  ASTConstraintSatisfaction(const ASTContext &C,
+                            const ConstraintSatisfaction &Satisfaction);
+
+  ASTConstraintSatisfaction(const ASTContext &C,
+                            const ASTConstraintSatisfaction &Satisfaction);
+
+public:
   const UnsatisfiedConstraintRecord *begin() const {
     return getTrailingObjects();
   }
@@ -105,13 +100,15 @@ struct ASTConstraintSatisfaction final :
     return {begin(), end()};
   }
 
-  ASTConstraintSatisfaction(const ASTContext &C,
-                            const ConstraintSatisfaction &Satisfaction);
-  ASTConstraintSatisfaction(const ASTContext &C,
-                            const ASTConstraintSatisfaction &Satisfaction);
+  bool isSatisfied() const { return IsSatisfied; }
+
+  bool containsErrors() const { return ContainsErrors; }
+
+  unsigned record_size() const { return NumRecords; }
 
   static ASTConstraintSatisfaction *
   Create(const ASTContext &C, const ConstraintSatisfaction &Satisfaction);
+
   static ASTConstraintSatisfaction *
   Rebuild(const ASTContext &C, const ASTConstraintSatisfaction &Satisfaction);
 };

diff  --git a/clang/include/clang/AST/ExprConcepts.h 
b/clang/include/clang/AST/ExprConcepts.h
index 18ce5a94ebef3c..7d977069e80964 100644
--- a/clang/include/clang/AST/ExprConcepts.h
+++ b/clang/include/clang/AST/ExprConcepts.h
@@ -128,7 +128,7 @@ class ConceptSpecializationExpr final : public Expr {
   bool isSatisfied() const {
     assert(!isValueDependent() &&
            "isSatisfied called on a dependent ConceptSpecializationExpr");
-    return Satisfaction->IsSatisfied;
+    return Satisfaction->isSatisfied();
   }
 
   /// \brief Get elaborated satisfaction info about the template arguments'
@@ -463,7 +463,7 @@ class NestedRequirement : public Requirement {
       : Requirement(RK_Nested,
                     /*IsDependent=*/false,
                     /*ContainsUnexpandedParameterPack*/ false,
-                    Satisfaction->IsSatisfied),
+                    Satisfaction->isSatisfied()),
         Satisfaction(Satisfaction), HasInvalidConstraint(true),
         InvalidConstraintEntity(InvalidConstraintEntity) {}
 

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7e37f5872166cd..ba215e7e18d7ba 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -115,7 +115,7 @@ struct InlineAsmIdentifierInfo;
 namespace clang {
 class ADLResult;
 class APValue;
-struct ASTConstraintSatisfaction;
+class ASTConstraintSatisfaction;
 class ASTConsumer;
 class ASTContext;
 class ASTDeclReader;
@@ -9011,9 +9011,6 @@ class Sema final : public SemaBase {
   concepts::TypeRequirement *BuildTypeRequirement(
       concepts::Requirement::SubstitutionDiagnostic *SubstDiag);
   concepts::NestedRequirement *BuildNestedRequirement(Expr *E);
-  concepts::NestedRequirement *
-  BuildNestedRequirement(StringRef InvalidConstraintEntity,
-                         const ASTConstraintSatisfaction &Satisfaction);
   ExprResult ActOnRequiresExpr(SourceLocation RequiresKWLoc,
                                RequiresExprBodyDecl *Body,
                                SourceLocation LParenLoc,
@@ -15298,7 +15295,7 @@ class Sema final : public SemaBase {
   /// The key is based on the unsubstituted expression and the parameter
   /// mapping. This lets us not substituting the mapping more than once,
   /// which is (very!) expensive.
-  llvm::DenseMap<llvm::FoldingSetNodeID,
+  llvm::DenseMap<llvm::FoldingSetNodeIDRef,
                  UnsubstitutedConstraintSatisfactionCacheResult>
       UnsubstitutedConstraintSatisfactionCache;
 
@@ -15306,7 +15303,7 @@ class Sema final : public SemaBase {
   /// concepts. Substituting into normalized concepts can be extremely 
expensive
   /// due to the redundancy of template parameters. This cache is intended for
   /// use by TemplateInstantiator to avoid redundant semantic checking.
-  llvm::DenseMap<llvm::FoldingSetNodeID, TemplateArgumentLoc>
+  llvm::DenseMap<llvm::FoldingSetNodeIDRef, TemplateArgumentLoc>
       *CurrentCachedTemplateArgs = nullptr;
 
   /// Caches pairs of template-like decls whose associated constraints were
@@ -15323,7 +15320,7 @@ class Sema final : public SemaBase {
 
   /// Cache whether the associated constraint of a declaration
   /// is satisfied.
-  llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
+  llvm::DenseMap<llvm::FoldingSetNodeIDRef, ConstraintSatisfaction *>
       SatisfactionCache;
 
   // The current stack of constraint satisfactions, so we can exit-early.

diff  --git a/clang/lib/AST/ASTConcept.cpp b/clang/lib/AST/ASTConcept.cpp
index 2b04821a157da4..ee8ef848cebe09 100644
--- a/clang/lib/AST/ASTConcept.cpp
+++ b/clang/lib/AST/ASTConcept.cpp
@@ -43,9 +43,9 @@ CreateUnsatisfiedConstraintRecord(const ASTContext &C,
 
 ASTConstraintSatisfaction::ASTConstraintSatisfaction(
     const ASTContext &C, const ConstraintSatisfaction &Satisfaction)
-    : NumRecords{Satisfaction.Details.size()},
-      IsSatisfied{Satisfaction.IsSatisfied}, ContainsErrors{
-                                                 Satisfaction.ContainsErrors} {
+    : NumRecords(Satisfaction.Details.size()),
+      IsSatisfied(Satisfaction.IsSatisfied),
+      ContainsErrors(Satisfaction.ContainsErrors) {
   for (unsigned I = 0; I < NumRecords; ++I)
     CreateUnsatisfiedConstraintRecord(C, Satisfaction.Details[I],
                                       getTrailingObjects() + I);
@@ -53,9 +53,9 @@ ASTConstraintSatisfaction::ASTConstraintSatisfaction(
 
 ASTConstraintSatisfaction::ASTConstraintSatisfaction(
     const ASTContext &C, const ASTConstraintSatisfaction &Satisfaction)
-    : NumRecords{Satisfaction.NumRecords},
-      IsSatisfied{Satisfaction.IsSatisfied},
-      ContainsErrors{Satisfaction.ContainsErrors} {
+    : NumRecords(Satisfaction.NumRecords),
+      IsSatisfied(Satisfaction.IsSatisfied),
+      ContainsErrors(Satisfaction.ContainsErrors) {
   for (unsigned I = 0; I < NumRecords; ++I)
     CreateUnsatisfiedConstraintRecord(C, *(Satisfaction.begin() + I),
                                       getTrailingObjects() + I);

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 31507f62ad6908..a9e45c2b8c56b5 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1077,8 +1077,8 @@ StringRef ASTNodeImporter::ImportASTStringRef(StringRef 
FromStr) {
 
 Error ASTNodeImporter::ImportConstraintSatisfaction(
     const ASTConstraintSatisfaction &FromSat, ConstraintSatisfaction &ToSat) {
-  ToSat.IsSatisfied = FromSat.IsSatisfied;
-  ToSat.ContainsErrors = FromSat.ContainsErrors;
+  ToSat.IsSatisfied = FromSat.isSatisfied();
+  ToSat.ContainsErrors = FromSat.containsErrors();
   if (!ToSat.IsSatisfied) {
     for (auto Record = FromSat.begin(); Record != FromSat.end(); ++Record) {
       if (const Expr *E = dyn_cast<const Expr *>(*Record)) {

diff  --git a/clang/lib/AST/ComputeDependence.cpp 
b/clang/lib/AST/ComputeDependence.cpp
index 7ea1c67ff77389..c4bf3681a79122 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -955,7 +955,7 @@ ExprDependence 
clang::computeDependence(ConceptSpecializationExpr *E,
   ExprDependence D =
       ValueDependent ? ExprDependence::Value : ExprDependence::None;
   auto Res = D | toExprDependence(TA);
-  if(!ValueDependent && E->getSatisfaction().ContainsErrors)
+  if (!ValueDependent && E->getSatisfaction().containsErrors())
     Res |= ExprDependence::Error;
   return Res;
 }

diff  --git a/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp 
b/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp
index 2db2a2bd32aabe..b7a31b03e6c2d2 100644
--- a/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp
+++ b/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp
@@ -443,7 +443,7 @@ 
TemplateParameterListBuilder::constructConceptSpecializationExpr(
   // Constraint satisfaction is used to construct the
   // ConceptSpecailizationExpr, and represents the 2nd Template Argument,
   // located at the bottom of the sample AST above.
-  const ConstraintSatisfaction CS(CD, {ConceptTA});
+  ConstraintSatisfaction CS;
   TemplateArgumentLoc TAL =
       S.getTrivialTemplateArgumentLoc(ConceptTA, QualType(), SourceLocation());
 

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index b121f17b96a288..fcfcc706d2f9d3 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -329,7 +329,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer 
&consumer,
       GlobalNewDeleteDeclared(false), DisableTypoCorrection(false),
       TyposCorrected(0), IsBuildingRecoveryCallExpr(false),
       CurrentInstantiationScope(nullptr), NonInstantiationEntries(0),
-      ArgPackSubstIndex(std::nullopt), SatisfactionCache(Context) {
+      ArgPackSubstIndex(std::nullopt) {
   assert(pp.TUKind == TUKind);
   TUScope = nullptr;
 
@@ -627,11 +627,7 @@ Sema::~Sema() {
     ExternalSema->ForgetSema();
 
   // Delete cached satisfactions.
-  std::vector<ConstraintSatisfaction *> Satisfactions;
-  Satisfactions.reserve(SatisfactionCache.size());
-  for (auto &Node : SatisfactionCache)
-    Satisfactions.push_back(&Node);
-  for (auto *Node : Satisfactions)
+  for (auto [_, Node] : SatisfactionCache)
     delete Node;
 
   threadSafety::threadSafetyCleanup(ThreadSafetyDeclCache);

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 2c812cde72f66e..72d2ad4a782e20 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -576,7 +576,7 @@ class ConstraintSatisfactionChecker {
 
   // This is for TemplateInstantiator to not instantiate the same template
   // parameter mapping many times, in order to improve substitution 
performance.
-  llvm::DenseMap<llvm::FoldingSetNodeID, TemplateArgumentLoc>
+  llvm::DenseMap<llvm::FoldingSetNodeIDRef, TemplateArgumentLoc>
       CachedTemplateArgs;
 
 private:
@@ -607,9 +607,11 @@ class ConstraintSatisfactionChecker {
       auto &Cached = Iter->second.Satisfaction;
       Satisfaction.ContainsErrors = Cached.ContainsErrors;
       Satisfaction.IsSatisfied = Cached.IsSatisfied;
-      Satisfaction.Details.insert(Satisfaction.Details.begin() +
-                                      PreviousDetailsSize,
-                                  Cached.Details.begin(), 
Cached.Details.end());
+      SmallVector<UnsatisfiedConstraintRecord, 1> Details(
+          Satisfaction.Details.begin(),
+          Satisfaction.Details.begin() + PreviousDetailsSize);
+      Details.append(Cached.Details.begin(), Cached.Details.end());
+      std::swap(Details, Satisfaction.Details);
       return &Iter->second;
     }
 
@@ -623,8 +625,8 @@ class ConstraintSatisfactionChecker {
                                             PreviousDetailsSize,
                                         Satisfaction.Details.end());
       Cache.SubstExpr = E;
-      Checker.S.UnsubstitutedConstraintSatisfactionCache.insert(
-          {ID, std::move(Cache)});
+      Checker.S.UnsubstitutedConstraintSatisfactionCache.try_emplace(
+          ID.Intern(Checker.S.BumpAlloc), std::move(Cache));
       return E;
     }
   };
@@ -1334,14 +1336,12 @@ bool Sema::CheckConstraintSatisfaction(
 
   llvm::FoldingSetNodeID ID;
   ConstraintSatisfaction::Profile(ID, Context, Owner, FlattenedArgs);
-  llvm::FoldingSetInsertToken Token;
-  if (auto *Cached = SatisfactionCache.lookup(ID, Token)) {
+  if (auto *Cached = SatisfactionCache.lookup(ID)) {
     OutSatisfaction = *Cached;
     return false;
   }
 
-  auto Satisfaction =
-      std::make_unique<ConstraintSatisfaction>(Owner, FlattenedArgs);
+  auto Satisfaction = std::make_unique<ConstraintSatisfaction>();
   if (::CheckConstraintSatisfaction(
           *this, Template, AssociatedConstraints, TemplateArgsLists,
           TemplateIDRange, *Satisfaction, ConvertedExpr, TopLevelConceptId)) {
@@ -1349,23 +1349,13 @@ bool Sema::CheckConstraintSatisfaction(
     return true;
   }
 
-  if (auto *Cached = SatisfactionCache.lookup(ID, Token)) {
-    // The evaluation of this constraint resulted in us trying to re-evaluate 
it
-    // recursively. This isn't really possible, except we try to form a
-    // RecoveryExpr as a part of the evaluation.  If this is the case, just
-    // return the 'cached' version (which will have the same result), and save
-    // ourselves the extra-insert. If it ever becomes possible to legitimately
-    // recursively check a constraint, we should skip checking the 'inner' one
-    // above, and replace the cached version with this one, as it would be more
-    // specific.
-    OutSatisfaction = *Cached;
-    return false;
-  }
-
   // Else we can simply add this satisfaction to the list.
   OutSatisfaction = *Satisfaction;
   // Note that entries of SatisfactionCache are deleted in Sema's destructor.
-  SatisfactionCache.insert(Satisfaction.release());
+  auto [Iter, Inserted] =
+      SatisfactionCache.try_emplace(ID.Intern(BumpAlloc), nullptr);
+  if (Inserted)
+    Iter->second = Satisfaction.release();
   return false;
 }
 
@@ -2069,7 +2059,7 @@ void Sema::DiagnoseUnsatisfiedConstraint(
   const ASTConstraintSatisfaction &Satisfaction =
       ConstraintExpr->getSatisfaction();
 
-  assert(!Satisfaction.IsSatisfied &&
+  assert(!Satisfaction.isSatisfied() &&
          "Attempted to diagnose a satisfied constraint");
 
   ::DiagnoseUnsatisfiedConstraint(*this, Satisfaction.records(),

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 7670b0fb22c01e..f2a8bd452a6ea9 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -18148,7 +18148,7 @@ Decl *Sema::BuildStaticAssertDeclaration(SourceLocation 
StaticAssertLoc,
               dyn_cast_or_null<ConceptSpecializationExpr>(InnerCond)) {
         const ASTConstraintSatisfaction &Satisfaction =
             ConceptIDExpr->getSatisfaction();
-        if (!Satisfaction.ContainsErrors || Satisfaction.NumRecords) {
+        if (!Satisfaction.containsErrors() || Satisfaction.record_size()) {
           Diag(AssertExpr->getBeginLoc(), diag::err_static_assert_failed)
               << !HasMessage << Msg.str() << AssertExpr->getSourceRange();
           // Drill down into concept specialization expressions to see why they

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 1e422da2e460d2..5d64b61a32ba2a 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -8126,7 +8126,7 @@ Sema::BuildExprRequirement(
     if (!HasError) {
       SubstitutedConstraintExpr =
           cast<ConceptSpecializationExpr>(Constraint.get());
-      if (SubstitutedConstraintExpr->getSatisfaction().ContainsErrors)
+      if (SubstitutedConstraintExpr->getSatisfaction().containsErrors())
         HasError = true;
     }
     if (HasError) {
@@ -8196,14 +8196,6 @@ Sema::BuildNestedRequirement(Expr *Constraint) {
                                                    Satisfaction);
 }
 
-concepts::NestedRequirement *
-Sema::BuildNestedRequirement(StringRef InvalidConstraintEntity,
-                       const ASTConstraintSatisfaction &Satisfaction) {
-  return new (Context) concepts::NestedRequirement(
-      InvalidConstraintEntity,
-      ASTConstraintSatisfaction::Rebuild(Context, Satisfaction));
-}
-
 RequiresExprBodyDecl *
 Sema::ActOnStartRequiresExpr(SourceLocation RequiresKWLoc,
                              ArrayRef<ParmVarDecl *> LocalParameters,

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index c71291cb4fa238..08ee65c772fb5c 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1324,7 +1324,7 @@ namespace {
     bool BailOutOnIncomplete;
 
     std::optional<llvm::FoldingSetNodeID> TemplateArgsHashValue;
-    llvm::DenseMap<llvm::FoldingSetNodeID, TemplateArgumentLoc>
+    llvm::DenseMap<llvm::FoldingSetNodeIDRef, TemplateArgumentLoc>
         *CurrentCachedTemplateArgs = nullptr;
 
     // While the parameters of a prototype are being substituted, the vector is
@@ -1365,7 +1365,7 @@ namespace {
     TemplateInstantiator(
         ForParameterMappingSubstitution_t, Sema &SemaRef, SourceLocation Loc,
         const MultiLevelTemplateArgumentList &TemplateArgs,
-        llvm::DenseMap<llvm::FoldingSetNodeID, TemplateArgumentLoc> *Cache)
+        llvm::DenseMap<llvm::FoldingSetNodeIDRef, TemplateArgumentLoc> *Cache)
         : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
           EvaluateLambdaConstraint(true), BailOutOnIncomplete(false),
           CurrentCachedTemplateArgs(Cache) {
@@ -1657,7 +1657,7 @@ namespace {
         }
         bool Ret = inherited::TransformTemplateArgument(Input, Output, Uneval);
         if (!Ret)
-          Cache->insert({ID, Output});
+          Cache->try_emplace(ID.Intern(SemaRef.BumpAlloc), Output);
         return Ret;
       }
       switch (Arg.getKind()) {

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 7b5ee7b7068ae4..f22951b8ed0fa8 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -3880,8 +3880,8 @@ class TreeTransform {
   concepts::NestedRequirement *
   RebuildNestedRequirement(StringRef InvalidConstraintEntity,
                            const ASTConstraintSatisfaction &Satisfaction) {
-    return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
-                                          Satisfaction);
+    return new (getSema().Context)
+        concepts::NestedRequirement(InvalidConstraintEntity, &Satisfaction);
   }
 
   concepts::NestedRequirement *RebuildNestedRequirement(Expr *Constraint) {

diff  --git a/clang/lib/Serialization/ASTWriterStmt.cpp 
b/clang/lib/Serialization/ASTWriterStmt.cpp
index c6f04336f806ee..c6e74fd19750a4 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -504,10 +504,10 @@ void 
ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
 static void
 addConstraintSatisfaction(ASTRecordWriter &Record,
                           const ASTConstraintSatisfaction &Satisfaction) {
-  Record.push_back(Satisfaction.IsSatisfied);
-  Record.push_back(Satisfaction.ContainsErrors);
-  if (!Satisfaction.IsSatisfied) {
-    Record.push_back(Satisfaction.NumRecords);
+  Record.push_back(Satisfaction.isSatisfied());
+  Record.push_back(Satisfaction.containsErrors());
+  if (!Satisfaction.isSatisfied()) {
+    Record.push_back(Satisfaction.record_size());
     for (const auto &DetailRecord : Satisfaction) {
       if (auto *Diag = dyn_cast<const ConstraintSubstitutionDiagnostic *>(
               DetailRecord)) {


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to