Skip to content

Commit e5f9b1f

Browse files
committed
[+0-normal-args] When performing optional-to-optional conversions, be sure the passed in conversion is at +1 since all conversions happen at +1.
This assumption is already in the code here. My change just makes it so that when we perform optional-to-optional on a +0 argument, we copy before the transform. Caught via the ownership verifier when updating test/SILGen/objc_blocks_bridging.swift for +0 arguments. rdar://34222540
1 parent 35c96b8 commit e5f9b1f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/SILGen/SILGenConvert.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ SILGenFunction::emitOptionalToOptional(SILLocation loc,
369369
auto isNotPresentBB = createBasicBlock();
370370
auto isPresentBB = createBasicBlock();
371371

372+
// All conversions happen at +1.
373+
input = input.ensurePlusOne(*this, loc);
374+
372375
SwitchEnumBuilder SEBuilder(B, loc, input);
373376
SILType noOptResultTy = resultTy.getOptionalObjectType();
374377
assert(noOptResultTy);

0 commit comments

Comments
 (0)