Skip to content

Commit 1b5d15b

Browse files
committed
Swift: Mangle function type lifetimes
1 parent dcf715e commit 1b5d15b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

swift/extractor/mangler/SwiftMangler.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,40 @@ SwiftMangledName SwiftMangler::visitAnyFunctionType(const swift::AnyFunctionType
225225
ret << "...";
226226
}
227227
}
228+
229+
if (type->hasLifetimeDependencies()) {
230+
for (const auto& lifetime : type->getLifetimeDependencies()) {
231+
auto addressable = lifetime.getAddressableIndices();
232+
auto condAddressable = lifetime.getConditionallyAddressableIndices();
233+
ret << "_lifetime";
234+
235+
auto addIndexes = [&](swift::IndexSubset* bitvector) {
236+
for (unsigned i = 0; i < bitvector->getCapacity(); ++i) {
237+
if (bitvector->contains(i)) {
238+
if (addressable && addressable->contains(i)) {
239+
ret << "_address";
240+
} else if (condAddressable && condAddressable->contains(i)) {
241+
ret << "_address_for_deps";
242+
}
243+
ret << "_" << i;
244+
}
245+
}
246+
};
247+
248+
if (lifetime.hasInheritLifetimeParamIndices()) {
249+
ret << "_copy";
250+
addIndexes(lifetime.getInheritIndices());
251+
}
252+
if (lifetime.hasScopeLifetimeParamIndices()) {
253+
ret << "_borrow";
254+
addIndexes(lifetime.getScopeIndices());
255+
}
256+
if (lifetime.isImmortal()) {
257+
ret << "_immortal";
258+
}
259+
}
260+
}
261+
228262
ret << "->" << fetch(type->getResult());
229263
if (type->isAsync()) {
230264
ret << "_async";

0 commit comments

Comments
 (0)