Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -13339,7 +13339,7 @@ class Sema final : public SemaBase {
bool SubstTemplateArgumentsInParameterMapping(
ArrayRef<TemplateArgumentLoc> Args, SourceLocation BaseLoc,
const MultiLevelTemplateArgumentList &TemplateArgs,
TemplateArgumentListInfo &Out);
TemplateArgumentListInfo &Out, bool BuildPackExpansionTypes);

/// Retrieve the template argument list(s) that should be used to
/// instantiate the definition of the given declaration.
Expand Down Expand Up @@ -13799,15 +13799,15 @@ class Sema final : public SemaBase {
}

/// Determine whether we are currently performing constraint substitution.
// FIXME: Rename it
bool inConstraintSubstitution() const {
return !CodeSynthesisContexts.empty() &&
CodeSynthesisContexts.back().InConstraintSubstitution;
}

bool inParameterMappingSubstitution() const {
return !CodeSynthesisContexts.empty() &&
CodeSynthesisContexts.back().InParameterMappingSubstitution;
CodeSynthesisContexts.back().InParameterMappingSubstitution &&
!inConstraintSubstitution();
}

using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
Expand Down Expand Up @@ -14819,6 +14819,9 @@ class Sema final : public SemaBase {
const NamedDecl *D1, ArrayRef<AssociatedConstraint> AC1,
const NamedDecl *D2, ArrayRef<AssociatedConstraint> AC2);

llvm::DenseMap<unsigned, CachedConceptIdConstraint>
ConceptIdSatisfactionCache;

private:
/// Caches pairs of template-like decls whose associated constraints were
/// checked for subsumption and whether or not the first's constraints did in
Expand Down
24 changes: 18 additions & 6 deletions clang/include/clang/Sema/SemaConcept.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "clang/AST/ExprConcepts.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/UnsignedOrNone.h"
#include "clang/Sema/Ownership.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/STLForwardCompat.h"
Expand Down Expand Up @@ -67,7 +68,7 @@ struct NormalizedConstraint {
unsigned Kind : 5;
unsigned Placeholder : 1;
unsigned PackSubstitutionIndex : 26;
llvm::SmallBitVector Indexes;
OccurenceList Indexes;
TemplateArgumentLoc *Args;
TemplateParameterList *ParamList;
ExprOrConcept ConstraintExpr;
Expand All @@ -84,6 +85,7 @@ struct NormalizedConstraint {
TemplateArgumentLoc *Args;
TemplateParameterList *ParamList;
const Expr *Pattern;
const NamedDecl *ConstraintDecl;
NormalizedConstraint *Constraint;
};

Expand Down Expand Up @@ -128,14 +130,16 @@ struct NormalizedConstraint {
ConstraintDecl} {}

NormalizedConstraint(const Expr *Pattern, FoldOperatorKind OpKind,
NormalizedConstraint *Constraint)
NormalizedConstraint *Constraint,
const NamedDecl *ConstraintDecl)
: FoldExpanded{llvm::to_underlying(ConstraintKind::FoldExpanded),
llvm::to_underlying(OpKind),
/*Placeholder=*/0,
/*Indexes=*/{},
/*Args=*/nullptr,
/*ParamList=*/nullptr,
Pattern,
ConstraintDecl,
Constraint} {}

NormalizedConstraint(const ConceptReference *ConceptId,
Expand Down Expand Up @@ -323,14 +327,17 @@ class AtomicConstraint : public NormalizedConstraintWithParamMapping {
}
};

class FoldExpandedConstraint : public NormalizedConstraint {
using NormalizedConstraint::NormalizedConstraint;
class FoldExpandedConstraint : public NormalizedConstraintWithParamMapping {
using NormalizedConstraintWithParamMapping::
NormalizedConstraintWithParamMapping;

public:
static FoldExpandedConstraint *Create(ASTContext &Ctx, const Expr *Pattern,
const NamedDecl *ConstraintDecl,
FoldOperatorKind OpKind,
NormalizedConstraint *Constraint) {
return new (Ctx) FoldExpandedConstraint(Pattern, OpKind, Constraint);
return new (Ctx)
FoldExpandedConstraint(Pattern, OpKind, Constraint, ConstraintDecl);
}

using NormalizedConstraint::hasMatchingParameterMapping;
Expand Down Expand Up @@ -383,6 +390,11 @@ class ConceptIdConstraint : public NormalizedConstraintWithParamMapping {
NormalizedConstraint &getNormalizedConstraint() { return *ConceptId.Sub; }
};

struct CachedConceptIdConstraint {
ExprResult SubstExpr;
ConstraintSatisfaction Satisfaction;
};

/// \brief SubsumptionChecker establishes subsumption
/// between two set of constraints.
class SubsumptionChecker {
Expand Down Expand Up @@ -482,6 +494,6 @@ class SubsumptionChecker {
uint16_t getNewLiteralId();
};

} // clang
} // namespace clang

#endif // LLVM_CLANG_SEMA_SEMACONCEPT_H
Loading