@@ -423,6 +423,46 @@ Status ObjCLanguageRuntime::ObjCExceptionPrecondition::ConfigurePrecondition(
423423 return error;
424424}
425425
426+ CompilerType ObjCLanguageRuntime::LookupInModulesVendor (ConstString class_name,
427+ Target &target) {
428+ assert (class_name);
429+
430+ auto *persistent_state = llvm::cast<ClangPersistentVariables>(
431+ target.GetPersistentExpressionStateForLanguage (lldb::eLanguageTypeC));
432+ if (!persistent_state)
433+ return {};
434+
435+ auto clang_modules_decl_vendor_sp =
436+ persistent_state->GetClangModulesDeclVendor ();
437+ if (!clang_modules_decl_vendor_sp)
438+ return {};
439+
440+ auto types = clang_modules_decl_vendor_sp->FindTypes (
441+ class_name, /* max_matches*/ UINT32_MAX);
442+ if (types.empty ())
443+ return {};
444+
445+ return types.front ();
446+ }
447+
448+ CompilerType ObjCLanguageRuntime::LookupInRuntime (ConstString class_name) {
449+ auto *runtime_vendor = GetDeclVendor ();
450+ if (!runtime_vendor)
451+ return {};
452+
453+ std::vector<CompilerDecl> compiler_decls;
454+ runtime_vendor->FindDecls (class_name, false , UINT32_MAX, compiler_decls);
455+ if (compiler_decls.empty ())
456+ return {};
457+
458+ auto *ctx =
459+ llvm::dyn_cast<TypeSystemClang>(compiler_decls[0 ].GetTypeSystem ());
460+ if (!ctx)
461+ return {};
462+
463+ return ctx->GetTypeForDecl (compiler_decls[0 ].GetOpaqueDecl ());
464+ }
465+
426466std::optional<CompilerType>
427467ObjCLanguageRuntime::GetRuntimeType (CompilerType base_type) {
428468 CompilerType class_type;
@@ -442,18 +482,21 @@ ObjCLanguageRuntime::GetRuntimeType(CompilerType base_type) {
442482 if (!class_name)
443483 return std::nullopt ;
444484
445- TypeSP complete_objc_class_type_sp = LookupInCompleteClassCache (class_name);
446- if (!complete_objc_class_type_sp)
447- return std::nullopt ;
448-
449- CompilerType complete_class (
450- complete_objc_class_type_sp->GetFullCompilerType ());
451- if (complete_class.GetCompleteType ()) {
452- if (is_pointer_type)
453- return complete_class.GetPointerType ();
454- else
455- return complete_class;
485+ if (TypeSP complete_objc_class_type_sp =
486+ LookupInCompleteClassCache (class_name)) {
487+ if (CompilerType complete_class =
488+ complete_objc_class_type_sp->GetFullCompilerType ();
489+ complete_class.GetCompleteType ())
490+ return is_pointer_type ? complete_class.GetPointerType () : complete_class;
456491 }
457492
493+ assert (m_process);
494+ if (CompilerType found =
495+ LookupInModulesVendor (class_name, m_process->GetTarget ()))
496+ return is_pointer_type ? found.GetPointerType () : found;
497+
498+ if (CompilerType found = LookupInRuntime (class_name))
499+ return is_pointer_type ? found.GetPointerType () : found;
500+
458501 return std::nullopt ;
459502}
0 commit comments