[libcxx-commits] [clang] [libcxx] [Clang] Normalize constraints before checking for satisfaction (PR #141776)

Matheus Izvekov via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 12 13:29:21 PDT 2025


================
@@ -16,130 +16,385 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprConcepts.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Sema/Ownership.h"
 #include "llvm/ADT/FoldingSet.h"
-#include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/SmallVector.h"
 #include <optional>
 #include <utility>
 
 namespace clang {
 class Sema;
+class MultiLevelTemplateArgumentList;
 
-enum { ConstraintAlignment = 8 };
+/// \brief A normalized constraint, as defined in C++ [temp.constr.normal], is
+/// either an atomic constraint, a conjunction of normalized constraints or a
+/// disjunction of normalized constraints.
+struct NormalizedConstraint {
+
+  enum class ConstraintKind : unsigned char {
+    Atomic = 0,
+    ConceptId,
+    FoldExpanded,
+    Compound,
+  };
+
+  enum CompoundConstraintKind : unsigned char {
+    CCK_Conjunction,
+    CCK_Disjunction
+  };
+  enum class FoldOperatorKind : unsigned char { And, Or };
+
+  using OccurenceList = llvm::SmallBitVector;
+
+  friend bool
+  substituteParameterMappings(Sema &S, NormalizedConstraint &N,
+                              const MultiLevelTemplateArgumentList &MLTAL,
+                              const ASTTemplateArgumentListInfo *ArgsAsWritten,
+                              TemplateParameterList *TemplateParams,
+                              const NamedDecl *D);
+
+protected:
+  using ExprOrConcept =
+      llvm::PointerUnion<const Expr *, const ConceptReference *>;
+
+  struct AtomicConstraintBits {
+    LLVM_PREFERRED_TYPE(ConstraintKind)
+    // Kind is the first member of all union members,
+    // as we rely on their initial common sequence.
+    unsigned Kind : 5;
----------------
mizvekov wrote:

```suggestion
    // Kind is the first member of all union members,
    // as we rely on their initial common sequence.
    LLVM_PREFERRED_TYPE(ConstraintKind)
    unsigned Kind : 5;
```

https://github.com/llvm/llvm-project/pull/141776


More information about the libcxx-commits mailing list