@@ -14,15 +14,9 @@ namespace swift {
1414
1515// / Represents the nine reflection sections used by Swift
1616enum ReflectionSectionKind : uint8_t {
17- fieldmd,
18- assocty,
19- builtin,
20- capture,
21- typeref,
22- reflstr,
23- conform,
24- protocs,
25- acfuncs,
17+ #define HANDLE_SWIFT_SECTION (KIND, MACHO, ELF, COFF ) KIND,
18+ #include " llvm/BinaryFormat/Swift.def"
19+ #undef HANDLE_SWIFT_SECTION
2620};
2721
2822// / Abstract base class responsible for providing the correct reflection section
@@ -43,24 +37,11 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
4337public:
4438 llvm::StringRef getSectionName (ReflectionSectionKind section) override {
4539 switch (section) {
46- case fieldmd:
47- return " __swift5_fieldmd" ;
48- case assocty:
49- return " __swift5_assocty" ;
50- case builtin:
51- return " __swift5_builtin" ;
52- case capture:
53- return " __swift5_capture" ;
54- case typeref:
55- return " __swift5_typeref" ;
56- case reflstr:
57- return " __swift5_reflstr" ;
58- case conform:
59- return " __swift5_proto" ;
60- case protocs:
61- return " __swift5_protos" ;
62- case acfuncs:
63- return " __swift5_acfuncs" ;
40+ #define HANDLE_SWIFT_SECTION (KIND, MACHO, ELF, COFF ) \
41+ case KIND: \
42+ return MACHO;
43+ #include " llvm/BinaryFormat/Swift.def"
44+ #undef HANDLE_SWIFT_SECTION
6445 }
6546 llvm_unreachable (" Section type not found." );
6647 }
@@ -78,24 +59,11 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
7859public:
7960 llvm::StringRef getSectionName (ReflectionSectionKind section) override {
8061 switch (section) {
81- case fieldmd:
82- return " swift5_fieldmd" ;
83- case assocty:
84- return " swift5_assocty" ;
85- case builtin:
86- return " swift5_builtin" ;
87- case capture:
88- return " swift5_capture" ;
89- case typeref:
90- return " swift5_typeref" ;
91- case reflstr:
92- return " swift5_reflstr" ;
93- case conform:
94- return " swift5_protocol_conformances" ;
95- case protocs:
96- return " swift5_protocols" ;
97- case acfuncs:
98- return " swift5_accessible_functions" ;
62+ #define HANDLE_SWIFT_SECTION (KIND, MACHO, ELF, COFF ) \
63+ case KIND: \
64+ return ELF;
65+ #include " llvm/BinaryFormat/Swift.def"
66+ #undef HANDLE_SWIFT_SECTION
9967 }
10068 llvm_unreachable (" Section type not found." );
10169 }
@@ -110,24 +78,11 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
11078public:
11179 llvm::StringRef getSectionName (ReflectionSectionKind section) override {
11280 switch (section) {
113- case fieldmd:
114- return " .sw5flmd" ;
115- case assocty:
116- return " .sw5asty" ;
117- case builtin:
118- return " .sw5bltn" ;
119- case capture:
120- return " .sw5cptr" ;
121- case typeref:
122- return " .sw5tyrf" ;
123- case reflstr:
124- return " .sw5rfst" ;
125- case conform:
126- return " .sw5prtc$B" ;
127- case protocs:
128- return " .sw5prt$B" ;
129- case acfuncs:
130- return " .sw5acfn$B" ;
81+ #define HANDLE_SWIFT_SECTION (KIND, MACHO, ELF, COFF ) \
82+ case KIND: \
83+ return COFF;
84+ #include " llvm/BinaryFormat/Swift.def"
85+ #undef HANDLE_SWIFT_SECTION
13186 }
13287 llvm_unreachable (" Section not found." );
13388 }
0 commit comments