File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -5618,7 +5618,9 @@ IRGenModule::getAddrOfForeignTypeMetadataCandidate(CanType type) {
5618
5618
} else if (auto structType = dyn_cast<StructType>(type)) {
5619
5619
auto structDecl = structType->getDecl ();
5620
5620
assert (isa<ClangModuleUnit>(structDecl->getModuleScopeContext ()));
5621
-
5621
+
5622
+ ImportedStructs.insert (structDecl);
5623
+
5622
5624
ForeignStructMetadataBuilder builder (*this , structDecl, init);
5623
5625
builder.layout ();
5624
5626
addressPoint = builder.getOffsetOfAddressPoint ();
Original file line number Diff line number Diff line change @@ -368,12 +368,13 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
368
368
B.addInt16 (fieldRecordSize);
369
369
370
370
// Imported classes don't need field descriptors
371
- if (NTD->hasClangNode ()) {
372
- assert (isa<ClassDecl>(NTD));
371
+ if (NTD->hasClangNode () && isa<ClassDecl>(NTD)) {
373
372
B.addInt32 (0 );
374
373
return ;
375
374
}
376
375
376
+ assert (!NTD->hasClangNode () || isa<StructDecl>(NTD));
377
+
377
378
auto properties = NTD->getStoredProperties ();
378
379
B.addInt32 (std::distance (properties.begin (), properties.end ()));
379
380
for (auto property : properties)
@@ -435,6 +436,7 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
435
436
void layout () override {
436
437
if (NTD->hasClangNode () &&
437
438
!isa<ClassDecl>(NTD) &&
439
+ !isa<StructDecl>(NTD) &&
438
440
!isa<ProtocolDecl>(NTD))
439
441
return ;
440
442
@@ -941,6 +943,9 @@ void IRGenModule::emitBuiltinReflectionMetadata() {
941
943
for (auto PD : ImportedProtocols)
942
944
emitFieldMetadataRecord (PD);
943
945
946
+ for (auto SD : ImportedStructs)
947
+ emitFieldMetadataRecord (SD);
948
+
944
949
for (auto builtinType : BuiltinTypes)
945
950
emitBuiltinTypeMetadataRecord (builtinType);
946
951
Original file line number Diff line number Diff line change @@ -920,6 +920,9 @@ class IRGenModule {
920
920
// / Imported protocols referenced by types in this module when emitting
921
921
// / reflection metadata.
922
922
llvm::SetVector<const ProtocolDecl *> ImportedProtocols;
923
+ // / Imported structs referenced by types in this module when emitting
924
+ // / reflection metadata.
925
+ llvm::SetVector<const StructDecl *> ImportedStructs;
923
926
924
927
llvm::Constant *getAddrOfStringForTypeRef (StringRef Str);
925
928
llvm::Constant *getAddrOfFieldName (StringRef Name);
You can’t perform that action at this time.
0 commit comments