Reflection: Decode imported Objective-C classes and protocols as their own TypeRef

Right now we expect that every class and protocol has a field
descriptor that tells us if the entity is @objc or not.

For imported types, the descriptor will not exist if we did not
directly emit a field whose concrete type contains the imported
type. For example, in lldb, we might have a generic type whose
runtime substituted type includes an imported type.

In this case, TypeLowering would fail to produce a layout because
it did not find a field descriptor for the imported type.

A better approach is to have the TypeDecoder call a different
factory method for imported types, and handle them specially in
TypeLowering, bypassing the field type metadata altogether.
This commit is contained in:
Slava Pestov
2018-11-01 21:55:29 -04:00
parent 5655b35bc3
commit d093fcb4a4
11 changed files with 229 additions and 104 deletions

View File

@@ -438,6 +438,16 @@ public:
return createNominalType(typeDecl, /*parent*/ Type());
}
ProtocolDecl *createObjCProtocolDecl(StringRef name) {
auto typeDecl =
findForeignNominalTypeDecl(name, /*relatedEntityKind*/{},
ForeignModuleKind::Imported,
Demangle::Node::Kind::Protocol);
if (auto *protocolDecl = dyn_cast_or_null<ProtocolDecl>(typeDecl))
return protocolDecl;
return nullptr;
}
Type createForeignClassType(StringRef mangledName) {
auto typeDecl = createNominalTypeDecl(mangledName);
if (!typeDecl) return Type();