Skip to content

Commit 47b0b91

Browse files
committed
Remove hardcode to emit types in CompilerSwiftSyntax with ABI mod name
Now that mangling for the debugger respects originally defined in, this is not needed anymore. (cherry picked from commit f1d3bc8)
1 parent 2720862 commit 47b0b91

File tree

1 file changed

+25
-31
lines changed

1 file changed

+25
-31
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ std::string ASTMangler::mangleGlobalInit(const PatternBindingDecl *pd,
427427
unsigned pbdEntry,
428428
bool isInitFunc) {
429429
beginMangling();
430-
430+
431431
Pattern *pattern = pd->getPattern(pbdEntry);
432432
bool first = true;
433433
pattern->forEachVariable([&](VarDecl *D) {
@@ -440,13 +440,13 @@ std::string ASTMangler::mangleGlobalInit(const PatternBindingDecl *pd,
440440
appendListSeparator();
441441
});
442442
assert(!first && "no variables in pattern binding?!");
443-
443+
444444
if (isInitFunc) {
445445
appendOperator("WZ");
446446
} else {
447447
appendOperator("Wz");
448448
}
449-
449+
450450
return finalize();
451451
}
452452

@@ -474,7 +474,7 @@ std::string ASTMangler::mangleReabstractionThunkHelper(
474474
appendOperator("Ty");
475475
else
476476
appendOperator("TR");
477-
477+
478478
if (GlobalActorBound) {
479479
appendType(GlobalActorBound, GenSig);
480480
appendOperator("TU");
@@ -1303,7 +1303,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
13031303
appendType(bfa->getElementType(), sig, forDecl);
13041304
return appendOperator("BV");
13051305
}
1306-
1306+
13071307
case TypeKind::SILToken:
13081308
return appendOperator("Bt");
13091309
case TypeKind::BuiltinVector:
@@ -1580,7 +1580,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
15801580
return appendOpaqueTypeArchetype(
15811581
opaqueType, opaqueDecl, opaqueType->getSubstitutions(), sig, forDecl);
15821582
}
1583-
1583+
15841584
case TypeKind::DynamicSelf: {
15851585
auto dynamicSelf = cast<DynamicSelfType>(tybase);
15861586
if (dynamicSelf->getSelfType()->getAnyNominal()) {
@@ -1638,13 +1638,13 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
16381638
addTypeSubstitution(DepTy, sig);
16391639
return;
16401640
}
1641-
1641+
16421642
case TypeKind::Function:
16431643
appendFunctionType(cast<FunctionType>(tybase), sig,
16441644
/*autoclosure*/ false,
16451645
forDecl);
16461646
return;
1647-
1647+
16481648
case TypeKind::SILBox: {
16491649
auto box = cast<SILBoxType>(tybase);
16501650
auto layout = box->getLayout();
@@ -2094,7 +2094,7 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn,
20942094
if (fn->getInvocationSubstitutions()) {
20952095
OpArgs.push_back('I');
20962096
}
2097-
2097+
20982098
if (fn->isPolymorphic() && fn->isPseudogeneric())
20992099
OpArgs.push_back('P');
21002100

@@ -2201,7 +2201,7 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn,
22012201
}
22022202

22032203
GenericSignature sig = fn->getSubstGenericSignature();
2204-
2204+
22052205
// Mangle the parameters.
22062206
for (auto param : fn->getParameters()) {
22072207
OpArgs.push_back(getParamConvention(param.getConvention()));
@@ -2491,7 +2491,7 @@ void ASTMangler::appendContext(const DeclContext *ctx,
24912491
if (auto ctor = dyn_cast<ConstructorDecl>(fn)) {
24922492
return appendConstructorEntity(ctor, /*allocating*/ false);
24932493
}
2494-
2494+
24952495
if (auto dtor = dyn_cast<DestructorDecl>(fn))
24962496
return appendDestructorEntity(dtor, DestructorKind::NonDeallocating);
24972497

@@ -2507,7 +2507,7 @@ void ASTMangler::appendContext(const DeclContext *ctx,
25072507
auto sd = cast<SubscriptDecl>(ctx);
25082508
return appendEntity(sd);
25092509
}
2510-
2510+
25112511
case DeclContextKind::Initializer: {
25122512
switch (cast<Initializer>(ctx)->getInitializerKind()) {
25132513
case InitializerKind::DefaultArgument: {
@@ -2575,15 +2575,9 @@ void ASTMangler::appendModule(const ModuleDecl *module,
25752575
StringRef ModName = module->getRealName().str();
25762576

25772577
// If RespectOriginallyDefinedIn is not set, ignore the ABI name only for
2578-
// _Concurrency and swift-syntax (which adds "Compiler" as a prefix when
2579-
// building swift-syntax as part of the compiler).
2580-
// TODO: Mangling for the debugger should respect originally defined in, but
2581-
// as of right now there is not enough information in the mangled name to
2582-
// reconstruct AST types from mangled names when using that attribute.
2578+
// _Concurrency.
25832579
if ((RespectOriginallyDefinedIn ||
2584-
(module->getName().str() != SWIFT_CONCURRENCY_NAME &&
2585-
!module->getABIName().str().starts_with(
2586-
SWIFT_MODULE_ABI_NAME_PREFIX))) &&
2580+
module->getName().str() != SWIFT_CONCURRENCY_NAME) &&
25872581
module->getABIName() != module->getName())
25882582
ModName = module->getABIName().str();
25892583

@@ -2631,7 +2625,7 @@ void ASTMangler::appendProtocolName(const ProtocolDecl *protocol,
26312625
// Try to use a symbolic reference substitution.
26322626
if (tryMangleSubstitution(protocol))
26332627
return;
2634-
2628+
26352629
appendSymbolicReference(protocol);
26362630
// Substitutions can refer back to the symbolic reference.
26372631
addSubstitution(protocol);
@@ -2890,7 +2884,7 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl,
28902884
if (tryMangleSubstitution(cast<TypeAliasDecl>(decl)))
28912885
return;
28922886
}
2893-
2887+
28942888
// Try to mangle a symbolic reference for a nominal type.
28952889
if (nominal && canSymbolicReference(nominal)) {
28962890
appendSymbolicReference(nominal);
@@ -2924,7 +2918,7 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl,
29242918
// Mangle ObjC classes using their runtime names.
29252919
auto interface = dyn_cast<clang::ObjCInterfaceDecl>(namedDecl);
29262920
auto protocol = dyn_cast<clang::ObjCProtocolDecl>(namedDecl);
2927-
2921+
29282922
if (UseObjCRuntimeNames && interface) {
29292923
appendIdentifier(interface->getObjCRuntimeNameAsString());
29302924
} else if (UseObjCRuntimeNames && protocol) {
@@ -3176,7 +3170,7 @@ getDefaultOwnership(const ValueDecl *forDecl) {
31763170
if (!forFuncDecl) {
31773171
return ParamSpecifier::Borrowing;
31783172
}
3179-
3173+
31803174
if (isa<ConstructorDecl>(forFuncDecl)) {
31813175
return ParamSpecifier::Consuming;
31823176
} else if (auto accessor = dyn_cast<AccessorDecl>(forFuncDecl)) {
@@ -3188,7 +3182,7 @@ getDefaultOwnership(const ValueDecl *forDecl) {
31883182
return ParamSpecifier::Borrowing;
31893183
}
31903184
}
3191-
3185+
31923186
return ParamSpecifier::Borrowing;
31933187
}
31943188

@@ -3238,7 +3232,7 @@ void ASTMangler::appendFunctionInputType(
32383232
AnyFunctionType *fnType, ArrayRef<AnyFunctionType::Param> params,
32393233
GenericSignature sig, const ValueDecl *forDecl, bool isRecursedInto) {
32403234
auto defaultSpecifier = getDefaultOwnership(forDecl);
3241-
3235+
32423236
switch (params.size()) {
32433237
case 0:
32443238
appendOperator("y");
@@ -3688,7 +3682,7 @@ void ASTMangler::appendGenericSignatureParts(
36883682
// Mangle the number of parameters.
36893683
unsigned depth = 0;
36903684
unsigned count = 0;
3691-
3685+
36923686
// Since it's unlikely (but not impossible) to have zero generic parameters
36933687
// at a depth, encode indexes starting from 1, and use a special mangling
36943688
// for zero.
@@ -3700,7 +3694,7 @@ void ASTMangler::appendGenericSignatureParts(
37003694
else
37013695
OpBuffer << Index(count - 1);
37023696
};
3703-
3697+
37043698
// As a special case, mangle nothing if there's a single generic parameter
37053699
// at the initial depth.
37063700
for (auto param : params) {
@@ -3950,7 +3944,7 @@ void ASTMangler::appendDeclType(const ValueDecl *decl,
39503944
} else {
39513945
appendType(type, sig, decl);
39523946
}
3953-
3947+
39543948
// Mangle the generic signature, if any.
39553949
if (genericSig
39563950
&& appendGenericSignature(genericSig, parentGenericSig, base)) {
@@ -4053,7 +4047,7 @@ void ASTMangler::appendEntity(const ValueDecl *decl,
40534047
void ASTMangler::appendEntity(const ValueDecl *decl) {
40544048
assert(!isa<ConstructorDecl>(decl));
40554049
assert(!isa<DestructorDecl>(decl));
4056-
4050+
40574051
// Handle accessors specially, they are mangled as modifiers on the accessed
40584052
// declaration.
40594053
if (auto accessor = dyn_cast<AccessorDecl>(decl)) {
@@ -4601,7 +4595,7 @@ void ASTMangler::appendMacroExpansionContext(
46014595
case GeneratedSourceInfo::AttributeFromClang:
46024596
return appendMacroExpansionLoc();
46034597
}
4604-
4598+
46054599
switch (generatedSourceInfo->kind) {
46064600
// Freestanding macros
46074601
#define FREESTANDING_MACRO_ROLE(Name, Description) \

0 commit comments

Comments
 (0)