Skip to content

Commit e3efd00

Browse files
committed
IRGen: Don't emit field descriptors for imported classes and protocols
1 parent d093fcb commit e3efd00

File tree

2 files changed

+5
-34
lines changed

2 files changed

+5
-34
lines changed

lib/IRGen/GenReflection.cpp

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -202,21 +202,16 @@ class ReflectionMetadataBuilder {
202202
if (IGM.getSwiftModule()->isStdlibModule() && isa<BuiltinType>(t))
203203
IGM.BuiltinTypes.insert(t);
204204

205-
// We need size/alignment information for imported value types,
206-
// so emit builtin descriptors for them.
205+
// We need size/alignment information for imported structs and
206+
// enums, so emit builtin descriptors for them.
207207
//
208208
// In effect they're treated like an opaque blob, which is OK
209209
// for now, at least until we want to import C++ types or
210210
// something like that.
211-
//
212-
// Classes and protocols go down a different path.
213211
if (auto Nominal = t->getAnyNominal())
214212
if (Nominal->hasClangNode()) {
215-
if (auto CD = dyn_cast<ClassDecl>(Nominal))
216-
IGM.ImportedClasses.insert(CD);
217-
else if (auto PD = dyn_cast<ProtocolDecl>(Nominal))
218-
IGM.ImportedProtocols.insert(PD);
219-
else
213+
if (isa<StructDecl>(Nominal) ||
214+
isa<EnumDecl>(Nominal))
220215
IGM.OpaqueTypes.insert(Nominal);
221216
}
222217
});
@@ -386,14 +381,6 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
386381
B.addInt16(uint16_t(kind));
387382
B.addInt16(fieldRecordSize);
388383

389-
// Imported classes don't need field descriptors
390-
if (NTD->hasClangNode() && isa<ClassDecl>(NTD)) {
391-
B.addInt32(0);
392-
return;
393-
}
394-
395-
assert(!NTD->hasClangNode() || isa<StructDecl>(NTD));
396-
397384
auto properties = NTD->getStoredProperties();
398385
B.addInt32(std::distance(properties.begin(), properties.end()));
399386
for (auto property : properties)
@@ -453,11 +440,7 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
453440
}
454441

455442
void layout() override {
456-
if (NTD->hasClangNode() &&
457-
!isa<ClassDecl>(NTD) &&
458-
!isa<StructDecl>(NTD) &&
459-
!isa<ProtocolDecl>(NTD))
460-
return;
443+
assert(!NTD->hasClangNode() || isa<StructDecl>(NTD));
461444

462445
PrettyStackTraceDecl DebugStack("emitting field type metadata", NTD);
463446
addNominalRef(NTD);
@@ -949,12 +932,6 @@ void IRGenModule::emitBuiltinReflectionMetadata() {
949932
BuiltinTypes.insert(anyMetatype);
950933
}
951934

952-
for (auto CD : ImportedClasses)
953-
emitFieldMetadataRecord(CD);
954-
955-
for (auto PD : ImportedProtocols)
956-
emitFieldMetadataRecord(PD);
957-
958935
for (auto SD : ImportedStructs)
959936
emitFieldMetadataRecord(SD);
960937

lib/IRGen/IRGenModule.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,12 +1045,6 @@ class IRGenModule {
10451045
/// without knowledge of their contents. This includes imported structs
10461046
/// and fixed-size multi-payload enums.
10471047
llvm::SetVector<const NominalTypeDecl *> OpaqueTypes;
1048-
/// Imported classes referenced by types in this module when emitting
1049-
/// reflection metadata.
1050-
llvm::SetVector<const ClassDecl *> ImportedClasses;
1051-
/// Imported protocols referenced by types in this module when emitting
1052-
/// reflection metadata.
1053-
llvm::SetVector<const ProtocolDecl *> ImportedProtocols;
10541048
/// Imported structs referenced by types in this module when emitting
10551049
/// reflection metadata.
10561050
llvm::SetVector<const StructDecl *> ImportedStructs;

0 commit comments

Comments
 (0)