@@ -28,10 +28,20 @@ namespace clang {
28
28
29
29
class ConceptDecl ;
30
30
class TemplateDecl ;
31
+ class ConceptReference ;
31
32
class Expr ;
32
33
class NamedDecl ;
33
34
struct PrintingPolicy ;
34
35
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
+
35
45
// / The result of a constraint satisfaction check, containing the necessary
36
46
// / information to diagnose an unsatisfied constraint.
37
47
class ConstraintSatisfaction : public llvm ::FoldingSetNode {
@@ -48,16 +58,13 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode {
48
58
ArrayRef<TemplateArgument> TemplateArgs)
49
59
: ConstraintOwner(ConstraintOwner), TemplateArgs(TemplateArgs) {}
50
60
51
- using SubstitutionDiagnostic = std::pair<SourceLocation, StringRef>;
52
- using Detail = llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>;
53
-
54
61
bool IsSatisfied = false ;
55
62
bool ContainsErrors = false ;
56
63
57
64
// / \brief The substituted constraint expr, if the template arguments could be
58
65
// / substituted into them, or a diagnostic if substitution resulted in an
59
66
// / invalid expression.
60
- llvm::SmallVector<Detail , 4 > Details;
67
+ llvm::SmallVector<UnsatisfiedConstraintRecord , 4 > Details;
61
68
62
69
void Profile (llvm::FoldingSetNodeID &ID, const ASTContext &C) {
63
70
Profile (ID, C, ConstraintOwner, TemplateArgs);
@@ -69,19 +76,12 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode {
69
76
70
77
bool HasSubstitutionFailure () {
71
78
for (const auto &Detail : Details)
72
- if (Detail.dyn_cast <SubstitutionDiagnostic *>())
79
+ if (Detail.dyn_cast <const ConstraintSubstitutionDiagnostic *>())
73
80
return true ;
74
81
return false ;
75
82
}
76
83
};
77
84
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
-
85
85
// / \brief The result of a constraint satisfaction check, containing the
86
86
// / necessary information to diagnose an unsatisfied constraint.
87
87
// /
@@ -101,6 +101,10 @@ struct ASTConstraintSatisfaction final :
101
101
return getTrailingObjects () + NumRecords;
102
102
}
103
103
104
+ ArrayRef<UnsatisfiedConstraintRecord> records () const {
105
+ return {begin (), end ()};
106
+ }
107
+
104
108
ASTConstraintSatisfaction (const ASTContext &C,
105
109
const ConstraintSatisfaction &Satisfaction);
106
110
ASTConstraintSatisfaction (const ASTContext &C,
@@ -282,6 +286,11 @@ class TypeConstraint {
282
286
}
283
287
};
284
288
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
+
285
294
} // clang
286
295
287
296
#endif // LLVM_CLANG_AST_ASTCONCEPT_H
0 commit comments