File tree Expand file tree Collapse file tree 4 files changed +18
-10
lines changed
lib/AST/RequirementMachine Expand file tree Collapse file tree 4 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -371,7 +371,7 @@ void RequirementMachine::addGenericSignature(CanGenericSignature sig) {
371
371
std::move (builder.RequirementRules ),
372
372
std::move (builder.Protocols ));
373
373
374
- computeCompletion ();
374
+ computeCompletion (RewriteSystem::DisallowInvalidRequirements );
375
375
376
376
if (Dump) {
377
377
llvm::dbgs () << " }\n " ;
@@ -380,7 +380,7 @@ void RequirementMachine::addGenericSignature(CanGenericSignature sig) {
380
380
381
381
// / Attempt to obtain a confluent rewrite system using the completion
382
382
// / procedure.
383
- void RequirementMachine::computeCompletion () {
383
+ void RequirementMachine::computeCompletion (RewriteSystem::ValidityPolicy policy ) {
384
384
while (true ) {
385
385
// First, run the Knuth-Bendix algorithm to resolve overlapping rules.
386
386
auto result = System.computeConfluentCompletion (
@@ -415,7 +415,7 @@ void RequirementMachine::computeCompletion() {
415
415
checkCompletionResult ();
416
416
417
417
// Check invariants.
418
- System.verifyRewriteRules ();
418
+ System.verifyRewriteRules (policy );
419
419
System.verifyHomotopyGenerators ();
420
420
421
421
// Build the property map, which also performs concrete term
Original file line number Diff line number Diff line change @@ -80,7 +80,8 @@ class RequirementMachine final {
80
80
void addGenericSignature (CanGenericSignature sig);
81
81
82
82
bool isComplete () const ;
83
- void computeCompletion ();
83
+
84
+ void computeCompletion (RewriteSystem::ValidityPolicy policy);
84
85
85
86
MutableTerm getLongestValidPrefix (const MutableTerm &term) const ;
86
87
Original file line number Diff line number Diff line change @@ -358,7 +358,7 @@ void RewriteSystem::simplifyRewriteSystem() {
358
358
}
359
359
}
360
360
361
- void RewriteSystem::verifyRewriteRules () const {
361
+ void RewriteSystem::verifyRewriteRules (ValidityPolicy policy ) const {
362
362
#ifndef NDEBUG
363
363
364
364
#define ASSERT_RULE (expr ) \
@@ -396,10 +396,12 @@ void RewriteSystem::verifyRewriteRules() const {
396
396
for (unsigned index : indices (rhs)) {
397
397
auto symbol = rhs[index];
398
398
399
- // FIXME: This is only true if the input requirements were valid.
400
- // On invalid code, we'll need to skip this assertion (and instead
401
- // assert that we diagnosed an error!)
402
- ASSERT_RULE (symbol.getKind () != Symbol::Kind::Name);
399
+ // This is only true if the input requirements were valid.
400
+ if (policy == DisallowInvalidRequirements) {
401
+ ASSERT_RULE (symbol.getKind () != Symbol::Kind::Name);
402
+ } else {
403
+ // FIXME: Assert that we diagnosed an error
404
+ }
403
405
404
406
ASSERT_RULE (symbol.getKind () != Symbol::Kind::Layout);
405
407
ASSERT_RULE (!symbol.isSuperclassOrConcreteType ());
Original file line number Diff line number Diff line change @@ -406,7 +406,12 @@ class RewriteSystem final {
406
406
407
407
void minimizeRewriteSystem ();
408
408
409
- void verifyRewriteRules () const ;
409
+ enum ValidityPolicy {
410
+ AllowInvalidRequirements,
411
+ DisallowInvalidRequirements
412
+ };
413
+
414
+ void verifyRewriteRules (ValidityPolicy policy) const ;
410
415
411
416
void verifyHomotopyGenerators () const ;
412
417
You can’t perform that action at this time.
0 commit comments