@@ -133,7 +133,8 @@ class MemoryLifetimeVerifier {
133
133
134
134
public:
135
135
MemoryLifetimeVerifier (SILFunction *function) :
136
- function (function), locations(/* handleNonTrivialProjections*/ true ) {}
136
+ function (function), locations(/* handleNonTrivialProjections*/ true ,
137
+ /* handleTrivialLocations*/ true ) {}
137
138
138
139
// / The main entry point to verify the lifetime of all memory locations in
139
140
// / the function.
@@ -593,7 +594,7 @@ void MemoryLifetimeVerifier::checkBlock(SILBasicBlock *block, Bits &bits) {
593
594
case SILInstructionKind::InitExistentialAddrInst:
594
595
case SILInstructionKind::InitEnumDataAddrInst: {
595
596
SILValue addr = I.getOperand (0 );
596
- requireBitsClear (bits, addr, &I);
597
+ requireBitsClear (bits & nonTrivialLocations , addr, &I);
597
598
requireNoStoreBorrowLocation (addr, &I);
598
599
break ;
599
600
}
@@ -701,9 +702,17 @@ void MemoryLifetimeVerifier::checkFuncArgument(Bits &bits, Operand &argumentOp,
701
702
break ;
702
703
case SILArgumentConvention::Indirect_In_Guaranteed:
703
704
case SILArgumentConvention::Indirect_Inout:
704
- case SILArgumentConvention::Indirect_InoutAliasable:
705
705
requireBitsSet (bits, argumentOp.get (), applyInst);
706
706
break ;
707
+ case SILArgumentConvention::Indirect_InoutAliasable:
708
+ // We don't require any locations to be initialized for a partial_apply
709
+ // which takes an inout_aliasable argument. This is used for implicit
710
+ // closures (e.g. for the Bool '||' and '&&' operator arguments). Such
711
+ // closures capture the whole "self". When this is done in an initializer
712
+ // it can happen that not all fields of "self" are initialized, yet.
713
+ if (!isa<PartialApplyInst>(applyInst))
714
+ requireBitsSet (bits, argumentOp.get (), applyInst);
715
+ break ;
707
716
case SILArgumentConvention::Direct_Owned:
708
717
case SILArgumentConvention::Direct_Unowned:
709
718
case SILArgumentConvention::Direct_Guaranteed:
0 commit comments