@@ -67,7 +67,7 @@ class MemoryLifetimeVerifier {
6767
6868 // / Issue an error if any bit in \p wrongBits is set.
6969 void require (const Bits &wrongBits, const Twine &complaint,
70- SILInstruction *where );
70+ SILInstruction *where, bool excludeTrivialEnums = false );
7171
7272 // / Require that all the subLocation bits of the location, associated with
7373 // / \p addr, are clear in \p bits.
@@ -252,19 +252,20 @@ void MemoryLifetimeVerifier::reportError(const Twine &complaint,
252252}
253253
254254void MemoryLifetimeVerifier::require (const Bits &wrongBits,
255- const Twine &complaint, SILInstruction *where) {
255+ const Twine &complaint, SILInstruction *where,
256+ bool excludeTrivialEnums) {
256257 for (int errorLocIdx = wrongBits.find_first (); errorLocIdx >= 0 ;
257258 errorLocIdx = wrongBits.find_next (errorLocIdx)) {
258- if (!isEnumTrivialAt (errorLocIdx, where))
259+ if (!excludeTrivialEnums || ! isEnumTrivialAt (errorLocIdx, where))
259260 reportError (complaint, errorLocIdx, where);
260261 }
261262}
262263
263264void MemoryLifetimeVerifier::requireBitsClear (const Bits &bits, SILValue addr,
264265 SILInstruction *where) {
265266 if (auto *loc = locations.getLocation (addr)) {
266- require (bits & loc->subLocations ,
267- " memory is initialized, but shouldn't " , where );
267+ require (bits & loc->subLocations , " memory is initialized, but shouldn't " ,
268+ where, /* excludeTrivialEnums */ true );
268269 }
269270}
270271
@@ -502,7 +503,8 @@ void MemoryLifetimeVerifier::checkFunction(BitDataflow &dataFlow) {
502503 BlockState &predState = dataFlow[pred];
503504 if (predState.reachableFromEntry ) {
504505 require ((bs.data .entrySet ^ predState.exitSet ) & nonTrivialLocations,
505- " lifetime mismatch in predecessors" , pred->getTerminator ());
506+ " lifetime mismatch in predecessors" , pred->getTerminator (),
507+ /* excludeTrivialEnums*/ true );
506508 }
507509 }
508510
@@ -515,13 +517,15 @@ void MemoryLifetimeVerifier::checkFunction(BitDataflow &dataFlow) {
515517 require (expectedReturnBits & ~bs.data .exitSet ,
516518 " indirect argument is not alive at function return" , term);
517519 require (bs.data .exitSet & ~expectedReturnBits & nonTrivialLocations,
518- " memory is initialized at function return but shouldn't" , term);
520+ " memory is initialized at function return but shouldn't" , term,
521+ /* excludeTrivialEnums*/ true );
519522 break ;
520523 case SILInstructionKind::ThrowInst:
521524 require (expectedThrowBits & ~bs.data .exitSet ,
522525 " indirect argument is not alive at throw" , term);
523526 require (bs.data .exitSet & ~expectedThrowBits & nonTrivialLocations,
524- " memory is initialized at throw but shouldn't" , term);
527+ " memory is initialized at throw but shouldn't" , term,
528+ /* excludeTrivialEnums*/ true );
525529 break ;
526530 default :
527531 break ;
0 commit comments