Skip to content

Commit a1e1656

Browse files
committed
[AST] Remove respectOriginallyDefinedIn parameter from mangleAnyDecl
This was always set to `true` except for USR mangling, where we already have it set to `false` for IDE USRs. The other clients were: - AutoDiff, which is just using the resulting string as a dictionary key, so don't seem to have any preference. - The ClangImporter, which always overrides `@_originallyDefinedIn` anyway.
1 parent b607ec7 commit a1e1656

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

include/swift/AST/ASTMangler.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,7 @@ class ASTMangler : public Mangler {
398398
std::string mangleTypeAsContextUSR(const NominalTypeDecl *type);
399399

400400
void appendAnyDecl(const ValueDecl *Decl);
401-
std::string mangleAnyDecl(const ValueDecl *Decl, bool prefix,
402-
bool respectOriginallyDefinedIn = false);
401+
std::string mangleAnyDecl(const ValueDecl *decl, bool addPrefix);
403402
std::string mangleDeclAsUSR(const ValueDecl *Decl, StringRef USRPrefix);
404403

405404
std::string mangleAccessorEntityAsUSR(AccessorKind kind,

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,8 +1120,7 @@ static StringRef calculateMangledName(SDKContext &Ctx, ValueDecl *VD) {
11201120
return Ctx.buffer(attr->Name);
11211121
}
11221122
Mangle::ASTMangler NewMangler(VD->getASTContext());
1123-
return Ctx.buffer(NewMangler.mangleAnyDecl(VD, true,
1124-
/*bool respectOriginallyDefinedIn*/true));
1123+
return Ctx.buffer(NewMangler.mangleAnyDecl(VD, /*addPrefix*/ true));
11251124
}
11261125

11271126
static StringRef calculateLocation(SDKContext &SDKCtx, Decl *D) {

lib/AST/ASTMangler.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -993,31 +993,28 @@ void ASTMangler::appendAnyDecl(const ValueDecl *Decl) {
993993
}
994994
}
995995

996-
std::string
997-
ASTMangler::mangleAnyDecl(const ValueDecl *Decl,
998-
bool prefix,
999-
bool respectOriginallyDefinedIn) {
996+
std::string ASTMangler::mangleAnyDecl(const ValueDecl *decl, bool addPrefix) {
1000997
DWARFMangling = true;
1001-
RespectOriginallyDefinedIn = respectOriginallyDefinedIn;
1002-
if (prefix) {
998+
if (addPrefix) {
1003999
beginMangling();
10041000
} else {
10051001
beginManglingWithoutPrefix();
10061002
}
10071003
llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true);
10081004

1009-
appendAnyDecl(Decl);
1005+
appendAnyDecl(decl);
10101006

10111007
// We have a custom prefix, so finalize() won't verify for us. If we're not
10121008
// in invalid code (coming from an IDE caller) verify manually.
1013-
if (CONDITIONAL_ASSERT_enabled() && !prefix && !Decl->isInvalid())
1009+
if (CONDITIONAL_ASSERT_enabled() && !addPrefix && !decl->isInvalid())
10141010
verify(Storage.str(), Flavor);
10151011
return finalize();
10161012
}
10171013

10181014
std::string ASTMangler::mangleDeclAsUSR(const ValueDecl *Decl,
10191015
StringRef USRPrefix) {
1020-
return (llvm::Twine(USRPrefix) + mangleAnyDecl(Decl, false)).str();
1016+
return (llvm::Twine(USRPrefix) + mangleAnyDecl(Decl, /*addPrefix*/ false))
1017+
.str();
10211018
}
10221019

10231020
std::string ASTMangler::mangleAccessorEntityAsUSR(AccessorKind kind,

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,9 +1348,9 @@ void PrintAST::printAttributes(const Decl *D) {
13481348
if (Options.PrintSyntheticSILGenName
13491349
&& !D->getAttrs().hasAttribute<SILGenNameAttr>()) {
13501350
if (canPrintSyntheticSILGenName(D)) {
1351-
auto mangledName = Mangle::ASTMangler(D->getASTContext())
1352-
.mangleAnyDecl(cast<ValueDecl>(D), /*prefix=*/true,
1353-
/*respectOriginallyDefinedIn=*/true);
1351+
auto mangledName =
1352+
Mangle::ASTMangler(D->getASTContext())
1353+
.mangleAnyDecl(cast<ValueDecl>(D), /*addPrefix*/ true);
13541354
Printer.printAttrName("@_silgen_name");
13551355
Printer << "(";
13561356
Printer.printEscapedStringLiteral(mangledName);

lib/PrintAsClang/ModuleContentsWriter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ static std::string getMangledNameString(const Decl *D) {
155155
if (!VD)
156156
return std::string();
157157
Mangle::ASTMangler mangler(VD->getASTContext());
158-
return mangler.mangleAnyDecl(VD, /*prefix=*/true,
159-
/*respectOriginallyDefinedIn=*/true);
158+
return mangler.mangleAnyDecl(VD, /*addPrefix*/ true);
160159
}
161160

162161
static std::string getTypeString(const ValueDecl *VD) {

0 commit comments

Comments
 (0)