@@ -73,9 +73,10 @@ void printCTypeMetadataTypeFunction(raw_ostream &os,
7373 os << " SWIFT_NOEXCEPT SWIFT_CALL;\n\n " ;
7474}
7575
76- void ClangValueTypePrinter::printStructDecl (const StructDecl *SD) {
76+ void ClangValueTypePrinter::printValueTypeDecl (
77+ const NominalTypeDecl *typeDecl) {
7778 auto typeSizeAlign =
78- interopContext.getIrABIDetails ().getTypeSizeAlignment (SD );
79+ interopContext.getIrABIDetails ().getTypeSizeAlignment (typeDecl );
7980 if (!typeSizeAlign) {
8081 // FIXME: handle non-fixed layout structs.
8182 return ;
@@ -88,31 +89,31 @@ void ClangValueTypePrinter::printStructDecl(const StructDecl *SD) {
8889 ClangSyntaxPrinter printer (os);
8990
9091 auto typeMetadataFunc = irgen::LinkEntity::forTypeMetadataAccessFunction (
91- SD ->getDeclaredType ()->getCanonicalType ());
92+ typeDecl ->getDeclaredType ()->getCanonicalType ());
9293 std::string typeMetadataFuncName = typeMetadataFunc.mangleAsString ();
9394
9495 // Print out a forward declaration of the "hidden" _impl class.
9596 printer.printNamespace (cxx_synthesis::getCxxImplNamespaceName (),
9697 [&](raw_ostream &os) {
9798 os << " class " ;
98- printCxxImplClassName (os, SD );
99+ printCxxImplClassName (os, typeDecl );
99100 os << " ;\n\n " ;
100101
101102 // Print out special functions, like functions that
102103 // access type metadata.
103- printCTypeMetadataTypeFunction (os, SD ,
104+ printCTypeMetadataTypeFunction (os, typeDecl ,
104105 typeMetadataFuncName);
105106 });
106107
107108 // Print out the C++ class itself.
108109 os << " class " ;
109- ClangSyntaxPrinter (os).printBaseName (SD );
110+ ClangSyntaxPrinter (os).printBaseName (typeDecl );
110111 os << " final {\n " ;
111112 os << " public:\n " ;
112113
113114 // Print out the destructor.
114115 os << " inline ~" ;
115- printer.printBaseName (SD );
116+ printer.printBaseName (typeDecl );
116117 os << " () {\n " ;
117118 os << " auto metadata = " << cxx_synthesis::getCxxImplNamespaceName ()
118119 << " ::" ;
@@ -125,9 +126,9 @@ void ClangValueTypePrinter::printStructDecl(const StructDecl *SD) {
125126 os << " }\n " ;
126127
127128 os << " inline " ;
128- printer.printBaseName (SD );
129+ printer.printBaseName (typeDecl );
129130 os << " (const " ;
130- printer.printBaseName (SD );
131+ printer.printBaseName (typeDecl );
131132 os << " &other) {\n " ;
132133 os << " auto metadata = " << cxx_synthesis::getCxxImplNamespaceName ()
133134 << " ::" ;
@@ -142,24 +143,24 @@ void ClangValueTypePrinter::printStructDecl(const StructDecl *SD) {
142143
143144 // FIXME: the move constructor should be hidden somehow.
144145 os << " inline " ;
145- printer.printBaseName (SD );
146+ printer.printBaseName (typeDecl );
146147 os << " (" ;
147- printer.printBaseName (SD );
148+ printer.printBaseName (typeDecl );
148149 os << " &&) = default;\n " ;
149150
150151 // FIXME: Print the other members of the struct.
151152 os << " private:\n " ;
152153
153154 // Print out private default constructor.
154155 os << " inline " ;
155- printer.printBaseName (SD );
156+ printer.printBaseName (typeDecl );
156157 os << " () {}\n " ;
157158 // Print out '_make' function which returns an unitialized instance for
158159 // passing to Swift.
159160 os << " static inline " ;
160- printer.printBaseName (SD );
161+ printer.printBaseName (typeDecl );
161162 os << " _make() { return " ;
162- printer.printBaseName (SD );
163+ printer.printBaseName (typeDecl );
163164 os << " (); }\n " ;
164165 // Print out the private accessors to the underlying Swift value storage.
165166 os << " inline const char * _Nonnull _getOpaquePointer() const { return "
@@ -172,32 +173,32 @@ void ClangValueTypePrinter::printStructDecl(const StructDecl *SD) {
172173 os << " char _storage[" << typeSizeAlign->size << " ];\n " ;
173174 // Wrap up the value type.
174175 os << " friend class " << cxx_synthesis::getCxxImplNamespaceName () << " ::" ;
175- printCxxImplClassName (os, SD );
176+ printCxxImplClassName (os, typeDecl );
176177 os << " ;\n " ;
177178 os << " };\n\n " ;
178179
179180 // Print out the "hidden" _impl class.
180181 printer.printNamespace (
181182 cxx_synthesis::getCxxImplNamespaceName (), [&](raw_ostream &os) {
182183 os << " class " ;
183- printCxxImplClassName (os, SD );
184+ printCxxImplClassName (os, typeDecl );
184185 os << " {\n " ;
185186 os << " public:\n " ;
186187
187188 os << " static inline char * _Nonnull getOpaquePointer(" ;
188- printCxxTypeName (os, SD );
189+ printCxxTypeName (os, typeDecl );
189190 os << " &object) { return object._getOpaquePointer(); }\n " ;
190191
191192 os << " static inline const char * _Nonnull getOpaquePointer(const " ;
192- printCxxTypeName (os, SD );
193+ printCxxTypeName (os, typeDecl );
193194 os << " &object) { return object._getOpaquePointer(); }\n " ;
194195
195196 os << " template<class T>\n " ;
196197 os << " static inline " ;
197- printCxxTypeName (os, SD );
198+ printCxxTypeName (os, typeDecl );
198199 os << " returnNewValue(T callable) {\n " ;
199200 os << " auto result = " ;
200- printCxxTypeName (os, SD );
201+ printCxxTypeName (os, typeDecl );
201202 os << " ::_make();\n " ;
202203 os << " callable(result._getOpaquePointer());\n " ;
203204 os << " return result;\n " ;
@@ -206,7 +207,7 @@ void ClangValueTypePrinter::printStructDecl(const StructDecl *SD) {
206207 os << " };\n " ;
207208 });
208209
209- printCValueTypeStorageStruct (cPrologueOS, SD , *typeSizeAlign);
210+ printCValueTypeStorageStruct (cPrologueOS, typeDecl , *typeSizeAlign);
210211}
211212
212213// / Print the name of the C stub struct for passing/returning a value type
0 commit comments