[Lldb-commits] [lldb] [lldb] Use if-with-initializer pattern in SBTarget (NFC) (PR #141284)
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Fri May 23 15:19:10 PDT 2025
================
@@ -1266,25 +1235,22 @@ lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file,
LLDB_INSTRUMENT_VA(this, dest_file, bkpt_list, append);
SBError sberr;
- TargetSP target_sp(GetSP());
- if (!target_sp) {
- sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
+ if (TargetSP target_sp = GetSP()) {
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ BreakpointIDList bp_id_list;
+ bkpt_list.CopyToBreakpointIDList(bp_id_list);
+ sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
+ bp_id_list, append);
return sberr;
}
-
- std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- BreakpointIDList bp_id_list;
- bkpt_list.CopyToBreakpointIDList(bp_id_list);
- sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
- bp_id_list, append);
+ sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
----------------
bulbazord wrote:
Same suggestion here
https://github.com/llvm/llvm-project/pull/141284
More information about the lldb-commits
mailing list