Skip to content

Commit 8fd8bb9

Browse files
committed
Rename borrowLifetimeParamIndices -> scopeLifetimeParamIndices
1 parent a66b7b6 commit 8fd8bb9

7 files changed

+39
-38
lines changed

include/swift/AST/LifetimeDependence.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class LifetimeDependenceSpecifier {
131131

132132
class LifetimeDependenceInfo {
133133
IndexSubset *inheritLifetimeParamIndices;
134-
IndexSubset *borrowLifetimeParamIndices;
134+
IndexSubset *scopeLifetimeParamIndices;
135135

136136
static LifetimeDependenceInfo getForParamIndex(AbstractFunctionDecl *afd,
137137
unsigned index,
@@ -146,24 +146,24 @@ class LifetimeDependenceInfo {
146146
public:
147147
LifetimeDependenceInfo()
148148
: inheritLifetimeParamIndices(nullptr),
149-
borrowLifetimeParamIndices(nullptr) {}
149+
scopeLifetimeParamIndices(nullptr) {}
150150
LifetimeDependenceInfo(IndexSubset *inheritLifetimeParamIndices,
151-
IndexSubset *borrowLifetimeParamIndices)
151+
IndexSubset *scopeLifetimeParamIndices)
152152
: inheritLifetimeParamIndices(inheritLifetimeParamIndices),
153-
borrowLifetimeParamIndices(borrowLifetimeParamIndices) {}
153+
scopeLifetimeParamIndices(scopeLifetimeParamIndices) {}
154154

155155
operator bool() const { return !empty(); }
156156

157157
bool empty() const {
158158
return inheritLifetimeParamIndices == nullptr &&
159-
borrowLifetimeParamIndices == nullptr;
159+
scopeLifetimeParamIndices == nullptr;
160160
}
161161

162162
bool hasInheritLifetimeParamIndices() const {
163163
return inheritLifetimeParamIndices != nullptr;
164164
}
165165
bool hasBorrowLifetimeParamIndices() const {
166-
return borrowLifetimeParamIndices != nullptr;
166+
return scopeLifetimeParamIndices != nullptr;
167167
}
168168

169169
std::string getString() const;

lib/Sema/LifetimeDependence.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ std::string LifetimeDependenceInfo::getString() const {
4040
lifetimeDependenceString =
4141
"_inherit(" + getOnIndices(inheritLifetimeParamIndices) + ")";
4242
}
43-
if (borrowLifetimeParamIndices && !borrowLifetimeParamIndices->isEmpty()) {
43+
if (scopeLifetimeParamIndices && !scopeLifetimeParamIndices->isEmpty()) {
4444
lifetimeDependenceString +=
45-
"_borrow(" + getOnIndices(borrowLifetimeParamIndices) + ")";
45+
"_scope(" + getOnIndices(scopeLifetimeParamIndices) + ")";
4646
}
4747
return lifetimeDependenceString;
4848
}
@@ -51,8 +51,8 @@ void LifetimeDependenceInfo::Profile(llvm::FoldingSetNodeID &ID) const {
5151
if (inheritLifetimeParamIndices) {
5252
inheritLifetimeParamIndices->Profile(ID);
5353
}
54-
if (borrowLifetimeParamIndices) {
55-
borrowLifetimeParamIndices->Profile(ID);
54+
if (scopeLifetimeParamIndices) {
55+
scopeLifetimeParamIndices->Profile(ID);
5656
}
5757
}
5858

@@ -64,12 +64,12 @@ LifetimeDependenceInfo LifetimeDependenceInfo::getForParamIndex(
6464
auto indexSubset = IndexSubset::get(ctx, capacity, {index});
6565
if (ownership == ValueOwnership::Owned) {
6666
return LifetimeDependenceInfo{/*inheritLifetimeParamIndices*/ indexSubset,
67-
/*borrowLifetimeParamIndices*/ nullptr};
67+
/*scopeLifetimeParamIndices*/ nullptr};
6868
}
6969
assert(ownership == ValueOwnership::Shared ||
7070
ownership == ValueOwnership::InOut);
7171
return LifetimeDependenceInfo{/*inheritLifetimeParamIndices*/ nullptr,
72-
/*borrowLifetimeParamIndices*/ indexSubset};
72+
/*scopeLifetimeParamIndices*/ indexSubset};
7373
}
7474

7575
void LifetimeDependenceInfo::getConcatenatedData(
@@ -92,7 +92,7 @@ void LifetimeDependenceInfo::getConcatenatedData(
9292
pushData(inheritLifetimeParamIndices);
9393
}
9494
if (hasBorrowLifetimeParamIndices()) {
95-
pushData(borrowLifetimeParamIndices);
95+
pushData(scopeLifetimeParamIndices);
9696
}
9797
}
9898

@@ -107,7 +107,7 @@ LifetimeDependenceInfo::fromTypeRepr(AbstractFunctionDecl *afd, Type resultType,
107107
cast<LifetimeDependentReturnTypeRepr>(afd->getResultTypeRepr());
108108

109109
SmallBitVector inheritLifetimeParamIndices(capacity);
110-
SmallBitVector borrowLifetimeParamIndices(capacity);
110+
SmallBitVector scopeLifetimeParamIndices(capacity);
111111

112112
auto updateLifetimeDependenceInfo = [&](LifetimeDependenceSpecifier specifier,
113113
unsigned paramIndexToSet,
@@ -143,7 +143,7 @@ LifetimeDependenceInfo::fromTypeRepr(AbstractFunctionDecl *afd, Type resultType,
143143
return true;
144144
}
145145
if (inheritLifetimeParamIndices.test(paramIndexToSet) ||
146-
borrowLifetimeParamIndices.test(paramIndexToSet)) {
146+
scopeLifetimeParamIndices.test(paramIndexToSet)) {
147147
diags.diagnose(loc, diag::lifetime_dependence_duplicate_param_id);
148148
return true;
149149
}
@@ -153,7 +153,7 @@ LifetimeDependenceInfo::fromTypeRepr(AbstractFunctionDecl *afd, Type resultType,
153153
} else {
154154
assert(kind == LifetimeDependenceKind::Borrow ||
155155
kind == LifetimeDependenceKind::Mutate);
156-
borrowLifetimeParamIndices.set(paramIndexToSet);
156+
scopeLifetimeParamIndices.set(paramIndexToSet);
157157
}
158158
return false;
159159
};
@@ -227,8 +227,8 @@ LifetimeDependenceInfo::fromTypeRepr(AbstractFunctionDecl *afd, Type resultType,
227227
inheritLifetimeParamIndices.any()
228228
? IndexSubset::get(ctx, inheritLifetimeParamIndices)
229229
: nullptr,
230-
borrowLifetimeParamIndices.any()
231-
? IndexSubset::get(ctx, borrowLifetimeParamIndices)
230+
scopeLifetimeParamIndices.any()
231+
? IndexSubset::get(ctx, scopeLifetimeParamIndices)
232232
: nullptr);
233233
}
234234

@@ -323,4 +323,5 @@ LifetimeDependenceInfo::get(AbstractFunctionDecl *afd, Type resultType,
323323
}
324324
return LifetimeDependenceInfo::infer(afd, resultType);
325325
}
326+
326327
} // namespace swift

test/SIL/explicit_lifetime_dependence_specifiers.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct BufferView : ~Escapable {
2222
}
2323
self.ptr = ptr
2424
}
25-
// CHECK: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACSW_SaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> _borrow(2) @owned BufferView {
25+
// CHECK: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACSW_SaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> _scope(2) @owned BufferView {
2626
init(_ ptr: UnsafeRawBufferPointer, _ a: borrowing Array<Int>) -> _borrow(a) Self {
2727
self.ptr = ptr
2828
return self
@@ -32,7 +32,7 @@ struct BufferView : ~Escapable {
3232
self.ptr = ptr
3333
return self
3434
}
35-
// CHECK: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACSW_SaySdGSaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @owned Array<Double>, @guaranteed Array<Int>, @thin BufferView.Type) -> _inherit(2)_borrow(3) @owned BufferView {
35+
// CHECK: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACSW_SaySdGSaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @owned Array<Double>, @guaranteed Array<Int>, @thin BufferView.Type) -> _inherit(2)_scope(3) @owned BufferView {
3636
init(_ ptr: UnsafeRawBufferPointer, _ a: consuming Array<Double>, _ b: borrowing Array<Int>) -> _consume(a) _borrow(b) Self {
3737
self.ptr = ptr
3838
return self
@@ -59,7 +59,7 @@ func testBasic() {
5959
}
6060
}
6161

62-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _borrow(1) @owned BufferView {
62+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _scope(1) @owned BufferView {
6363
func derive(_ x: borrowing BufferView) -> _borrow(x) BufferView {
6464
return BufferView(x.ptr)
6565
}
@@ -69,15 +69,15 @@ func consumeAndCreate(_ x: consuming BufferView) -> _copy(x) BufferView {
6969
return BufferView(x.ptr)
7070
}
7171

72-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers17deriveThisOrThat1yAA10BufferViewVAD_ADtF : $@convention(thin) (@guaranteed BufferView, @guaranteed BufferView) -> _borrow(1, 2) @owned BufferView {
72+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers17deriveThisOrThat1yAA10BufferViewVAD_ADtF : $@convention(thin) (@guaranteed BufferView, @guaranteed BufferView) -> _scope(1, 2) @owned BufferView {
7373
func deriveThisOrThat1(_ this: borrowing BufferView, _ that: borrowing BufferView) -> _borrow(this, that) BufferView {
7474
if (Int.random(in: 1..<100) == 0) {
7575
return BufferView(this.ptr)
7676
}
7777
return BufferView(that.ptr)
7878
}
7979

80-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers17deriveThisOrThat2yAA10BufferViewVAD_ADntF : $@convention(thin) (@guaranteed BufferView, @owned BufferView) -> _inherit(2)_borrow(1) @owned BufferView {
80+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers17deriveThisOrThat2yAA10BufferViewVAD_ADntF : $@convention(thin) (@guaranteed BufferView, @owned BufferView) -> _inherit(2)_scope(1) @owned BufferView {
8181
func deriveThisOrThat2(_ this: borrowing BufferView, _ that: consuming BufferView) -> _borrow(this) _copy(that) BufferView {
8282
if (Int.random(in: 1..<100) == 0) {
8383
return BufferView(this.ptr)
@@ -92,7 +92,7 @@ struct Wrapper : ~Escapable {
9292
init(_ view: consuming BufferView) {
9393
self.view = view
9494
}
95-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers7WrapperV8getView1AA10BufferViewVyF : $@convention(method) (@guaranteed Wrapper) -> _borrow(0) @owned BufferView {
95+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers7WrapperV8getView1AA10BufferViewVyF : $@convention(method) (@guaranteed Wrapper) -> _scope(0) @owned BufferView {
9696
borrowing func getView1() -> _borrow(self) BufferView {
9797
return view
9898
}

test/SIL/implicit_lifetime_dependence.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct BufferView : ~Escapable {
1616
init(_ ptr: UnsafeRawBufferPointer) {
1717
self.ptr = ptr
1818
}
19-
// CHECK-LABEL: sil hidden @$s28implicit_lifetime_dependence10BufferViewVyA2ChcfC : $@convention(method) (@guaranteed BufferView, @thin BufferView.Type) -> _borrow(1) @owned BufferView {
19+
// CHECK-LABEL: sil hidden @$s28implicit_lifetime_dependence10BufferViewVyA2ChcfC : $@convention(method) (@guaranteed BufferView, @thin BufferView.Type) -> _scope(1) @owned BufferView {
2020
init(_ otherBV: borrowing BufferView) {
2121
self.ptr = otherBV.ptr
2222
}
@@ -48,7 +48,7 @@ func testBasic() {
4848
}
4949
*/
5050

51-
// CHECK-LABEL: sil hidden @$s28implicit_lifetime_dependence6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _borrow(1) @owned BufferView {
51+
// CHECK-LABEL: sil hidden @$s28implicit_lifetime_dependence6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _scope(1) @owned BufferView {
5252
func derive(_ x: borrowing BufferView) -> BufferView {
5353
return BufferView(x.ptr)
5454
}
@@ -65,7 +65,7 @@ struct Wrapper : ~Escapable {
6565
init(_ view: consuming BufferView) {
6666
self.view = view
6767
}
68-
// CHECK-LABEL: sil hidden @$s28implicit_lifetime_dependence7WrapperV8getView1AA10BufferViewVyF : $@convention(method) (@guaranteed Wrapper) -> _borrow(0) @owned BufferView {
68+
// CHECK-LABEL: sil hidden @$s28implicit_lifetime_dependence7WrapperV8getView1AA10BufferViewVyF : $@convention(method) (@guaranteed Wrapper) -> _scope(0) @owned BufferView {
6969
borrowing func getView1() -> BufferView {
7070
return view
7171
}

test/SIL/lifetime_dependence_generics.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public func test(pview: consuming PView) -> _consume(pview) View {
2929
return pview.getDefault()
3030
}
3131

32-
// CHECK: sil hidden @$s28lifetime_dependence_generics1PPAAE10getDefault1EQzyF : $@convention(method) <Self where Self : P> (@in_guaranteed Self) -> _borrow(0) @out Self.E {
32+
// CHECK: sil hidden @$s28lifetime_dependence_generics1PPAAE10getDefault1EQzyF : $@convention(method) <Self where Self : P> (@in_guaranteed Self) -> _scope(0) @out Self.E {
3333

34-
// CHECK: sil hidden @$s28lifetime_dependence_generics5PViewV4getEAA4ViewVyF : $@convention(method) (PView) -> _borrow(0) @owned View {
34+
// CHECK: sil hidden @$s28lifetime_dependence_generics5PViewV4getEAA4ViewVyF : $@convention(method) (PView) -> _scope(0) @owned View {
3535

36-
// CHECK: sil private [transparent] [thunk] @$s28lifetime_dependence_generics5PViewVAA1PA2aDP4getE1EQzyFTW : $@convention(witness_method: P) (@in_guaranteed PView) -> _borrow(0) @out View {
36+
// CHECK: sil private [transparent] [thunk] @$s28lifetime_dependence_generics5PViewVAA1PA2aDP4getE1EQzyFTW : $@convention(witness_method: P) (@in_guaranteed PView) -> _scope(0) @out View {
3737

3838
// CHECK: sil @$s28lifetime_dependence_generics4test5pviewAA4ViewVAA5PViewVn_tF : $@convention(thin) (PView) -> _inherit(1) @owned View {

test/Serialization/explicit_lifetime_dependence.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ func testInitializers() {
3939
use(mysteryView)
4040
}
4141
}
42-
// CHECK: sil @$s32def_explicit_lifetime_dependence6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _borrow(1) @owned BufferView
42+
// CHECK: sil @$s32def_explicit_lifetime_dependence6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _scope(1) @owned BufferView
4343
// CHECK: sil @$s32def_explicit_lifetime_dependence16consumeAndCreateyAA10BufferViewVADnF : $@convention(thin) (@owned BufferView) -> _inherit(1) @owned BufferView
44-
// CHECK: sil @$s32def_explicit_lifetime_dependence15borrowAndCreateyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _borrow(1) @owned BufferView
45-
// CHECK: sil @$s32def_explicit_lifetime_dependence16deriveThisOrThatyAA10BufferViewVAD_ADtF : $@convention(thin) (@guaranteed BufferView, @guaranteed BufferView) -> _borrow(1, 2) @owned BufferView
44+
// CHECK: sil @$s32def_explicit_lifetime_dependence15borrowAndCreateyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _scope(1) @owned BufferView
45+
// CHECK: sil @$s32def_explicit_lifetime_dependence16deriveThisOrThatyAA10BufferViewVAD_ADtF : $@convention(thin) (@guaranteed BufferView, @guaranteed BufferView) -> _scope(1, 2) @owned BufferView
4646

47-
// CHECK: sil @$s32def_explicit_lifetime_dependence10BufferViewVyACSW_SaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> _borrow(2) @owned BufferView
47+
// CHECK: sil @$s32def_explicit_lifetime_dependence10BufferViewVyACSW_SaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> _scope(2) @owned BufferView
4848

49-
// CHECK: sil @$s32def_explicit_lifetime_dependence10BufferViewVyACSW_SaySiGADhtcfC : $@convention(method) (UnsafeRawBufferPointer, @owned Array<Int>, @guaranteed Array<Int>, @thin BufferView.Type) -> _inherit(2)_borrow(3) @owned BufferView
49+
// CHECK: sil @$s32def_explicit_lifetime_dependence10BufferViewVyACSW_SaySiGADhtcfC : $@convention(method) (UnsafeRawBufferPointer, @owned Array<Int>, @guaranteed Array<Int>, @thin BufferView.Type) -> _inherit(2)_scope(3) @owned BufferView

test/Serialization/implicit_lifetime_dependence.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ func unsafetest(_ ptr: UnsafeRawBufferPointer) {
4646
use(view3)
4747
}
4848

49-
// CHECK: sil @$s32def_implicit_lifetime_dependence6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _borrow(1) @owned BufferView
49+
// CHECK: sil @$s32def_implicit_lifetime_dependence6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _scope(1) @owned BufferView
5050
// CHECK: sil @$s32def_implicit_lifetime_dependence16consumeAndCreateyAA10BufferViewVADnF : $@convention(thin) (@owned BufferView) -> _inherit(1) @owned BufferView
51-
// CHECK: sil @$s32def_implicit_lifetime_dependence15borrowAndCreateyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _borrow(1) @owned BufferView
52-
// CHECK: sil @$s32def_implicit_lifetime_dependence10BufferViewVyA2ChcfC : $@convention(method) (@guaranteed BufferView, @thin BufferView.Type) -> _borrow(1) @owned BufferView
51+
// CHECK: sil @$s32def_implicit_lifetime_dependence15borrowAndCreateyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _scope(1) @owned BufferView
52+
// CHECK: sil @$s32def_implicit_lifetime_dependence10BufferViewVyA2ChcfC : $@convention(method) (@guaranteed BufferView, @thin BufferView.Type) -> _scope(1) @owned BufferView
5353

0 commit comments

Comments
 (0)