Skip to content

Commit 1f15ebf

Browse files
committed
[+0-all-args] Use SILGenBuilder APIs when converting bridged to native errors.
By using this API, we properly forward ownership when we perform this conversion. Previously if we had a guaranteed bridged error argument, we would wrap the bridged error argument in an class existential box and then destroy that box, violating the +0 contract. Instead now we forward the ownership correctly through the init_existential_ref. Found while updating SILGen tests for +0 arguments. rdar://34222540
1 parent 251093e commit 1f15ebf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/SILGen/SILGenBridging.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,10 +1094,8 @@ ManagedValue SILGenFunction::emitBridgedToNativeError(SILLocation loc,
10941094
};
10951095
auto conformances = getASTContext().AllocateCopy(conformanceArray);
10961096

1097-
SILValue nativeError =
1098-
B.createInitExistentialRef(loc, nativeErrorTy, bridgedErrorTy,
1099-
bridgedError.forward(*this), conformances);
1100-
return emitManagedRValueWithCleanup(nativeError);
1097+
return B.createInitExistentialRef(loc, nativeErrorTy, bridgedErrorTy,
1098+
bridgedError, conformances);
11011099
}
11021100

11031101
// Otherwise, we need to call a runtime function to potential substitute

0 commit comments

Comments
 (0)