[Lldb-commits] [lldb] Make only one function that needs to be implemented when searching for types (PR #74786)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 11 04:24:39 PST 2023


================
@@ -437,26 +437,25 @@ lldb::SBType SBModule::FindFirstType(const char *name_cstr) {
   LLDB_INSTRUMENT_VA(this, name_cstr);
 
   ModuleSP module_sp(GetSP());
-  if (!name_cstr || !module_sp)
-    return {};
-  SymbolContext sc;
-  const bool exact_match = false;
-  ConstString name(name_cstr);
+  if (name_cstr && module_sp) {
+    ConstString name(name_cstr);
+    TypeQuery query(name.GetStringRef(), TypeQueryOptions::e_find_one);
+    TypeResults results;
+    module_sp->FindTypes(query, results);
+    TypeSP type_sp = results.GetFirstType();
+    if (type_sp)
+      return SBType(type_sp);
----------------
Michael137 wrote:

We previously would only return `sb_type` if `sb_type.IsValid() == true`. Does this mean we can now return an "invalid" SBType? Or is this checked elsewhere now?

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


More information about the lldb-commits mailing list