Skip to content

Use Swift.def to define enums and switch cases for swift5 reflection sections #41371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 18 additions & 63 deletions include/swift/ABI/ObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@ namespace swift {

/// Represents the nine reflection sections used by Swift
enum ReflectionSectionKind : uint8_t {
fieldmd,
assocty,
builtin,
capture,
typeref,
reflstr,
conform,
protocs,
acfuncs,
#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) KIND,
#include "llvm/BinaryFormat/Swift.def"
#undef HANDLE_SWIFT_SECTION
};

/// Abstract base class responsible for providing the correct reflection section
Expand All @@ -43,24 +37,11 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
public:
llvm::StringRef getSectionName(ReflectionSectionKind section) override {
switch (section) {
case fieldmd:
return "__swift5_fieldmd";
case assocty:
return "__swift5_assocty";
case builtin:
return "__swift5_builtin";
case capture:
return "__swift5_capture";
case typeref:
return "__swift5_typeref";
case reflstr:
return "__swift5_reflstr";
case conform:
return "__swift5_proto";
case protocs:
return "__swift5_protos";
case acfuncs:
return "__swift5_acfuncs";
#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) \
case KIND: \
return MACHO;
#include "llvm/BinaryFormat/Swift.def"
#undef HANDLE_SWIFT_SECTION
}
llvm_unreachable("Section type not found.");
}
Expand All @@ -78,24 +59,11 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
public:
llvm::StringRef getSectionName(ReflectionSectionKind section) override {
switch (section) {
case fieldmd:
return "swift5_fieldmd";
case assocty:
return "swift5_assocty";
case builtin:
return "swift5_builtin";
case capture:
return "swift5_capture";
case typeref:
return "swift5_typeref";
case reflstr:
return "swift5_reflstr";
case conform:
return "swift5_protocol_conformances";
case protocs:
return "swift5_protocols";
case acfuncs:
return "swift5_accessible_functions";
#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) \
case KIND: \
return ELF;
#include "llvm/BinaryFormat/Swift.def"
#undef HANDLE_SWIFT_SECTION
}
llvm_unreachable("Section type not found.");
}
Expand All @@ -110,24 +78,11 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
public:
llvm::StringRef getSectionName(ReflectionSectionKind section) override {
switch (section) {
case fieldmd:
return ".sw5flmd";
case assocty:
return ".sw5asty";
case builtin:
return ".sw5bltn";
case capture:
return ".sw5cptr";
case typeref:
return ".sw5tyrf";
case reflstr:
return ".sw5rfst";
case conform:
return ".sw5prtc$B";
case protocs:
return ".sw5prt$B";
case acfuncs:
return ".sw5acfn$B";
#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) \
case KIND: \
return COFF;
#include "llvm/BinaryFormat/Swift.def"
#undef HANDLE_SWIFT_SECTION
}
llvm_unreachable("Section not found.");
}
Expand Down