mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Today, SILGenFunction::emitRValue assumes the caller will create any cleanup scopes that are needed to cleanup side-effects relating to the rvalue evaluation. The API also provides the ability for the caller to specify that a +0 rvalues is an "ok" result. The API then tries to produce a +0 rvalue and returns a +1 rvalue otherwise. These two properties create conflicting requirements on the caller since the caller does not know whether or not it should create a scope (if a +1 rvalue will be returned) or not (if a +0 rvalue would be returned). The key issue here is the optionality of returning a +0 rvalue. This change begins to resolve this difference by creating two separate APIs that guarantee to the caller whether or not a +0 or a +1 rvalue is returned and also creates local scopes for the caller as appropriate. So by using these APIs, the caller knows that the +0 or +1 rvalue that is returned has properly been put into the caller scope. So the caller no longer needs to create its own scopes anymore. emitPlusOneRValue is emitRValue except that it scopes the rvalue emission and then *pushes* the produced rvalue through the scope. emitPlusZeroRValue is currently a stub implementation that just calls emitPlusOneRValue and then borrows the resulting +1 RValue in the outer scope, creating the +0 RValue that was requested by the caller. rdar://33358110
6.2 KiB
6.2 KiB