[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:18 PDT 2025


================
@@ -1926,20 +1863,21 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
 
   SBValueList sb_value_list;
 
-  TargetSP target_sp(GetSP());
-  if (name && target_sp) {
-    VariableList variable_list;
-    target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches,
-                                               variable_list);
-    if (!variable_list.Empty()) {
-      ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
-      if (exe_scope == nullptr)
-        exe_scope = target_sp.get();
-      for (const VariableSP &var_sp : variable_list) {
-        lldb::ValueObjectSP valobj_sp(
-            ValueObjectVariable::Create(exe_scope, var_sp));
-        if (valobj_sp)
-          sb_value_list.Append(SBValue(valobj_sp));
+  if (TargetSP target_sp = GetSP()) {
----------------
labath wrote:

h

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


More information about the lldb-commits mailing list