Skip to content

Commit f1d3bc8

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.
1 parent d75bde3 commit f1d3bc8

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");
@@ -1304,7 +1304,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
13041304
appendType(bfa->getElementType(), sig, forDecl);
13051305
return appendOperator("BV");
13061306
}
1307-
1307+
13081308
case TypeKind::SILToken:
13091309
return appendOperator("Bt");
13101310
case TypeKind::BuiltinVector:
@@ -1596,7 +1596,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
15961596
return appendOpaqueTypeArchetype(
15971597
opaqueType, opaqueDecl, opaqueType->getSubstitutions(), sig, forDecl);
15981598
}
1599-
1599+
16001600
case TypeKind::DynamicSelf: {
16011601
auto dynamicSelf = cast<DynamicSelfType>(tybase);
16021602
if (dynamicSelf->getSelfType()->getAnyNominal()) {
@@ -1654,13 +1654,13 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
16541654
addTypeSubstitution(DepTy, sig);
16551655
return;
16561656
}
1657-
1657+
16581658
case TypeKind::Function:
16591659
appendFunctionType(cast<FunctionType>(tybase), sig,
16601660
/*autoclosure*/ false,
16611661
forDecl);
16621662
return;
1663-
1663+
16641664
case TypeKind::SILBox: {
16651665
auto box = cast<SILBoxType>(tybase);
16661666
auto layout = box->getLayout();
@@ -2110,7 +2110,7 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn,
21102110
if (fn->getInvocationSubstitutions()) {
21112111
OpArgs.push_back('I');
21122112
}
2113-
2113+
21142114
if (fn->isPolymorphic() && fn->isPseudogeneric())
21152115
OpArgs.push_back('P');
21162116

@@ -2217,7 +2217,7 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn,
22172217
}
22182218

22192219
GenericSignature sig = fn->getSubstGenericSignature();
2220-
2220+
22212221
// Mangle the parameters.
22222222
for (auto param : fn->getParameters()) {
22232223
OpArgs.push_back(getParamConvention(param.getConvention()));
@@ -2507,7 +2507,7 @@ void ASTMangler::appendContext(const DeclContext *ctx,
25072507
if (auto ctor = dyn_cast<ConstructorDecl>(fn)) {
25082508
return appendConstructorEntity(ctor, /*allocating*/ false);
25092509
}
2510-
2510+
25112511
if (auto dtor = dyn_cast<DestructorDecl>(fn))
25122512
return appendDestructorEntity(dtor, DestructorKind::NonDeallocating);
25132513

@@ -2523,7 +2523,7 @@ void ASTMangler::appendContext(const DeclContext *ctx,
25232523
auto sd = cast<SubscriptDecl>(ctx);
25242524
return appendEntity(sd);
25252525
}
2526-
2526+
25272527
case DeclContextKind::Initializer: {
25282528
switch (cast<Initializer>(ctx)->getInitializerKind()) {
25292529
case InitializerKind::DefaultArgument: {
@@ -2591,15 +2591,9 @@ void ASTMangler::appendModule(const ModuleDecl *module,
25912591
StringRef ModName = module->getRealName().str();
25922592

25932593
// If RespectOriginallyDefinedIn is not set, ignore the ABI name only for
2594-
// _Concurrency and swift-syntax (which adds "Compiler" as a prefix when
2595-
// building swift-syntax as part of the compiler).
2596-
// TODO: Mangling for the debugger should respect originally defined in, but
2597-
// as of right now there is not enough information in the mangled name to
2598-
// reconstruct AST types from mangled names when using that attribute.
2594+
// _Concurrency.
25992595
if ((RespectOriginallyDefinedIn ||
2600-
(module->getName().str() != SWIFT_CONCURRENCY_NAME &&
2601-
!module->getABIName().str().starts_with(
2602-
SWIFT_MODULE_ABI_NAME_PREFIX))) &&
2596+
module->getName().str() != SWIFT_CONCURRENCY_NAME) &&
26032597
module->getABIName() != module->getName())
26042598
ModName = module->getABIName().str();
26052599

@@ -2647,7 +2641,7 @@ void ASTMangler::appendProtocolName(const ProtocolDecl *protocol,
26472641
// Try to use a symbolic reference substitution.
26482642
if (tryMangleSubstitution(protocol))
26492643
return;
2650-
2644+
26512645
appendSymbolicReference(protocol);
26522646
// Substitutions can refer back to the symbolic reference.
26532647
addSubstitution(protocol);
@@ -2906,7 +2900,7 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl,
29062900
if (tryMangleSubstitution(cast<TypeAliasDecl>(decl)))
29072901
return;
29082902
}
2909-
2903+
29102904
// Try to mangle a symbolic reference for a nominal type.
29112905
if (nominal && canSymbolicReference(nominal)) {
29122906
appendSymbolicReference(nominal);
@@ -2940,7 +2934,7 @@ void ASTMangler::appendAnyGenericType(const GenericTypeDecl *decl,
29402934
// Mangle ObjC classes using their runtime names.
29412935
auto interface = dyn_cast<clang::ObjCInterfaceDecl>(namedDecl);
29422936
auto protocol = dyn_cast<clang::ObjCProtocolDecl>(namedDecl);
2943-
2937+
29442938
if (UseObjCRuntimeNames && interface) {
29452939
appendIdentifier(interface->getObjCRuntimeNameAsString());
29462940
} else if (UseObjCRuntimeNames && protocol) {
@@ -3192,7 +3186,7 @@ getDefaultOwnership(const ValueDecl *forDecl) {
31923186
if (!forFuncDecl) {
31933187
return ParamSpecifier::Borrowing;
31943188
}
3195-
3189+
31963190
if (isa<ConstructorDecl>(forFuncDecl)) {
31973191
return ParamSpecifier::Consuming;
31983192
} else if (auto accessor = dyn_cast<AccessorDecl>(forFuncDecl)) {
@@ -3204,7 +3198,7 @@ getDefaultOwnership(const ValueDecl *forDecl) {
32043198
return ParamSpecifier::Borrowing;
32053199
}
32063200
}
3207-
3201+
32083202
return ParamSpecifier::Borrowing;
32093203
}
32103204

@@ -3254,7 +3248,7 @@ void ASTMangler::appendFunctionInputType(
32543248
AnyFunctionType *fnType, ArrayRef<AnyFunctionType::Param> params,
32553249
GenericSignature sig, const ValueDecl *forDecl, bool isRecursedInto) {
32563250
auto defaultSpecifier = getDefaultOwnership(forDecl);
3257-
3251+
32583252
switch (params.size()) {
32593253
case 0:
32603254
appendOperator("y");
@@ -3704,7 +3698,7 @@ void ASTMangler::appendGenericSignatureParts(
37043698
// Mangle the number of parameters.
37053699
unsigned depth = 0;
37063700
unsigned count = 0;
3707-
3701+
37083702
// Since it's unlikely (but not impossible) to have zero generic parameters
37093703
// at a depth, encode indexes starting from 1, and use a special mangling
37103704
// for zero.
@@ -3716,7 +3710,7 @@ void ASTMangler::appendGenericSignatureParts(
37163710
else
37173711
OpBuffer << Index(count - 1);
37183712
};
3719-
3713+
37203714
// As a special case, mangle nothing if there's a single generic parameter
37213715
// at the initial depth.
37223716
for (auto param : params) {
@@ -3966,7 +3960,7 @@ void ASTMangler::appendDeclType(const ValueDecl *decl,
39663960
} else {
39673961
appendType(type, sig, decl);
39683962
}
3969-
3963+
39703964
// Mangle the generic signature, if any.
39713965
if (genericSig
39723966
&& appendGenericSignature(genericSig, parentGenericSig, base)) {
@@ -4069,7 +4063,7 @@ void ASTMangler::appendEntity(const ValueDecl *decl,
40694063
void ASTMangler::appendEntity(const ValueDecl *decl) {
40704064
assert(!isa<ConstructorDecl>(decl));
40714065
assert(!isa<DestructorDecl>(decl));
4072-
4066+
40734067
// Handle accessors specially, they are mangled as modifiers on the accessed
40744068
// declaration.
40754069
if (auto accessor = dyn_cast<AccessorDecl>(decl)) {
@@ -4616,7 +4610,7 @@ void ASTMangler::appendMacroExpansionContext(
46164610
case GeneratedSourceInfo::AttributeFromClang:
46174611
return appendMacroExpansionLoc();
46184612
}
4619-
4613+
46204614
switch (generatedSourceInfo->kind) {
46214615
// Freestanding macros
46224616
#define FREESTANDING_MACRO_ROLE(Name, Description) \

0 commit comments

Comments
 (0)