|
21 | 21 | #include "swift/AST/LazyResolver.h" |
22 | 22 | #include "swift/AST/Module.h" |
23 | 23 | #include "swift/AST/ParameterList.h" |
| 24 | +#include "swift/AST/Type.h" |
| 25 | +#include "swift/AST/Types.h" |
24 | 26 | #include "swift/Basic/Assertions.h" |
25 | 27 | #include "swift/Basic/StringExtras.h" |
26 | 28 |
|
@@ -212,7 +214,9 @@ swift::cxx_translation::getNameForCxx(const ValueDecl *VD, |
212 | 214 | } |
213 | 215 |
|
214 | 216 | swift::cxx_translation::DeclRepresentation |
215 | | -swift::cxx_translation::getDeclRepresentation(const ValueDecl *VD) { |
| 217 | +swift::cxx_translation::getDeclRepresentation( |
| 218 | + const ValueDecl *VD, |
| 219 | + std::optional<std::function<bool(const NominalTypeDecl *)>> isZeroSized) { |
216 | 220 | if (getActorIsolation(const_cast<ValueDecl *>(VD)).isActorIsolated()) |
217 | 221 | return {Unsupported, UnrepresentableIsolatedInActor}; |
218 | 222 | if (isa<MacroDecl>(VD)) |
@@ -253,6 +257,8 @@ swift::cxx_translation::getDeclRepresentation(const ValueDecl *VD) { |
253 | 257 | isa_and_nonnull<NominalTypeDecl>( |
254 | 258 | typeDecl->getDeclContext()->getAsDecl())) |
255 | 259 | return {Unsupported, UnrepresentableNested}; |
| 260 | + if (!isa<ClassDecl>(typeDecl) && isZeroSized && (*isZeroSized)(typeDecl)) |
| 261 | + return {Unsupported, UnrepresentableZeroSizedValueType}; |
256 | 262 | } |
257 | 263 | if (const auto *varDecl = dyn_cast<VarDecl>(VD)) { |
258 | 264 | // Check if any property accessor throws, do not expose it in that case. |
@@ -393,5 +399,7 @@ swift::cxx_translation::diagnoseRepresenationError(RepresentationError error, |
393 | 399 | return Diagnostic(diag::expose_nested_type_to_cxx, vd); |
394 | 400 | case UnrepresentableMacro: |
395 | 401 | return Diagnostic(diag::expose_macro_to_cxx, vd); |
| 402 | + case UnrepresentableZeroSizedValueType: |
| 403 | + return Diagnostic(diag::expose_zero_size_to_cxx, vd); |
396 | 404 | } |
397 | 405 | } |
0 commit comments