Types that came from a Clang module are nested in DW_TAG_module tags in DWARF. This patch recreates the Clang module hierarchy in LLDB and sets the owning module information accordingly. My primary motivation is to facilitate looking up per-module APINotes for individual declarations, but this likely also has other applications.
The fact that Clang modules are orthogonal to DeclContexts made the implementation in LLDB challenging. In the end I extended lldb_private::CompilerDeclContext to hold a pair of clang::DeclContext * and clang::Module * and made sure to use CompilerDeclContext everywhere in TypeSystemClang. To save memory for all non-Clang typesystems, the extra data for the owning module ID is hidden in the CompilerDeclContext's opaque pointer: If it isn't a raw clang::DeclContext pointer, it is an index into an array of Module ID + DeclContexts.