mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Swift: Mangle function type lifetimes
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user