@@ -52,8 +52,8 @@ SwiftMangledName SwiftMangler::visitModuleDecl(const swift::ModuleDecl* decl) {
5252 return ret;
5353}
5454
55- SwiftMangledName SwiftMangler::visitValueDecl (const swift::ValueDecl* decl) {
56- if (!decl->hasName () || decl->getDeclContext ()->isLocalContext ()) {
55+ SwiftMangledName SwiftMangler::visitValueDecl (const swift::ValueDecl* decl, bool force ) {
56+ if (!force && (! decl->hasName () || decl->getDeclContext ()->isLocalContext () )) {
5757 return {};
5858 }
5959 auto ret = initMangled (decl);
@@ -91,8 +91,12 @@ SwiftMangledName SwiftMangler::visitExtensionDecl(const swift::ExtensionDecl* de
9191 if (decl->getDeclContext ()->isLocalContext ()) {
9292 return {};
9393 }
94- auto ret = initMangled (decl);
9594 auto extended = decl->getExtendedNominal ();
95+ if (!extended) {
96+ // may happen in incomplete ASTs
97+ return {};
98+ }
99+ auto ret = initMangled (decl);
96100 ret << dispatcher.fetchLabel (extended);
97101 // get the index of all extensions of the same nominal type within this decl's module
98102 auto index = 0u ;
@@ -110,26 +114,25 @@ SwiftMangledName SwiftMangler::visitExtensionDecl(const swift::ExtensionDecl* de
110114}
111115
112116SwiftMangledName SwiftMangler::visitGenericTypeDecl (const swift::GenericTypeDecl* decl) {
113- if (auto ret = visitValueDecl (decl)) {
114- if (auto genericParams = decl->getGenericParams ()) {
115- ret << ' <' << genericParams->size () << ' >' ;
116- }
117- // TODO: almost same code as for function type
118- if (!decl->getGenericRequirements ().empty ()) {
119- ret << " where_" ;
120- for (const auto & req : decl->getGenericRequirements ()) {
121- ret << dispatcher.fetchLabel (req.getFirstType ()->getCanonicalType ());
122- ret << (req.getKind () == swift::RequirementKind::SameType ? ' =' : ' :' );
123- if (req.getKind () == swift::RequirementKind::Layout) {
124- ret << ' (' << req.getLayoutConstraint ().getString () << ' )' ;
125- } else {
126- ret << dispatcher.fetchLabel (req.getSecondType ()->getCanonicalType ());
127- }
128- }
129- }
130- return ret;
117+ auto ret = visitValueDecl (decl);
118+ if (!ret) {
119+ return {};
131120 }
132- return {};
121+ if (auto genericParams = decl->getParsedGenericParams ()) {
122+ ret << ' <' << genericParams->size () << ' >' ;
123+ }
124+ return ret;
125+ }
126+
127+ SwiftMangledName SwiftMangler::visitAbstractTypeParamDecl (
128+ const swift::AbstractTypeParamDecl* decl) {
129+ return visitValueDecl (decl, /* force */ true );
130+ }
131+
132+ SwiftMangledName SwiftMangler::visitGenericTypeParamDecl (const swift::GenericTypeParamDecl* decl) {
133+ auto ret = visitAbstractTypeParamDecl (decl);
134+ ret << ' _' << decl->getDepth () << ' _' << decl->getIndex ();
135+ return ret;
133136}
134137
135138SwiftMangledName SwiftMangler::visitModuleType (const swift::ModuleType* type) {
@@ -151,15 +154,15 @@ SwiftMangledName SwiftMangler::visitTupleType(const swift::TupleType* type) {
151154
152155SwiftMangledName SwiftMangler::visitBuiltinType (const swift::BuiltinType* type) {
153156 auto ret = initMangled (type);
154- ret << dispatcher.fetchLabel (type->getASTContext ().TheBuiltinModule );
155157 llvm::SmallString<32 > buffer;
156158 ret << type->getTypeName (buffer, /* prependBuiltinNamespace= */ false );
157159 return ret;
158160}
159161
160162SwiftMangledName SwiftMangler::visitAnyGenericType (const swift::AnyGenericType* type) {
161163 auto ret = initMangled (type);
162- ret << dispatcher.fetchLabel (type->getDecl ());
164+ auto decl = type->getDecl ();
165+ ret << dispatcher.fetchLabel (decl);
163166 if (auto parent = type->getParent ()) {
164167 ret << dispatcher.fetchLabel (parent);
165168 }
@@ -189,6 +192,9 @@ SwiftMangledName SwiftMangler::visitAnyFunctionType(const swift::AnyFunctionType
189192 if (param.isOwned ()) {
190193 ret << " _owned" ;
191194 }
195+ if (param.isShared ()) {
196+ ret << " _shared" ;
197+ }
192198 if (param.isVariadic ()) {
193199 ret << " ..." ;
194200 }
@@ -203,6 +209,9 @@ SwiftMangledName SwiftMangler::visitAnyFunctionType(const swift::AnyFunctionType
203209 if (type->isSendable ()) {
204210 ret << " _sendable" ;
205211 }
212+ if (type->isNoEscape ()) {
213+ ret << " _noescape" ;
214+ }
206215 // TODO: see if this needs to be used in identifying types, if not it needs to be removed from
207216 // type printing
208217 assert (type->hasExtInfo () && " type must have ext info" );
@@ -287,9 +296,14 @@ SwiftMangledName SwiftMangler::visitDictionaryType(const swift::DictionaryType*
287296SwiftMangledName SwiftMangler::visitTypeAliasType (const swift::TypeAliasType* type) {
288297 auto ret = initMangled (type);
289298 ret << dispatcher.fetchLabel (type->getDecl ());
299+ if (auto parent = type->getParent ()) {
300+ ret << dispatcher.fetchLabel (parent);
301+ }
302+ ret << ' <' ;
290303 for (auto replacement : type->getSubstitutionMap ().getReplacementTypes ()) {
291304 ret << dispatcher.fetchLabel (replacement);
292305 }
306+ ret << ' >' ;
293307 return ret;
294308}
295309
@@ -300,6 +314,13 @@ SwiftMangledName SwiftMangler::visitArchetypeType(const swift::ArchetypeType* ty
300314 return ret;
301315}
302316
317+ SwiftMangledName SwiftMangler::visitOpaqueTypeArchetypeType (
318+ const swift::OpaqueTypeArchetypeType* type) {
319+ auto ret = visitArchetypeType (type);
320+ ret << dispatcher.fetchLabel (type->getDecl ());
321+ return ret;
322+ }
323+
303324SwiftMangledName SwiftMangler::visitProtocolCompositionType (
304325 const swift::ProtocolCompositionType* type) {
305326 auto ret = initMangled (type);
0 commit comments