Skip to content

Commit cb6e3db

Browse files
authored
Merge pull request #77579 from DougGregor/revert-abi-comments-printing
Revert "Emit mangled names for public symbols into the .swiftinterface"
2 parents 11f9ea7 + 34c020d commit cb6e3db

File tree

7 files changed

+13
-130
lines changed

7 files changed

+13
-130
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,6 @@ struct PrintOptions {
535535
/// with types sharing a name with a module.
536536
bool AliasModuleNames = false;
537537

538-
/// Print some ABI details for public symbols as comments that can be
539-
/// parsed by another tool.
540-
bool PrintABIComments = false;
541-
542538
/// Name of the modules that have been aliased in AliasModuleNames mode.
543539
/// Ideally we would use something other than a string to identify a module,
544540
/// but since one alias can apply to more than one module, strings happen
@@ -729,8 +725,7 @@ struct PrintOptions {
729725
bool useExportedModuleNames,
730726
bool aliasModuleNames,
731727
llvm::SmallSet<StringRef, 4>
732-
*aliasModuleNamesTargets,
733-
bool abiComments
728+
*aliasModuleNamesTargets
734729
);
735730

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

include/swift/Frontend/ModuleInterfaceSupport.h

Lines changed: 0 additions & 4 deletions
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

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 3 deletions
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">,

lib/AST/ASTPrinter.cpp

Lines changed: 11 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(ModuleDecl *ModuleToPrint,
201201
bool useExportedModuleNames,
202202
bool aliasModuleNames,
203203
llvm::SmallSet<StringRef, 4>
204-
*aliasModuleNamesTargets,
205-
bool abiComments) {
204+
*aliasModuleNamesTargets
205+
) {
206206
PrintOptions result;
207207
result.IsForSwiftInterface = true;
208208
result.PrintLongAttrsOnSeparateLines = true;
@@ -224,7 +224,6 @@ PrintOptions PrintOptions::printSwiftInterfaceFile(ModuleDecl *ModuleToPrint,
224224
result.PreferTypeRepr = preferTypeRepr;
225225
result.AliasModuleNames = aliasModuleNames;
226226
result.AliasModuleNamesTargets = aliasModuleNamesTargets;
227-
result.PrintABIComments = abiComments;
228227
if (printFullConvention)
229228
result.PrintFunctionRepresentationAttrs =
230229
PrintOptions::FunctionRepresentationMode::Full;
@@ -765,28 +764,19 @@ class PrintAST : public ASTVisitor<PrintAST> {
765764
printRawComment(RC);
766765
}
767766

768-
/// If we should print a mangled name for this declaration, return that
769-
/// mangled name.
770-
std::optional<std::string> mangledNameToPrint(const Decl *D);
771-
772767
void printDocumentationComment(const Decl *D) {
773-
if (Options.PrintDocumentationComments) {
774-
// Try to print a comment from Clang.
775-
auto MaybeClangNode = D->getClangNode();
776-
if (MaybeClangNode) {
777-
if (auto *CD = MaybeClangNode.getAsDecl())
778-
printClangDocumentationComment(CD);
779-
return;
780-
}
768+
if (!Options.PrintDocumentationComments)
769+
return;
781770

782-
printSwiftDocumentationComment(D);
771+
// Try to print a comment from Clang.
772+
auto MaybeClangNode = D->getClangNode();
773+
if (MaybeClangNode) {
774+
if (auto *CD = MaybeClangNode.getAsDecl())
775+
printClangDocumentationComment(CD);
776+
return;
783777
}
784778

785-
if (auto mangledName = mangledNameToPrint(D)) {
786-
indent();
787-
Printer << "// MANGLED NAME: " << *mangledName;
788-
Printer.printNewline();
789-
}
779+
printSwiftDocumentationComment(D);
790780
}
791781

792782
void printStaticKeyword(StaticSpellingKind StaticSpelling) {
@@ -3114,58 +3104,6 @@ void PrintAST::printExtension(ExtensionDecl *decl) {
31143104
}
31153105
}
31163106

3117-
std::optional<std::string> PrintAST::mangledNameToPrint(const Decl *D) {
3118-
using ASTMangler = Mangle::ASTMangler;
3119-
3120-
if (!Options.PrintABIComments)
3121-
return std::nullopt;
3122-
3123-
auto valueDecl = dyn_cast<ValueDecl>(D);
3124-
if (!valueDecl)
3125-
return std::nullopt;
3126-
3127-
// Anything with an access level less than "package" isn't meant to be
3128-
// referenced from source code outside the module.
3129-
if (valueDecl->getEffectiveAccess() < AccessLevel::Package)
3130-
return std::nullopt;
3131-
3132-
// For functions, mangle the entity directly.
3133-
if (auto func = dyn_cast<FuncDecl>(D)) {
3134-
ASTMangler mangler;
3135-
return mangler.mangleEntity(func);
3136-
}
3137-
3138-
// For initializers, mangle the allocating initializer.
3139-
if (auto init = dyn_cast<ConstructorDecl>(D)) {
3140-
ASTMangler mangler;
3141-
return mangler.mangleConstructorEntity(init, /*isAllocating=*/true);
3142-
}
3143-
3144-
// For variables, mangle the entity directly.
3145-
if (auto var = dyn_cast<VarDecl>(D)) {
3146-
ASTMangler mangler;
3147-
return mangler.mangleEntity(var);
3148-
}
3149-
3150-
// For subscripts, mangle the entity directly.
3151-
if (auto subscript = dyn_cast<SubscriptDecl>(D)) {
3152-
ASTMangler mangler;
3153-
return mangler.mangleEntity(subscript);
3154-
}
3155-
3156-
// For nominal types, mangle the type metadata accessor.
3157-
if (auto nominal = dyn_cast<NominalTypeDecl>(D)) {
3158-
if (!isa<ProtocolDecl>(nominal) && !nominal->getGenericSignature()) {
3159-
ASTMangler mangler;
3160-
std::string name = mangler.mangleNominalType(nominal);
3161-
name += "Ma";
3162-
return name;
3163-
}
3164-
}
3165-
3166-
return std::nullopt;
3167-
}
3168-
31693107
static void suppressingFeatureIsolatedAny(PrintOptions &options,
31703108
llvm::function_ref<void()> action) {
31713109
llvm::SaveAndRestore<bool> scope(options.SuppressIsolatedAny, true);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 1 deletion
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();

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 1 addition & 1 deletion
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;

test/ModuleInterface/abi-comments.swift

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)