mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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.
This commit is contained in:
@@ -398,8 +398,7 @@ public:
|
|||||||
std::string mangleTypeAsContextUSR(const NominalTypeDecl *type);
|
std::string mangleTypeAsContextUSR(const NominalTypeDecl *type);
|
||||||
|
|
||||||
void appendAnyDecl(const ValueDecl *Decl);
|
void appendAnyDecl(const ValueDecl *Decl);
|
||||||
std::string mangleAnyDecl(const ValueDecl *Decl, bool prefix,
|
std::string mangleAnyDecl(const ValueDecl *decl, bool addPrefix);
|
||||||
bool respectOriginallyDefinedIn = false);
|
|
||||||
std::string mangleDeclAsUSR(const ValueDecl *Decl, StringRef USRPrefix);
|
std::string mangleDeclAsUSR(const ValueDecl *Decl, StringRef USRPrefix);
|
||||||
|
|
||||||
std::string mangleAccessorEntityAsUSR(AccessorKind kind,
|
std::string mangleAccessorEntityAsUSR(AccessorKind kind,
|
||||||
|
|||||||
@@ -1120,8 +1120,7 @@ static StringRef calculateMangledName(SDKContext &Ctx, ValueDecl *VD) {
|
|||||||
return Ctx.buffer(attr->Name);
|
return Ctx.buffer(attr->Name);
|
||||||
}
|
}
|
||||||
Mangle::ASTMangler NewMangler(VD->getASTContext());
|
Mangle::ASTMangler NewMangler(VD->getASTContext());
|
||||||
return Ctx.buffer(NewMangler.mangleAnyDecl(VD, true,
|
return Ctx.buffer(NewMangler.mangleAnyDecl(VD, /*addPrefix*/ true));
|
||||||
/*bool respectOriginallyDefinedIn*/true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static StringRef calculateLocation(SDKContext &SDKCtx, Decl *D) {
|
static StringRef calculateLocation(SDKContext &SDKCtx, Decl *D) {
|
||||||
|
|||||||
@@ -993,31 +993,28 @@ void ASTMangler::appendAnyDecl(const ValueDecl *Decl) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string ASTMangler::mangleAnyDecl(const ValueDecl *decl, bool addPrefix) {
|
||||||
ASTMangler::mangleAnyDecl(const ValueDecl *Decl,
|
|
||||||
bool prefix,
|
|
||||||
bool respectOriginallyDefinedIn) {
|
|
||||||
DWARFMangling = true;
|
DWARFMangling = true;
|
||||||
RespectOriginallyDefinedIn = respectOriginallyDefinedIn;
|
if (addPrefix) {
|
||||||
if (prefix) {
|
|
||||||
beginMangling();
|
beginMangling();
|
||||||
} else {
|
} else {
|
||||||
beginManglingWithoutPrefix();
|
beginManglingWithoutPrefix();
|
||||||
}
|
}
|
||||||
llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true);
|
llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true);
|
||||||
|
|
||||||
appendAnyDecl(Decl);
|
appendAnyDecl(decl);
|
||||||
|
|
||||||
// We have a custom prefix, so finalize() won't verify for us. If we're not
|
// We have a custom prefix, so finalize() won't verify for us. If we're not
|
||||||
// in invalid code (coming from an IDE caller) verify manually.
|
// in invalid code (coming from an IDE caller) verify manually.
|
||||||
if (CONDITIONAL_ASSERT_enabled() && !prefix && !Decl->isInvalid())
|
if (CONDITIONAL_ASSERT_enabled() && !addPrefix && !decl->isInvalid())
|
||||||
verify(Storage.str(), Flavor);
|
verify(Storage.str(), Flavor);
|
||||||
return finalize();
|
return finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ASTMangler::mangleDeclAsUSR(const ValueDecl *Decl,
|
std::string ASTMangler::mangleDeclAsUSR(const ValueDecl *Decl,
|
||||||
StringRef USRPrefix) {
|
StringRef USRPrefix) {
|
||||||
return (llvm::Twine(USRPrefix) + mangleAnyDecl(Decl, false)).str();
|
return (llvm::Twine(USRPrefix) + mangleAnyDecl(Decl, /*addPrefix*/ false))
|
||||||
|
.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ASTMangler::mangleAccessorEntityAsUSR(AccessorKind kind,
|
std::string ASTMangler::mangleAccessorEntityAsUSR(AccessorKind kind,
|
||||||
|
|||||||
@@ -1348,9 +1348,9 @@ void PrintAST::printAttributes(const Decl *D) {
|
|||||||
if (Options.PrintSyntheticSILGenName
|
if (Options.PrintSyntheticSILGenName
|
||||||
&& !D->getAttrs().hasAttribute<SILGenNameAttr>()) {
|
&& !D->getAttrs().hasAttribute<SILGenNameAttr>()) {
|
||||||
if (canPrintSyntheticSILGenName(D)) {
|
if (canPrintSyntheticSILGenName(D)) {
|
||||||
auto mangledName = Mangle::ASTMangler(D->getASTContext())
|
auto mangledName =
|
||||||
.mangleAnyDecl(cast<ValueDecl>(D), /*prefix=*/true,
|
Mangle::ASTMangler(D->getASTContext())
|
||||||
/*respectOriginallyDefinedIn=*/true);
|
.mangleAnyDecl(cast<ValueDecl>(D), /*addPrefix*/ true);
|
||||||
Printer.printAttrName("@_silgen_name");
|
Printer.printAttrName("@_silgen_name");
|
||||||
Printer << "(";
|
Printer << "(";
|
||||||
Printer.printEscapedStringLiteral(mangledName);
|
Printer.printEscapedStringLiteral(mangledName);
|
||||||
|
|||||||
@@ -155,8 +155,7 @@ static std::string getMangledNameString(const Decl *D) {
|
|||||||
if (!VD)
|
if (!VD)
|
||||||
return std::string();
|
return std::string();
|
||||||
Mangle::ASTMangler mangler(VD->getASTContext());
|
Mangle::ASTMangler mangler(VD->getASTContext());
|
||||||
return mangler.mangleAnyDecl(VD, /*prefix=*/true,
|
return mangler.mangleAnyDecl(VD, /*addPrefix*/ true);
|
||||||
/*respectOriginallyDefinedIn=*/true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string getTypeString(const ValueDecl *VD) {
|
static std::string getTypeString(const ValueDecl *VD) {
|
||||||
|
|||||||
Reference in New Issue
Block a user