Skip to content

Commit 34c020d

Browse files
committed
Revert "Emit mangled names for public symbols into the .swiftinterface"
This reverts commit 0aff85c.
1 parent 7ffa5c3 commit 34c020d

File tree

7 files changed

+13
-130
lines changed

7 files changed

+13
-130
lines changed

Diff for: include/swift/AST/PrintOptions.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -531,10 +531,6 @@ struct PrintOptions {
531531
/// with types sharing a name with a module.
532532
bool AliasModuleNames = false;
533533

534-
/// Print some ABI details for public symbols as comments that can be
535-
/// parsed by another tool.
536-
bool PrintABIComments = false;
537-
538534
/// Name of the modules that have been aliased in AliasModuleNames mode.
539535
/// Ideally we would use something other than a string to identify a module,
540536
/// but since one alias can apply to more than one module, strings happen
@@ -725,8 +721,7 @@ struct PrintOptions {
725721
bool useExportedModuleNames,
726722
bool aliasModuleNames,
727723
llvm::SmallSet<StringRef, 4>
728-
*aliasModuleNamesTargets,
729-
bool abiComments
724+
*aliasModuleNamesTargets
730725
);
731726

732727
/// Retrieve the set of options suitable for "Generated Interfaces", which

Diff for: include/swift/Frontend/ModuleInterfaceSupport.h

-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ struct ModuleInterfaceOptions {
4444
/// [TODO: Clang-type-plumbing] This check should go away.
4545
bool PrintFullConvention = false;
4646

47-
/// Print some ABI details for public symbols as comments that can be
48-
/// parsed by another tool.
49-
bool ABIComments = false;
50-
5147
struct InterfaceFlags {
5248
/// Copy of all the command-line flags passed at .swiftinterface
5349
/// generation time, re-applied to CompilerInvocation when reading

Diff for: include/swift/Option/FrontendOptions.td

-3
Original file line numberDiff line numberDiff line change
@@ -1050,9 +1050,6 @@ def disable_alias_module_names_in_module_interface :
10501050
Flag<["-"], "disable-alias-module-names-in-module-interface">,
10511051
HelpText<"When emitting a module interface, disable disambiguating modules "
10521052
"using distinct alias names">;
1053-
def abi_comments_in_module_interface :
1054-
Flag<["-"], "abi-comments-in-module-interface">,
1055-
HelpText<"When emitting a module interface, emit comments with ABI details">;
10561053

10571054
def experimental_spi_imports :
10581055
Flag<["-"], "experimental-spi-imports">,

Diff for: lib/AST/ASTPrinter.cpp

+11-73
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(ModuleDecl *ModuleToPrint,
219219
bool useExportedModuleNames,
220220
bool aliasModuleNames,
221221
llvm::SmallSet<StringRef, 4>
222-
*aliasModuleNamesTargets,
223-
bool abiComments) {
222+
*aliasModuleNamesTargets
223+
) {
224224
PrintOptions result;
225225
result.IsForSwiftInterface = true;
226226
result.PrintLongAttrsOnSeparateLines = true;
@@ -242,7 +242,6 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(ModuleDecl *ModuleToPrint,
242242
result.PreferTypeRepr = preferTypeRepr;
243243
result.AliasModuleNames = aliasModuleNames;
244244
result.AliasModuleNamesTargets = aliasModuleNamesTargets;
245-
result.PrintABIComments = abiComments;
246245
if (printFullConvention)
247246
result.PrintFunctionRepresentationAttrs =
248247
PrintOptions::FunctionRepresentationMode::Full;
@@ -783,28 +782,19 @@ class PrintAST : public ASTVisitor<PrintAST> {
783782
printRawComment(RC);
784783
}
785784

786-
/// If we should print a mangled name for this declaration, return that
787-
/// mangled name.
788-
std::optional<std::string> mangledNameToPrint(const Decl *D);
789-
790785
void printDocumentationComment(const Decl *D) {
791-
if (Options.PrintDocumentationComments) {
792-
// Try to print a comment from Clang.
793-
auto MaybeClangNode = D->getClangNode();
794-
if (MaybeClangNode) {
795-
if (auto *CD = MaybeClangNode.getAsDecl())
796-
printClangDocumentationComment(CD);
797-
return;
798-
}
786+
if (!Options.PrintDocumentationComments)
787+
return;
799788

800-
printSwiftDocumentationComment(D);
789+
// Try to print a comment from Clang.
790+
auto MaybeClangNode = D->getClangNode();
791+
if (MaybeClangNode) {
792+
if (auto *CD = MaybeClangNode.getAsDecl())
793+
printClangDocumentationComment(CD);
794+
return;
801795
}
802796

803-
if (auto mangledName = mangledNameToPrint(D)) {
804-
indent();
805-
Printer << "// MANGLED NAME: " << *mangledName;
806-
Printer.printNewline();
807-
}
797+
printSwiftDocumentationComment(D);
808798
}
809799

810800
void printStaticKeyword(StaticSpellingKind StaticSpelling) {
@@ -3130,58 +3120,6 @@ void PrintAST::printExtension(ExtensionDecl *decl) {
31303120
}
31313121
}
31323122

3133-
std::optional<std::string> PrintAST::mangledNameToPrint(const Decl *D) {
3134-
using ASTMangler = Mangle::ASTMangler;
3135-
3136-
if (!Options.PrintABIComments)
3137-
return std::nullopt;
3138-
3139-
auto valueDecl = dyn_cast<ValueDecl>(D);
3140-
if (!valueDecl)
3141-
return std::nullopt;
3142-
3143-
// Anything with an access level less than "package" isn't meant to be
3144-
// referenced from source code outside the module.
3145-
if (valueDecl->getEffectiveAccess() < AccessLevel::Package)
3146-
return std::nullopt;
3147-
3148-
// For functions, mangle the entity directly.
3149-
if (auto func = dyn_cast<FuncDecl>(D)) {
3150-
ASTMangler mangler;
3151-
return mangler.mangleEntity(func);
3152-
}
3153-
3154-
// For initializers, mangle the allocating initializer.
3155-
if (auto init = dyn_cast<ConstructorDecl>(D)) {
3156-
ASTMangler mangler;
3157-
return mangler.mangleConstructorEntity(init, /*isAllocating=*/true);
3158-
}
3159-
3160-
// For variables, mangle the entity directly.
3161-
if (auto var = dyn_cast<VarDecl>(D)) {
3162-
ASTMangler mangler;
3163-
return mangler.mangleEntity(var);
3164-
}
3165-
3166-
// For subscripts, mangle the entity directly.
3167-
if (auto subscript = dyn_cast<SubscriptDecl>(D)) {
3168-
ASTMangler mangler;
3169-
return mangler.mangleEntity(subscript);
3170-
}
3171-
3172-
// For nominal types, mangle the type metadata accessor.
3173-
if (auto nominal = dyn_cast<NominalTypeDecl>(D)) {
3174-
if (!isa<ProtocolDecl>(nominal) && !nominal->getGenericSignature()) {
3175-
ASTMangler mangler;
3176-
std::string name = mangler.mangleNominalType(nominal);
3177-
name += "Ma";
3178-
return name;
3179-
}
3180-
}
3181-
3182-
return std::nullopt;
3183-
}
3184-
31853123
static void suppressingFeatureIsolatedAny(PrintOptions &options,
31863124
llvm::function_ref<void()> action) {
31873125
llvm::SaveAndRestore<bool> scope(options.SuppressIsolatedAny, true);

Diff for: lib/Frontend/CompilerInvocation.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ static void ParseModuleInterfaceArgs(ModuleInterfaceOptions &Opts,
523523
Args.hasArg(OPT_debug_emit_invalid_swiftinterface_syntax);
524524
Opts.PrintMissingImports =
525525
!Args.hasArg(OPT_disable_print_missing_imports_in_module_interface);
526-
Opts.ABIComments = Args.hasArg(OPT_abi_comments_in_module_interface);
527526

528527
if (const Arg *A = Args.getLastArg(OPT_library_level)) {
529528
StringRef contents = A->getValue();

Diff for: lib/Frontend/ModuleInterfaceSupport.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ bool swift::emitSwiftInterface(raw_ostream &out,
878878
M, Opts.PreserveTypesAsWritten, Opts.PrintFullConvention,
879879
Opts.InterfaceContentMode,
880880
useExportedModuleNames,
881-
Opts.AliasModuleNames, &aliasModuleNamesTargets, Opts.ABIComments);
881+
Opts.AliasModuleNames, &aliasModuleNamesTargets);
882882
InheritedProtocolCollector::PerTypeMap inheritedProtocolMap;
883883

884884
SmallVector<Decl *, 16> topLevelDecls;

Diff for: test/ModuleInterface/abi-comments.swift

-42
This file was deleted.

0 commit comments

Comments
 (0)