13#ifndef LLVM_CLANG_SEMA_SEMACONCEPT_H
14#define LLVM_CLANG_SEMA_SEMACONCEPT_H
20#include "llvm/ADT/FoldingSet.h"
21#include "llvm/ADT/PointerUnion.h"
22#include "llvm/ADT/STLFunctionalExtras.h"
23#include "llvm/ADT/SmallVector.h"
50 llvm::FoldingSetNodeID IDA, IDB;
53 C.getCanonicalTemplateArgument((*
Other.ParameterMapping)[I].getArgument())
62struct alignas(ConstraintAlignment) NormalizedConstraintPair;
63struct alignas(ConstraintAlignment) FoldExpandedConstraint;
89 Other.Constraint =
nullptr;
102 return llvm::isa<FoldExpandedConstraint *>(
Constraint);
106 CompoundConstraintKind getCompoundKind()
const;
116 static std::optional<NormalizedConstraint>
119 static std::optional<NormalizedConstraint>
140const NormalizedConstraint *getNormalizedAssociatedConstraints(
141 Sema &S,
const NamedDecl *ConstrainedDecl,
153 std::optional<bool> Subsumes(
const NamedDecl *DP,
170 enum Kind {
Atomic, FoldExpanded };
173 LLVM_PREFERRED_TYPE(Kind)
176 bool operator==(
const Literal &Other)
const {
return Value == Other.Value; }
179 using Clause = llvm::SmallVector<Literal>;
180 using Formula = llvm::SmallVector<Clause, 5>;
182 struct CNFFormula : Formula {
183 static constexpr auto Kind = NormalizedConstraint::CCK_Conjunction;
184 using Formula::Formula;
186 struct DNFFormula : Formula {
187 static constexpr auto Kind = NormalizedConstraint::CCK_Disjunction;
188 using Formula::Formula;
191 struct MappedAtomicConstraint {
192 AtomicConstraint *Constraint;
196 struct FoldExpendedConstraintKey {
197 FoldExpandedConstraint::FoldOperatorKind
Kind;
198 AtomicConstraint *Constraint;
202 llvm::DenseMap<
const Expr *, llvm::SmallDenseMap<llvm::FoldingSetNodeID,
203 MappedAtomicConstraint>>
206 llvm::DenseMap<const Expr *, std::vector<FoldExpendedConstraintKey>> FoldMap;
210 llvm::DenseMap<uint16_t, void *> ReverseMap;
215 std::pair<const FoldExpandedConstraint *, const FoldExpandedConstraint *>,
217 FoldSubsumptionCache;
224 bool Subsumes(
const DNFFormula &P,
const CNFFormula &Q);
225 bool Subsumes(Literal A, Literal B);
226 bool Subsumes(
const FoldExpandedConstraint *A,
227 const FoldExpandedConstraint *B);
228 bool DNFSubsumes(
const Clause &P,
const Clause &Q);
230 CNFFormula CNF(
const NormalizedConstraint &C);
231 DNFFormula DNF(
const NormalizedConstraint &C);
233 template <
typename FormulaType>
234 FormulaType Normalize(
const NormalizedConstraint &C);
235 void AddUniqueClauseToFormula(Formula &F, Clause C);
237 Literal find(AtomicConstraint *);
238 Literal find(FoldExpandedConstraint *);
240 uint16_t getNewLiteralId();
This file provides AST data structures related to concepts.
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
Defines the clang::SourceLocation class and associated facilities.
static const TemplateArgument & getArgument(const TemplateArgument &A)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
This represents one expression.
This represents a decl that may have a name.
Sema - This implements semantic analysis and AST building for C.
SubsumptionChecker(Sema &SemaRef, SubsumptionCallable Callable={})
llvm::function_ref< bool( const AtomicConstraint &, const AtomicConstraint &)> SubsumptionCallable
uint32_t Literal
Literals are represented as positive integers.
The JSON file list parser is used to communicate input to InstallAPI.
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
@ Other
Other implicit parameter.
std::optional< ArrayRef< TemplateArgumentLoc > > ParameterMapping
const NamedDecl * ConstraintDecl
bool hasMatchingParameterMapping(ASTContext &C, const AtomicConstraint &Other) const
AtomicConstraint(const Expr *ConstraintExpr, const NamedDecl *ConstraintDecl)
const Expr * ConstraintExpr
NormalizedConstraint Constraint
enum clang::FoldExpandedConstraint::FoldOperatorKind Kind
FoldExpandedConstraint(FoldOperatorKind K, NormalizedConstraint C, const Expr *Pattern)
A normalized constraint, as defined in C++ [temp.constr.normal], is either an atomic constraint,...
llvm::PointerUnion< AtomicConstraint *, FoldExpandedConstraint *, CompoundConstraint > Constraint
bool isFoldExpanded() const
NormalizedConstraint(NormalizedConstraint &&Other)
NormalizedConstraint(AtomicConstraint *C)
NormalizedConstraint & operator=(const NormalizedConstraint &Other)=delete
NormalizedConstraint & operator=(NormalizedConstraint &&Other)
llvm::PointerIntPair< NormalizedConstraintPair *, 1, CompoundConstraintKind > CompoundConstraint
NormalizedConstraint(FoldExpandedConstraint *C)