Skip to content

Commit fee60ff

Browse files
committed
Revert "ABI Checker: include mangled names in ABI descriptor files"
This reverts commit a870b06.
1 parent 87e4607 commit fee60ff

File tree

9 files changed

+82
-364
lines changed

9 files changed

+82
-364
lines changed

include/swift/APIDigester/ModuleAnalyzerNodes.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ struct PlatformIntroVersion {
339339
class SDKNodeDecl: public SDKNode {
340340
DeclKind DKind;
341341
StringRef Usr;
342-
StringRef MangledName;
343342
SourceLoc Loc;
344343
StringRef Location;
345344
StringRef ModuleName;
@@ -464,7 +463,6 @@ class SDKNodeType: public SDKNode {
464463

465464
class SDKNodeTypeNominal : public SDKNodeType {
466465
StringRef USR;
467-
StringRef MangledName;
468466
public:
469467
SDKNodeTypeNominal(SDKNodeInitInfo Info);
470468
// Get the usr of the corresponding nominal type decl.
@@ -585,7 +583,6 @@ class SDKNodeDeclType: public SDKNodeDecl {
585583
/// in the conformance, thus getName() will give us the name of the protocol.
586584
class SDKNodeConformance: public SDKNode {
587585
StringRef Usr;
588-
StringRef MangledName;
589586
SDKNodeDeclType *TypeDecl;
590587
friend class SDKNodeDeclType;
591588
bool IsABIPlaceholder;

include/swift/AST/ASTMangler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ class ASTMangler : public Mangler {
271271

272272
std::string mangleTypeAsContextUSR(const NominalTypeDecl *type);
273273

274-
std::string mangleAnyDecl(const ValueDecl *Decl, bool prefix);
275274
std::string mangleDeclAsUSR(const ValueDecl *Decl, StringRef USRPrefix);
276275

277276
std::string mangleAccessorEntityAsUSR(AccessorKind kind,

include/swift/IDE/DigesterEnums.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ KEY(kind)
142142
KEY_STRING(Name, name)
143143
KEY_STRING(PrintedName, printedName)
144144
KEY_STRING(Usr, usr)
145-
KEY_STRING(MangledName, mangledName)
146145
KEY_STRING(Location, location)
147146
KEY_STRING(ModuleName, moduleName)
148147
KEY_STRING(SuperclassUsr, superclassUsr)

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "llvm/ADT/STLExtras.h"
22
#include "swift/Basic/Defer.h"
33
#include "swift/SIL/SILDeclRef.h"
4-
#include "swift/AST/ASTMangler.h"
54
#include <swift/APIDigester/ModuleAnalyzerNodes.h>
65
#include <algorithm>
76

@@ -99,8 +98,7 @@ SDKNodeRoot::SDKNodeRoot(SDKNodeInitInfo Info): SDKNode(Info, SDKNodeKind::Root)
9998
JsonFormatVer(Info.JsonFormatVer.hasValue() ? *Info.JsonFormatVer : DIGESTER_JSON_DEFAULT_VERSION) {}
10099

101100
SDKNodeDecl::SDKNodeDecl(SDKNodeInitInfo Info, SDKNodeKind Kind)
102-
: SDKNode(Info, Kind), DKind(Info.DKind), Usr(Info.Usr),
103-
MangledName(Info.MangledName), Loc(Info.Loc),
101+
: SDKNode(Info, Kind), DKind(Info.DKind), Usr(Info.Usr), Loc(Info.Loc),
104102
Location(Info.Location), ModuleName(Info.ModuleName),
105103
DeclAttributes(Info.DeclAttrs), IsImplicit(Info.IsImplicit),
106104
IsStatic(Info.IsStatic), IsDeprecated(Info.IsDeprecated),
@@ -122,8 +120,7 @@ SDKNodeType::SDKNodeType(SDKNodeInitInfo Info, SDKNodeKind Kind):
122120
ParamValueOwnership(Info.ParamValueOwnership) {}
123121

124122
SDKNodeTypeNominal::SDKNodeTypeNominal(SDKNodeInitInfo Info):
125-
SDKNodeType(Info, SDKNodeKind::TypeNominal), USR(Info.Usr),
126-
MangledName(Info.MangledName) {}
123+
SDKNodeType(Info, SDKNodeKind::TypeNominal), USR(Info.Usr) {}
127124

128125
SDKNodeTypeFunc::SDKNodeTypeFunc(SDKNodeInitInfo Info):
129126
SDKNodeType(Info, SDKNodeKind::TypeFunc) {}
@@ -142,8 +139,7 @@ SDKNodeDeclType::SDKNodeDeclType(SDKNodeInitInfo Info):
142139

143140
SDKNodeConformance::SDKNodeConformance(SDKNodeInitInfo Info):
144141
SDKNode(Info, SDKNodeKind::Conformance),
145-
Usr(Info.Usr), MangledName(Info.MangledName),
146-
IsABIPlaceholder(Info.IsABIPlaceholder) {}
142+
Usr(Info.Usr), IsABIPlaceholder(Info.IsABIPlaceholder) {}
147143

148144
SDKNodeTypeWitness::SDKNodeTypeWitness(SDKNodeInitInfo Info):
149145
SDKNode(Info, SDKNodeKind::TypeWitness) {}
@@ -1040,18 +1036,6 @@ static StringRef calculateUsr(SDKContext &Ctx, ValueDecl *VD) {
10401036
return StringRef();
10411037
}
10421038

1043-
static StringRef calculateMangledName(SDKContext &Ctx, ValueDecl *VD) {
1044-
if (isFromClang(VD)) {
1045-
// Don't mangle clang symbols.
1046-
return StringRef();
1047-
}
1048-
if (auto *attr = VD->getAttrs().getAttribute<SILGenNameAttr>()) {
1049-
return Ctx.buffer(attr->Name);
1050-
}
1051-
Mangle::ASTMangler NewMangler;
1052-
return Ctx.buffer(NewMangler.mangleAnyDecl(VD, false));
1053-
}
1054-
10551039
static StringRef calculateLocation(SDKContext &SDKCtx, Decl *D) {
10561040
if (SDKCtx.getOpts().AvoidLocation)
10571041
return StringRef();
@@ -1314,7 +1298,6 @@ SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, Type Ty, TypeInitInfo Info) :
13141298
// If this is a nominal type, get its Usr.
13151299
if (auto *ND = Ty->getAnyNominal()) {
13161300
Usr = calculateUsr(Ctx, ND);
1317-
MangledName = calculateMangledName(Ctx, ND);
13181301
}
13191302
}
13201303

@@ -1432,7 +1415,6 @@ SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, ValueDecl *VD)
14321415
Name = getSimpleName(VD);
14331416
PrintedName = getPrintedName(Ctx, VD);
14341417
Usr = calculateUsr(Ctx, VD);
1435-
MangledName = calculateMangledName(Ctx, VD);
14361418
IsThrowing = isFuncThrowing(VD);
14371419
IsStatic = VD->isStatic();
14381420
IsOverriding = VD->getOverriddenDecl();
@@ -1987,15 +1969,13 @@ void SDKNodeRoot::jsonize(json::Output &out) {
19871969
void SDKNodeConformance::jsonize(json::Output &out) {
19881970
SDKNode::jsonize(out);
19891971
output(out, KeyKind::KK_usr, Usr);
1990-
output(out, KeyKind::KK_mangledName, MangledName);
19911972
output(out, KeyKind::KK_isABIPlaceholder, IsABIPlaceholder);
19921973
}
19931974

19941975
void SDKNodeDecl::jsonize(json::Output &out) {
19951976
SDKNode::jsonize(out);
19961977
out.mapRequired(getKeyContent(Ctx, KeyKind::KK_declKind).data(), DKind);
19971978
output(out, KeyKind::KK_usr, Usr);
1998-
output(out, KeyKind::KK_mangledName, MangledName);
19991979
output(out, KeyKind::KK_location, Location);
20001980
output(out, KeyKind::KK_moduleName, ModuleName);
20011981
output(out, KeyKind::KK_genericSig, GenericSig);

lib/AST/ASTMangler.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -756,14 +756,16 @@ std::string ASTMangler::mangleTypeAsUSR(Type Ty) {
756756
return finalize();
757757
}
758758

759-
std::string ASTMangler::mangleAnyDecl(const ValueDecl *Decl, bool prefix) {
759+
std::string ASTMangler::mangleDeclAsUSR(const ValueDecl *Decl,
760+
StringRef USRPrefix) {
761+
#if SWIFT_BUILD_ONLY_SYNTAXPARSERLIB
762+
return std::string(); // not needed for the parser library.
763+
#endif
764+
760765
DWARFMangling = true;
761-
if (prefix) {
762-
beginMangling();
763-
} else {
764-
beginManglingWithoutPrefix();
765-
}
766+
beginManglingWithoutPrefix();
766767
llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true);
768+
Buffer << USRPrefix;
767769

768770
if (auto Ctor = dyn_cast<ConstructorDecl>(Decl)) {
769771
appendConstructorEntity(Ctor, /*isAllocating=*/false);
@@ -782,18 +784,10 @@ std::string ASTMangler::mangleAnyDecl(const ValueDecl *Decl, bool prefix) {
782784
// We have a custom prefix, so finalize() won't verify for us. If we're not
783785
// in invalid code (coming from an IDE caller) verify manually.
784786
if (!Decl->isInvalid())
785-
verify(Storage.str());
787+
verify(Storage.str().drop_front(USRPrefix.size()));
786788
return finalize();
787789
}
788790

789-
std::string ASTMangler::mangleDeclAsUSR(const ValueDecl *Decl,
790-
StringRef USRPrefix) {
791-
#if SWIFT_BUILD_ONLY_SYNTAXPARSERLIB
792-
return std::string(); // not needed for the parser library.
793-
#endif
794-
return (llvm::Twine(USRPrefix) + mangleAnyDecl(Decl, false)).str();
795-
}
796-
797791
std::string ASTMangler::mangleAccessorEntityAsUSR(AccessorKind kind,
798792
const AbstractStorageDecl *decl,
799793
StringRef USRPrefix,

test/api-digester/Inputs/cake.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,3 @@ extension SwiftObjcClass {
142142

143143
@_alwaysEmitIntoClient
144144
public func emitIntoClientFunc() {}
145-
146-
@_silgen_name("silgenName")
147-
public func silgenNamedFunc() {}

0 commit comments

Comments
 (0)