@@ -67,7 +67,7 @@ class MemoryLifetimeVerifier {
67
67
68
68
// / Issue an error if any bit in \p wrongBits is set.
69
69
void require (const Bits &wrongBits, const Twine &complaint,
70
- SILInstruction *where );
70
+ SILInstruction *where, bool excludeTrivialEnums = false );
71
71
72
72
// / Require that all the subLocation bits of the location, associated with
73
73
// / \p addr, are clear in \p bits.
@@ -252,19 +252,20 @@ void MemoryLifetimeVerifier::reportError(const Twine &complaint,
252
252
}
253
253
254
254
void MemoryLifetimeVerifier::require (const Bits &wrongBits,
255
- const Twine &complaint, SILInstruction *where) {
255
+ const Twine &complaint, SILInstruction *where,
256
+ bool excludeTrivialEnums) {
256
257
for (int errorLocIdx = wrongBits.find_first (); errorLocIdx >= 0 ;
257
258
errorLocIdx = wrongBits.find_next (errorLocIdx)) {
258
- if (!isEnumTrivialAt (errorLocIdx, where))
259
+ if (!excludeTrivialEnums || ! isEnumTrivialAt (errorLocIdx, where))
259
260
reportError (complaint, errorLocIdx, where);
260
261
}
261
262
}
262
263
263
264
void MemoryLifetimeVerifier::requireBitsClear (const Bits &bits, SILValue addr,
264
265
SILInstruction *where) {
265
266
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 );
268
269
}
269
270
}
270
271
@@ -502,7 +503,8 @@ void MemoryLifetimeVerifier::checkFunction(BitDataflow &dataFlow) {
502
503
BlockState &predState = dataFlow[pred];
503
504
if (predState.reachableFromEntry ) {
504
505
require ((bs.data .entrySet ^ predState.exitSet ) & nonTrivialLocations,
505
- " lifetime mismatch in predecessors" , pred->getTerminator ());
506
+ " lifetime mismatch in predecessors" , pred->getTerminator (),
507
+ /* excludeTrivialEnums*/ true );
506
508
}
507
509
}
508
510
@@ -515,13 +517,15 @@ void MemoryLifetimeVerifier::checkFunction(BitDataflow &dataFlow) {
515
517
require (expectedReturnBits & ~bs.data .exitSet ,
516
518
" indirect argument is not alive at function return" , term);
517
519
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 );
519
522
break ;
520
523
case SILInstructionKind::ThrowInst:
521
524
require (expectedThrowBits & ~bs.data .exitSet ,
522
525
" indirect argument is not alive at throw" , term);
523
526
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 );
525
529
break ;
526
530
default :
527
531
break ;
0 commit comments