-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Clang] Normalize constraints before checking for satisfaction #141776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a8c391c
bfcad78
7d66cd8
ccb3eb0
7ff50be
badb3f2
3e37bd4
e412201
fc0e116
e8d251b
da2022a
eb3922e
90b7a28
d2e310e
5f239d4
c5a8c31
9361310
3aec41a
aa79712
905de97
7237aaa
e11c377
0eec94b
8dc536c
b01c7f5
56aaa21
5454d00
f2bf57c
99b62f0
a160c64
95911f1
536b281
7ecf194
3604567
2843ad3
a1eb5b5
ebe396b
38c43e1
81413f0
ab3f023
aa7fcb9
cde4bb7
fdb9bfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,10 +28,20 @@ namespace clang { | |
|
||
class ConceptDecl; | ||
class TemplateDecl; | ||
class ConceptReference; | ||
class Expr; | ||
class NamedDecl; | ||
struct PrintingPolicy; | ||
|
||
/// Unsatisfied constraint expressions if the template arguments could be | ||
/// substituted into them, or a diagnostic if substitution resulted in | ||
/// an invalid expression. | ||
/// | ||
using ConstraintSubstitutionDiagnostic = std::pair<SourceLocation, StringRef>; | ||
using UnsatisfiedConstraintRecord = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name is pre-existing, we could change it afterwards |
||
llvm::PointerUnion<const Expr *, const ConceptReference *, | ||
const ConstraintSubstitutionDiagnostic *>; | ||
|
||
/// The result of a constraint satisfaction check, containing the necessary | ||
/// information to diagnose an unsatisfied constraint. | ||
class ConstraintSatisfaction : public llvm::FoldingSetNode { | ||
|
@@ -48,16 +58,13 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode { | |
ArrayRef<TemplateArgument> TemplateArgs) | ||
: ConstraintOwner(ConstraintOwner), TemplateArgs(TemplateArgs) {} | ||
|
||
using SubstitutionDiagnostic = std::pair<SourceLocation, StringRef>; | ||
using Detail = llvm::PointerUnion<Expr *, SubstitutionDiagnostic *>; | ||
|
||
bool IsSatisfied = false; | ||
bool ContainsErrors = false; | ||
|
||
/// \brief The substituted constraint expr, if the template arguments could be | ||
/// substituted into them, or a diagnostic if substitution resulted in an | ||
/// invalid expression. | ||
llvm::SmallVector<Detail, 4> Details; | ||
llvm::SmallVector<UnsatisfiedConstraintRecord, 4> Details; | ||
|
||
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C) { | ||
Profile(ID, C, ConstraintOwner, TemplateArgs); | ||
|
@@ -69,19 +76,12 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode { | |
|
||
bool HasSubstitutionFailure() { | ||
for (const auto &Detail : Details) | ||
if (Detail.dyn_cast<SubstitutionDiagnostic *>()) | ||
if (Detail.dyn_cast<const ConstraintSubstitutionDiagnostic *>()) | ||
return true; | ||
return false; | ||
} | ||
}; | ||
|
||
/// Pairs of unsatisfied atomic constraint expressions along with the | ||
/// substituted constraint expr, if the template arguments could be | ||
/// substituted into them, or a diagnostic if substitution resulted in | ||
/// an invalid expression. | ||
using UnsatisfiedConstraintRecord = | ||
llvm::PointerUnion<Expr *, std::pair<SourceLocation, StringRef> *>; | ||
|
||
/// \brief The result of a constraint satisfaction check, containing the | ||
/// necessary information to diagnose an unsatisfied constraint. | ||
/// | ||
|
@@ -101,6 +101,10 @@ struct ASTConstraintSatisfaction final : | |
return getTrailingObjects() + NumRecords; | ||
} | ||
|
||
ArrayRef<UnsatisfiedConstraintRecord> records() const { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, can we get a more descriptive name for this member function. Especially because searching for this name will hit so many other things on a naive search. |
||
return {begin(), end()}; | ||
} | ||
|
||
ASTConstraintSatisfaction(const ASTContext &C, | ||
const ConstraintSatisfaction &Satisfaction); | ||
ASTConstraintSatisfaction(const ASTContext &C, | ||
|
@@ -282,6 +286,11 @@ class TypeConstraint { | |
} | ||
}; | ||
|
||
/// Insertion operator for diagnostics. This allows sending ConceptReferences's | ||
/// into a diagnostic with <<. | ||
const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, | ||
const ConceptReference *C); | ||
|
||
} // clang | ||
|
||
#endif // LLVM_CLANG_AST_ASTCONCEPT_H |
Uh oh!
There was an error while loading. Please reload this page.