Swift: Mangle function type lifetimes

This commit is contained in:
Jeroen Ketema
2025-09-16 16:20:18 +02:00
parent e79c0b0405
commit 300b5b15e7

View File

@@ -225,6 +225,40 @@ SwiftMangledName SwiftMangler::visitAnyFunctionType(const swift::AnyFunctionType
ret << "...";
}
}
if (type->hasLifetimeDependencies()) {
for (const auto& lifetime : type->getLifetimeDependencies()) {
auto addressable = lifetime.getAddressableIndices();
auto condAddressable = lifetime.getConditionallyAddressableIndices();
ret << "_lifetime";
auto addIndexes = [&](swift::IndexSubset* bitvector) {
for (unsigned i = 0; i < bitvector->getCapacity(); ++i) {
if (bitvector->contains(i)) {
if (addressable && addressable->contains(i)) {
ret << "_address";
} else if (condAddressable && condAddressable->contains(i)) {
ret << "_address_for_deps";
}
ret << "_" << i;
}
}
};
if (lifetime.hasInheritLifetimeParamIndices()) {
ret << "_copy";
addIndexes(lifetime.getInheritIndices());
}
if (lifetime.hasScopeLifetimeParamIndices()) {
ret << "_borrow";
addIndexes(lifetime.getScopeIndices());
}
if (lifetime.isImmortal()) {
ret << "_immortal";
}
}
}
ret << "->" << fetch(type->getResult());
if (type->isAsync()) {
ret << "_async";