@@ -538,7 +538,7 @@ static Type getTypeForDWARFMangling(Type t) {
538
538
SubstFlags::AllowLoweredTypes);
539
539
}
540
540
541
- std::string ASTMangler::mangleTypeForDebugger (Type Ty, const DeclContext *DC ) {
541
+ std::string ASTMangler::mangleTypeForDebugger (Type Ty, GenericSignature sig ) {
542
542
PrettyStackTraceType prettyStackTrace (Ty->getASTContext (),
543
543
" mangling type for debugger" , Ty);
544
544
@@ -548,9 +548,7 @@ std::string ASTMangler::mangleTypeForDebugger(Type Ty, const DeclContext *DC) {
548
548
549
549
Ty = getTypeForDWARFMangling (Ty);
550
550
551
- if (DC)
552
- bindGenericParameters (DC);
553
-
551
+ bindGenericParameters (sig);
554
552
appendType (Ty);
555
553
appendOperator (" D" );
556
554
return finalize ();
@@ -676,7 +674,9 @@ std::string ASTMangler::mangleDeclAsUSR(const ValueDecl *Decl,
676
674
beginManglingWithoutPrefix ();
677
675
llvm::SaveAndRestore<bool > allowUnnamedRAII (AllowNamelessEntities, true );
678
676
Buffer << USRPrefix;
679
- bindGenericParameters (Decl->getDeclContext ());
677
+
678
+ auto Sig = Decl->getInnermostDeclContext ()->getGenericSignatureOfContext ();
679
+ bindGenericParameters (Sig);
680
680
681
681
if (auto Ctor = dyn_cast<ConstructorDecl>(Decl)) {
682
682
appendConstructorEntity (Ctor, /* isAllocating=*/ false );
@@ -1369,15 +1369,9 @@ void ASTMangler::appendOpWithGenericParamIndex(StringRef Op,
1369
1369
1370
1370
1371
1371
// / Bind the generic parameters from the given signature.
1372
- void ASTMangler::bindGenericParameters (CanGenericSignature sig) {
1372
+ void ASTMangler::bindGenericParameters (GenericSignature sig) {
1373
1373
if (sig)
1374
- CurGenericSignature = sig;
1375
- }
1376
-
1377
- // / Bind the generic parameters from the given context and its parents.
1378
- void ASTMangler::bindGenericParameters (const DeclContext *DC) {
1379
- if (auto sig = DC->getGenericSignatureOfContext ())
1380
- bindGenericParameters (sig.getCanonicalSignature ());
1374
+ CurGenericSignature = sig.getCanonicalSignature ();
1381
1375
}
1382
1376
1383
1377
void ASTMangler::appendFlatGenericArgs (SubstitutionMap subs) {
@@ -2853,12 +2847,13 @@ void ASTMangler::appendAccessorEntity(StringRef accessorKindCode,
2853
2847
const AbstractStorageDecl *decl,
2854
2848
bool isStatic) {
2855
2849
appendContextOf (decl);
2856
- bindGenericParameters (decl-> getDeclContext ());
2857
- if (isa<VarDecl>(decl)) {
2850
+ if ( auto *varDecl = dyn_cast<VarDecl>(decl)) {
2851
+ bindGenericParameters (varDecl-> getDeclContext ()-> getGenericSignatureOfContext ());
2858
2852
appendDeclName (decl);
2859
2853
appendDeclType (decl);
2860
2854
appendOperator (" v" , accessorKindCode);
2861
- } else if (isa<SubscriptDecl>(decl)) {
2855
+ } else if (auto *subscriptDecl = dyn_cast<SubscriptDecl>(decl)) {
2856
+ bindGenericParameters (subscriptDecl->getGenericSignature ());
2862
2857
appendDeclType (decl);
2863
2858
2864
2859
StringRef privateDiscriminator = getPrivateDiscriminatorIfNecessary (decl);
0 commit comments