@@ -40,13 +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) + " )" ;
46- }
47- if (mutateLifetimeParamIndices && !mutateLifetimeParamIndices->isEmpty ()) {
48- lifetimeDependenceString +=
49- " _mutate(" + getOnIndices (mutateLifetimeParamIndices) + " )" ;
45+ " _scope(" + getOnIndices (scopeLifetimeParamIndices) + " )" ;
5046 }
5147 return lifetimeDependenceString;
5248}
@@ -55,11 +51,8 @@ void LifetimeDependenceInfo::Profile(llvm::FoldingSetNodeID &ID) const {
5551 if (inheritLifetimeParamIndices) {
5652 inheritLifetimeParamIndices->Profile (ID);
5753 }
58- if (borrowLifetimeParamIndices) {
59- borrowLifetimeParamIndices->Profile (ID);
60- }
61- if (mutateLifetimeParamIndices) {
62- mutateLifetimeParamIndices->Profile (ID);
54+ if (scopeLifetimeParamIndices) {
55+ scopeLifetimeParamIndices->Profile (ID);
6356 }
6457}
6558
@@ -71,18 +64,12 @@ LifetimeDependenceInfo LifetimeDependenceInfo::getForParamIndex(
7164 auto indexSubset = IndexSubset::get (ctx, capacity, {index});
7265 if (ownership == ValueOwnership::Owned) {
7366 return LifetimeDependenceInfo{/* inheritLifetimeParamIndices*/ indexSubset,
74- /* borrowLifetimeParamIndices*/ nullptr ,
75- /* mutateLifetimeParamIndices*/ nullptr };
76- }
77- if (ownership == ValueOwnership::Shared) {
78- return LifetimeDependenceInfo{/* inheritLifetimeParamIndices*/ nullptr ,
79- /* borrowLifetimeParamIndices*/ indexSubset,
80- /* mutateLifetimeParamIndices*/ nullptr };
67+ /* scopeLifetimeParamIndices*/ nullptr };
8168 }
82- assert (ownership == ValueOwnership::InOut);
69+ assert (ownership == ValueOwnership::Shared ||
70+ ownership == ValueOwnership::InOut);
8371 return LifetimeDependenceInfo{/* inheritLifetimeParamIndices*/ nullptr ,
84- /* borrowLifetimeParamIndices*/ nullptr ,
85- /* mutateLifetimeParamIndices*/ indexSubset};
72+ /* scopeLifetimeParamIndices*/ indexSubset};
8673}
8774
8875void LifetimeDependenceInfo::getConcatenatedData (
@@ -105,10 +92,7 @@ void LifetimeDependenceInfo::getConcatenatedData(
10592 pushData (inheritLifetimeParamIndices);
10693 }
10794 if (hasBorrowLifetimeParamIndices ()) {
108- pushData (borrowLifetimeParamIndices);
109- }
110- if (hasMutateLifetimeParamIndices ()) {
111- pushData (mutateLifetimeParamIndices);
95+ pushData (scopeLifetimeParamIndices);
11296 }
11397}
11498
@@ -123,8 +107,7 @@ LifetimeDependenceInfo::fromTypeRepr(AbstractFunctionDecl *afd, Type resultType,
123107 cast<LifetimeDependentReturnTypeRepr>(afd->getResultTypeRepr ());
124108
125109 SmallBitVector inheritLifetimeParamIndices (capacity);
126- SmallBitVector borrowLifetimeParamIndices (capacity);
127- SmallBitVector mutateLifetimeParamIndices (capacity);
110+ SmallBitVector scopeLifetimeParamIndices (capacity);
128111
129112 auto updateLifetimeDependenceInfo = [&](LifetimeDependenceSpecifier specifier,
130113 unsigned paramIndexToSet,
@@ -160,18 +143,17 @@ LifetimeDependenceInfo::fromTypeRepr(AbstractFunctionDecl *afd, Type resultType,
160143 return true ;
161144 }
162145 if (inheritLifetimeParamIndices.test (paramIndexToSet) ||
163- borrowLifetimeParamIndices .test (paramIndexToSet)) {
146+ scopeLifetimeParamIndices .test (paramIndexToSet)) {
164147 diags.diagnose (loc, diag::lifetime_dependence_duplicate_param_id);
165148 return true ;
166149 }
167150 if (kind == LifetimeDependenceKind::Copy ||
168151 kind == LifetimeDependenceKind::Consume) {
169152 inheritLifetimeParamIndices.set (paramIndexToSet);
170- } else if (kind == LifetimeDependenceKind::Borrow) {
171- borrowLifetimeParamIndices.set (paramIndexToSet);
172153 } else {
173- assert (kind == LifetimeDependenceKind::Mutate);
174- mutateLifetimeParamIndices.set (paramIndexToSet);
154+ assert (kind == LifetimeDependenceKind::Borrow ||
155+ kind == LifetimeDependenceKind::Mutate);
156+ scopeLifetimeParamIndices.set (paramIndexToSet);
175157 }
176158 return false ;
177159 };
@@ -245,11 +227,8 @@ LifetimeDependenceInfo::fromTypeRepr(AbstractFunctionDecl *afd, Type resultType,
245227 inheritLifetimeParamIndices.any ()
246228 ? IndexSubset::get (ctx, inheritLifetimeParamIndices)
247229 : nullptr ,
248- borrowLifetimeParamIndices.any ()
249- ? IndexSubset::get (ctx, borrowLifetimeParamIndices)
250- : nullptr ,
251- mutateLifetimeParamIndices.any ()
252- ? IndexSubset::get (ctx, mutateLifetimeParamIndices)
230+ scopeLifetimeParamIndices.any ()
231+ ? IndexSubset::get (ctx, scopeLifetimeParamIndices)
253232 : nullptr );
254233}
255234
@@ -344,4 +323,5 @@ LifetimeDependenceInfo::get(AbstractFunctionDecl *afd, Type resultType,
344323 }
345324 return LifetimeDependenceInfo::infer (afd, resultType);
346325}
326+
347327} // namespace swift
0 commit comments