[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed May 28 00:18:19 PDT 2025


================
@@ -1841,31 +1776,33 @@ lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name,
 lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
   LLDB_INSTRUMENT_VA(this, typename_cstr);
 
-  TargetSP target_sp(GetSP());
-  if (typename_cstr && typename_cstr[0] && target_sp) {
-    ConstString const_typename(typename_cstr);
-    TypeQuery query(const_typename.GetStringRef(),
-                    TypeQueryOptions::e_find_one);
-    TypeResults results;
-    target_sp->GetImages().FindTypes(/*search_first=*/nullptr, query, results);
-    TypeSP type_sp = results.GetFirstType();
-    if (type_sp)
-      return SBType(type_sp);
-    // Didn't find the type in the symbols; Try the loaded language runtimes.
-    if (auto process_sp = target_sp->GetProcessSP()) {
-      for (auto *runtime : process_sp->GetLanguageRuntimes()) {
-        if (auto vendor = runtime->GetDeclVendor()) {
-          auto types = vendor->FindTypes(const_typename, /*max_matches*/ 1);
-          if (!types.empty())
-            return SBType(types.front());
+  if (TargetSP target_sp = GetSP()) {
----------------
labath wrote:

here

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


More information about the lldb-commits mailing list