Once we start the definition of an ObjCInterfaceDecl we won't attempt to ImportDeclContext later on. Unlike RecordDecl case which uses DefinitionCompleter to force completeDefinition we don't seem to have a similar mechanism for ObjCInterfaceDecl.
This fix was needed due to a bug we see in LLDB expression parsing where an initial expression cause an ObjCInterfaceDecl to be defined and subsequent expressions during import do not call ImportDeclContext and we can end up in a situation where ivars are imported out of order and not all ivars are imported e.g.
(lldb) expr chb1->hb->field2 ObjCInterfaceDecl 0x7f9457495fe0 <<invalid sloc>> <invalid sloc> <undeserialized declarations> HasBitfield1 |-super ObjCInterface 0x7f9457495e78 'NSObject' `-ObjCIvarDecl 0x7f945749d478 <<invalid sloc>> <invalid sloc> field2 'unsigned int' public `-IntegerLiteral 0x7f945749d458 <<invalid sloc>> 'int' 1
We have field2 which is the second ivar but we are missing field1.
In this particular case ASTContext::lookupFieldBitOffset(...) assumes we have all ivars and they are in order to obtain the index of the ivar and we break this assumption. This leads eventually to bad IRGen since it has the wrong field offset.