@@ -367,10 +367,13 @@ RequirementMachine *RewriteContext::getRequirementMachine(
367
367
// Store this requirement machine before adding the signature,
368
368
// to catch re-entrant construction via initWithGenericSignature()
369
369
// below.
370
- machine = new rewriting::RequirementMachine (*this );
371
- machine-> initWithGenericSignature (sig) ;
370
+ auto *newMachine = new rewriting::RequirementMachine (*this );
371
+ machine = newMachine ;
372
372
373
- return machine;
373
+ // This might re-entrantly invalidate 'machine', which is a reference
374
+ // into Protos.
375
+ newMachine->initWithGenericSignature (sig);
376
+ return newMachine;
374
377
}
375
378
376
379
bool RewriteContext::isRecursivelyConstructingRequirementMachine (
@@ -484,14 +487,19 @@ RequirementMachine *RewriteContext::getRequirementMachine(
484
487
llvm::errs () << " " << proto->getName ();
485
488
abort ();
486
489
}
487
- } else {
488
- // Construct a requirement machine from the structural requirements of
489
- // the given set of protocols.
490
- machine = new RequirementMachine (*this );
491
- machine->initWithProtocols (component.Protos );
490
+
491
+ return machine;
492
492
}
493
493
494
- return machine;
494
+ // Construct a requirement machine from the structural requirements of
495
+ // the given set of protocols.
496
+ auto *newMachine = new RequirementMachine (*this );
497
+ machine = newMachine;
498
+
499
+ // This might re-entrantly invalidate 'machine', which is a reference
500
+ // into Protos.
501
+ newMachine->initWithProtocols (component.Protos );
502
+ return newMachine;
495
503
}
496
504
497
505
// / We print stats in the destructor, which should get executed at the end of
0 commit comments