@@ -28,10 +28,20 @@ namespace clang {
2828
2929class ConceptDecl ;
3030class TemplateDecl ;
31+ class ConceptReference ;
3132class Expr ;
3233class NamedDecl ;
3334struct PrintingPolicy ;
3435
36+ // / Unsatisfied constraint expressions if the template arguments could be
37+ // / substituted into them, or a diagnostic if substitution resulted in
38+ // / an invalid expression.
39+ // /
40+ using ConstraintSubstitutionDiagnostic = std::pair<SourceLocation, StringRef>;
41+ using UnsatisfiedConstraintRecord =
42+ llvm::PointerUnion<const Expr *, const ConceptReference *,
43+ const ConstraintSubstitutionDiagnostic *>;
44+
3545// / The result of a constraint satisfaction check, containing the necessary
3646// / information to diagnose an unsatisfied constraint.
3747class ConstraintSatisfaction : public llvm ::FoldingSetNode {
@@ -48,16 +58,13 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode {
4858 ArrayRef<TemplateArgument> TemplateArgs)
4959 : ConstraintOwner(ConstraintOwner), TemplateArgs(TemplateArgs) {}
5060
51- using SubstitutionDiagnostic = std::pair<SourceLocation, StringRef>;
52- using Detail = llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>;
53-
5461 bool IsSatisfied = false ;
5562 bool ContainsErrors = false ;
5663
5764 // / \brief The substituted constraint expr, if the template arguments could be
5865 // / substituted into them, or a diagnostic if substitution resulted in an
5966 // / invalid expression.
60- llvm::SmallVector<Detail , 4 > Details;
67+ llvm::SmallVector<UnsatisfiedConstraintRecord , 4 > Details;
6168
6269 void Profile (llvm::FoldingSetNodeID &ID, const ASTContext &C) {
6370 Profile (ID, C, ConstraintOwner, TemplateArgs);
@@ -69,19 +76,12 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode {
6976
7077 bool HasSubstitutionFailure () {
7178 for (const auto &Detail : Details)
72- if (Detail.dyn_cast <SubstitutionDiagnostic *>())
79+ if (Detail.dyn_cast <const ConstraintSubstitutionDiagnostic *>())
7380 return true ;
7481 return false ;
7582 }
7683};
7784
78- // / Pairs of unsatisfied atomic constraint expressions along with the
79- // / substituted constraint expr, if the template arguments could be
80- // / substituted into them, or a diagnostic if substitution resulted in
81- // / an invalid expression.
82- using UnsatisfiedConstraintRecord =
83- llvm::PointerUnion<Expr *, std::pair<SourceLocation, StringRef> *>;
84-
8585// / \brief The result of a constraint satisfaction check, containing the
8686// / necessary information to diagnose an unsatisfied constraint.
8787// /
@@ -101,6 +101,10 @@ struct ASTConstraintSatisfaction final :
101101 return getTrailingObjects () + NumRecords;
102102 }
103103
104+ ArrayRef<UnsatisfiedConstraintRecord> records () const {
105+ return {begin (), end ()};
106+ }
107+
104108 ASTConstraintSatisfaction (const ASTContext &C,
105109 const ConstraintSatisfaction &Satisfaction);
106110 ASTConstraintSatisfaction (const ASTContext &C,
@@ -282,6 +286,11 @@ class TypeConstraint {
282286 }
283287};
284288
289+ // / Insertion operator for diagnostics. This allows sending ConceptReferences's
290+ // / into a diagnostic with <<.
291+ const StreamingDiagnostic &operator <<(const StreamingDiagnostic &DB,
292+ const ConceptReference *C);
293+
285294} // clang
286295
287296#endif // LLVM_CLANG_AST_ASTCONCEPT_H
0 commit comments