Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2592129

Browse files
committed
Swift: mangle remaining unmangled types appearing during test run
1 parent c8ca605 commit 2592129

3 files changed

Lines changed: 108 additions & 181 deletions

File tree

swift/extractor/mangler/SwiftMangler.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ SwiftMangledName SwiftMangler::visitBuiltinType(const swift::BuiltinType* type)
160160
SwiftMangledName SwiftMangler::visitAnyGenericType(const swift::AnyGenericType* type) {
161161
auto ret = initMangled(type);
162162
ret << dispatcher.fetchLabel(type->getDecl());
163+
if (auto parent = type->getParent()) {
164+
ret << dispatcher.fetchLabel(parent);
165+
}
163166
return ret;
164167
}
165168

@@ -284,6 +287,9 @@ SwiftMangledName SwiftMangler::visitDictionaryType(const swift::DictionaryType*
284287
SwiftMangledName SwiftMangler::visitTypeAliasType(const swift::TypeAliasType* type) {
285288
auto ret = initMangled(type);
286289
ret << dispatcher.fetchLabel(type->getDecl());
290+
for (auto replacement : type->getSubstitutionMap().getReplacementTypes()) {
291+
ret << dispatcher.fetchLabel(replacement);
292+
}
287293
return ret;
288294
}
289295

@@ -293,3 +299,45 @@ SwiftMangledName SwiftMangler::visitArchetypeType(const swift::ArchetypeType* ty
293299
ret << dispatcher.fetchLabel(type->getInterfaceType());
294300
return ret;
295301
}
302+
303+
SwiftMangledName SwiftMangler::visitProtocolCompositionType(
304+
const swift::ProtocolCompositionType* type) {
305+
auto ret = initMangled(type);
306+
for (auto composed : type->getMembers()) {
307+
ret << dispatcher.fetchLabel(composed);
308+
}
309+
if (type->hasExplicitAnyObject()) {
310+
ret << "&AnyObject";
311+
}
312+
return ret;
313+
}
314+
315+
SwiftMangledName SwiftMangler::visitParenType(const swift::ParenType* type) {
316+
auto ret = initMangled(type);
317+
ret << dispatcher.fetchLabel(type->getUnderlyingType());
318+
return ret;
319+
}
320+
321+
SwiftMangledName SwiftMangler::visitLValueType(const swift::LValueType* type) {
322+
auto ret = initMangled(type);
323+
ret << dispatcher.fetchLabel(type->getObjectType());
324+
return ret;
325+
}
326+
327+
SwiftMangledName SwiftMangler::visitDynamicSelfType(const swift::DynamicSelfType* type) {
328+
auto ret = initMangled(type);
329+
ret << dispatcher.fetchLabel(type->getSelfType());
330+
return ret;
331+
}
332+
333+
SwiftMangledName SwiftMangler::visitUnboundGenericType(const swift::UnboundGenericType* type) {
334+
auto ret = initMangled(type);
335+
ret << dispatcher.fetchLabel(type->getDecl());
336+
return ret;
337+
}
338+
339+
SwiftMangledName SwiftMangler::visitReferenceStorageType(const swift::ReferenceStorageType* type) {
340+
auto ret = initMangled(type);
341+
ret << dispatcher.fetchLabel(type->getReferentType());
342+
return ret;
343+
}

swift/extractor/mangler/SwiftMangler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ class SwiftMangler : private swift::TypeVisitor<SwiftMangler, SwiftMangledName>,
7979
SwiftMangledName visitDictionaryType(const swift::DictionaryType* type);
8080
SwiftMangledName visitTypeAliasType(const swift::TypeAliasType* type);
8181
SwiftMangledName visitArchetypeType(const swift::ArchetypeType* type);
82+
SwiftMangledName visitProtocolCompositionType(const swift::ProtocolCompositionType* type);
83+
SwiftMangledName visitParenType(const swift::ParenType* type);
84+
SwiftMangledName visitLValueType(const swift::LValueType* type);
85+
SwiftMangledName visitDynamicSelfType(const swift::DynamicSelfType* type);
86+
SwiftMangledName visitUnboundGenericType(const swift::UnboundGenericType* type);
87+
SwiftMangledName visitReferenceStorageType(const swift::ReferenceStorageType* type);
8288

8389
private:
8490
static SwiftMangledName initMangled(const swift::TypeBase* type);

0 commit comments

Comments
 (0)