In ImportContext(…) we may call into CompleteDecl(…) which if FromRecrord is not defined will start the definition of a ToRecord but from what I can tell at least one of the paths though here don't ensure we complete the definition.
For a RecordDecl this can be problematic since this means we won’t import base classes and we won’t have any of the methods or types we inherit from these bases.
One such path is through VisitTypedefNameDecl(…) which is exercised by the reproducer.
For LLDB expression parsing this results in expressions failing but sometimes succeeding in subsequent attempts e.g.:
(lldb) p BB->dump() error: no member named 'dump' in 'B' (lldb) p BB->dump() (lldb)
This happens because the first time through FromRecord is not defined but in subsequent attempts through it may be.
What if we did this a bit differently? We could simply complete the From type if it is not completed, before getting into ImportDefinition.
This way we could get rid of the redundant calls of ImportDefinition. As we have now a call for the case when we don't have external storage and for the case when we have.