@@ -88,7 +88,7 @@ std::string ASTMangler::mangleClosureEntity(const AbstractClosureExpr *closure,
8888
8989std::string ASTMangler::mangleEntity (const ValueDecl *decl, SymbolKind SKind) {
9090 beginMangling ();
91- appendEntity (decl);
91+ appendEntity (decl, SKind == SymbolKind::AsyncHandlerBody );
9292 appendSymbolKind (SKind);
9393 return finalize ();
9494}
@@ -657,7 +657,7 @@ std::string ASTMangler::mangleTypeAsUSR(Type Ty) {
657657 Ty = getTypeForDWARFMangling (Ty);
658658
659659 if (auto *fnType = Ty->getAs <AnyFunctionType>()) {
660- appendFunction (fnType, false );
660+ appendFunction (fnType);
661661 } else {
662662 appendType (Ty);
663663 }
@@ -744,6 +744,7 @@ std::string ASTMangler::mangleOpaqueTypeDecl(const ValueDecl *decl) {
744744void ASTMangler::appendSymbolKind (SymbolKind SKind) {
745745 switch (SKind) {
746746 case SymbolKind::Default: return ;
747+ case SymbolKind::AsyncHandlerBody: return ;
747748 case SymbolKind::DynamicThunk: return appendOperator (" TD" );
748749 case SymbolKind::SwiftAsObjCThunk: return appendOperator (" To" );
749750 case SymbolKind::ObjCAsSwiftThunk: return appendOperator (" TO" );
@@ -2249,7 +2250,8 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl) {
22492250 addSubstitution (cast<TypeAliasDecl>(decl));
22502251}
22512252
2252- void ASTMangler::appendFunction (AnyFunctionType *fn, bool isFunctionMangling,
2253+ void ASTMangler::appendFunction (AnyFunctionType *fn,
2254+ FunctionManglingKind functionMangling,
22532255 const ValueDecl *forDecl) {
22542256 // Append parameter labels right before the signature/type.
22552257 auto parameters = fn->getParams ();
@@ -2269,8 +2271,8 @@ void ASTMangler::appendFunction(AnyFunctionType *fn, bool isFunctionMangling,
22692271 appendOperator (" y" );
22702272 }
22712273
2272- if (isFunctionMangling ) {
2273- appendFunctionSignature (fn, forDecl);
2274+ if (functionMangling != NoFunctionMangling ) {
2275+ appendFunctionSignature (fn, forDecl, functionMangling );
22742276 } else {
22752277 appendFunctionType (fn, /* autoclosure*/ false , forDecl);
22762278 }
@@ -2281,7 +2283,7 @@ void ASTMangler::appendFunctionType(AnyFunctionType *fn, bool isAutoClosure,
22812283 assert ((DWARFMangling || fn->isCanonical ()) &&
22822284 " expecting canonical types when not mangling for the debugger" );
22832285
2284- appendFunctionSignature (fn, forDecl);
2286+ appendFunctionSignature (fn, forDecl, NoFunctionMangling );
22852287
22862288 bool mangleClangType = fn->getASTContext ().LangOpts .UseClangFunctionTypes &&
22872289 fn->hasNonDerivableClangType ();
@@ -2359,10 +2361,11 @@ void ASTMangler::appendClangType(AnyFunctionType *fn) {
23592361}
23602362
23612363void ASTMangler::appendFunctionSignature (AnyFunctionType *fn,
2362- const ValueDecl *forDecl) {
2364+ const ValueDecl *forDecl,
2365+ FunctionManglingKind functionMangling) {
23632366 appendFunctionResultType (fn->getResult (), forDecl);
23642367 appendFunctionInputType (fn->getParams (), forDecl);
2365- if (fn->isAsync ())
2368+ if (fn->isAsync () || functionMangling == AsyncHandlerBodyMangling )
23662369 appendOperator (" Y" );
23672370 if (fn->isThrowing ())
23682371 appendOperator (" K" );
@@ -2780,22 +2783,23 @@ CanType ASTMangler::getDeclTypeForMangling(
27802783 return canTy;
27812784}
27822785
2783- void ASTMangler::appendDeclType (const ValueDecl *decl, bool isFunctionMangling) {
2786+ void ASTMangler::appendDeclType (const ValueDecl *decl,
2787+ FunctionManglingKind functionMangling) {
27842788 Mod = decl->getModuleContext ();
27852789 GenericSignature genericSig;
27862790 GenericSignature parentGenericSig;
27872791 auto type = getDeclTypeForMangling (decl, genericSig, parentGenericSig);
27882792
27892793 if (AnyFunctionType *FuncTy = type->getAs <AnyFunctionType>()) {
2790- appendFunction (FuncTy, isFunctionMangling , decl);
2794+ appendFunction (FuncTy, functionMangling , decl);
27912795 } else {
27922796 appendType (type, decl);
27932797 }
27942798
27952799 // Mangle the generic signature, if any.
27962800 if (genericSig && appendGenericSignature (genericSig, parentGenericSig)) {
27972801 // The 'F' function mangling doesn't need a 'u' for its generic signature.
2798- if (!isFunctionMangling )
2802+ if (functionMangling == NoFunctionMangling )
27992803 appendOperator (" u" );
28002804 }
28012805}
@@ -2870,7 +2874,7 @@ void ASTMangler::appendEntity(const ValueDecl *decl, StringRef EntityOp,
28702874 appendOperator (" Z" );
28712875}
28722876
2873- void ASTMangler::appendEntity (const ValueDecl *decl) {
2877+ void ASTMangler::appendEntity (const ValueDecl *decl, bool isAsyncHandlerBody ) {
28742878 assert (!isa<ConstructorDecl>(decl));
28752879 assert (!isa<DestructorDecl>(decl));
28762880
@@ -2891,7 +2895,8 @@ void ASTMangler::appendEntity(const ValueDecl *decl) {
28912895
28922896 appendContextOf (decl);
28932897 appendDeclName (decl);
2894- appendDeclType (decl, /* isFunctionMangling*/ true );
2898+ appendDeclType (decl, isAsyncHandlerBody ? AsyncHandlerBodyMangling
2899+ : FunctionMangling);
28952900 appendOperator (" F" );
28962901 if (decl->isStatic ())
28972902 appendOperator (" Z" );
0 commit comments