Skip to content

Commit d505686

Browse files
committed
[ownership] Add some helpers to BorrowedValue that lets you use it easily as a value.
Specifically I provided a '->' and a '*' operator. So now you can do: ``` borrowedValue->callSILValueMethod(); ``` and explicitly cast to SILValue using '*'.
1 parent 31c9d76 commit d505686

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/swift/SIL/OwnershipUtils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@ struct BorrowedValue {
468468
return foundAnyReborrows;
469469
}
470470

471+
// Helpers to allow a BorrowedValue to easily be used as a SILValue
472+
// programatically.
473+
SILValue operator->() { return value; }
474+
SILValue operator->() const { return value; }
475+
SILValue operator*() { return value; }
476+
SILValue operator*() const { return value; }
477+
471478
private:
472479
/// Internal constructor for failable static constructor. Please do not expand
473480
/// its usage since it assumes the code passed in is well formed.

0 commit comments

Comments
 (0)