[Lldb-commits] [lldb] [LLDB] Add type casting to DIL, part 3 of 3 (PR #175061)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 10 01:41:53 PST 2026


================
@@ -44,6 +45,53 @@ DILDiagnosticError::DILDiagnosticError(llvm::StringRef expr,
   m_detail.rendered = std::move(rendered_msg);
 }
 
+llvm::Expected<lldb::TypeSystemSP>
+GetTypeSystemFromCU(std::shared_ptr<StackFrame> ctx) {
+  SymbolContext symbol_context =
+      ctx->GetSymbolContext(lldb::eSymbolContextCompUnit);
+  lldb::LanguageType language = symbol_context.comp_unit->GetLanguage();
+
+  symbol_context = ctx->GetSymbolContext(lldb::eSymbolContextModule);
+  return symbol_context.module_sp->GetTypeSystemForLanguage(language);
+}
+
+CompilerType
+ResolveTypeByName(const std::string &name,
+                  ExecutionContextScope &ctx_scope) {
+  // Internally types don't have global scope qualifier in their names and
+  // LLDB doesn't support queries with it too.
+  llvm::StringRef name_ref(name);
+
+  if (name_ref.starts_with("::"))
+    name_ref = name_ref.drop_front(2);
+
+  std::vector<CompilerType> result_type_list;
+  lldb::TargetSP target_sp = ctx_scope.CalculateTarget();
+  if (!name_ref.empty() && target_sp) {
+    ModuleList &images = target_sp->GetImages();
+    TypeQuery query{ConstString(name_ref)};
+    TypeResults results;
+    images.FindTypes(nullptr, query, results);
+    for (const lldb::TypeSP &type_sp : results.GetTypeMap().Types())
+      if (type_sp)
+        result_type_list.push_back(type_sp->GetFullCompilerType());
+  }
+
+  // We've found multiple types, try finding the "correct" one.
+  CompilerType full_match;
+  std::vector<CompilerType> partial_matches;
----------------
Michael137 wrote:

```suggestion
```
unused

https://github.com/llvm/llvm-project/pull/175061


More information about the lldb-commits mailing list