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"
38 : ConstraintExpr(ConstraintExpr), ConstraintDecl(ConstraintDecl) {};
42 if (!ParameterMapping != !
Other.ParameterMapping)
44 if (!ParameterMapping)
46 if (ParameterMapping->size() !=
Other.ParameterMapping->size())
49 for (
unsigned I = 0, S = ParameterMapping->size(); I < S; ++I) {
50 llvm::FoldingSetNodeID IDA, IDB;
51 C.getCanonicalTemplateArgument((*ParameterMapping)[I].
getArgument())
53 C.getCanonicalTemplateArgument((*
Other.ParameterMapping)[I].getArgument())
62struct alignas(ConstraintAlignment) NormalizedConstraintPair;
63struct alignas(ConstraintAlignment) FoldExpandedConstraint;
88 Constraint(
Other.Constraint) {
89 Other.Constraint =
nullptr;
100 bool isAtomic()
const {
return llvm::isa<AtomicConstraint *>(Constraint); }
102 return llvm::isa<FoldExpandedConstraint *>(Constraint);
104 bool isCompound()
const {
return llvm::isa<CompoundConstraint>(Constraint); }
106 CompoundConstraintKind getCompoundKind()
const;
116 static std::optional<NormalizedConstraint>
119 static std::optional<NormalizedConstraint>
134 :
Kind(K), Constraint(
std::move(C)), Pattern(Pattern) {};
140const NormalizedConstraint *getNormalizedAssociatedConstraints(
141 Sema &S,
const NamedDecl *ConstrainedDecl,
142 ArrayRef<AssociatedConstraint> AssociatedConstraints);
153 std::optional<bool> Subsumes(
const NamedDecl *DP,
173 LLVM_PREFERRED_TYPE(
Kind)
176 bool operator==(
const Literal &Other)
const {
return Value == Other.Value; }
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.
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
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 establishes subsumption between two set of constraints.
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
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
llvm::PointerIntPair< NormalizedConstraintPair *, 1, CompoundConstraintKind > CompoundConstraint
NormalizedConstraint(NormalizedConstraint &&Other)
NormalizedConstraint(AtomicConstraint *C)
NormalizedConstraint & operator=(const NormalizedConstraint &Other)=delete
NormalizedConstraint & operator=(NormalizedConstraint &&Other)
NormalizedConstraint(FoldExpandedConstraint *C)