Skip to content

Commit 5dbbc3b

Browse files
committed
[lldb] Use Target references instead of pointers in CommandObject (NFC)
The GetTarget helper returns a Target reference so there's reason to convert it to a pointer and check its validity.
1 parent 1c5f6cf commit 5dbbc3b

6 files changed

+148
-167
lines changed

lldb/source/Commands/CommandObjectBreakpointCommand.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,9 @@ class CommandObjectBreakpointCommandList : public CommandObjectParsed {
548548

549549
protected:
550550
void DoExecute(Args &command, CommandReturnObject &result) override {
551-
Target *target = &GetTarget();
551+
Target &target = GetTarget();
552552

553-
const BreakpointList &breakpoints = target->GetBreakpointList();
553+
const BreakpointList &breakpoints = target.GetBreakpointList();
554554
size_t num_breakpoints = breakpoints.GetSize();
555555

556556
if (num_breakpoints == 0) {
@@ -566,7 +566,7 @@ class CommandObjectBreakpointCommandList : public CommandObjectParsed {
566566

567567
BreakpointIDList valid_bp_ids;
568568
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
569-
command, target, result, &valid_bp_ids,
569+
command, &target, result, &valid_bp_ids,
570570
BreakpointName::Permissions::PermissionKinds::listPerm);
571571

572572
if (result.Succeeded()) {
@@ -575,7 +575,7 @@ class CommandObjectBreakpointCommandList : public CommandObjectParsed {
575575
BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
576576
if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
577577
Breakpoint *bp =
578-
target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
578+
target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
579579

580580
if (bp) {
581581
BreakpointLocationSP bp_loc_sp;

lldb/source/Commands/CommandObjectDisassemble.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,10 @@ CommandObjectDisassemble::GetRangesForSelectedMode(
439439

440440
void CommandObjectDisassemble::DoExecute(Args &command,
441441
CommandReturnObject &result) {
442-
Target *target = &GetTarget();
442+
Target &target = GetTarget();
443443

444444
if (!m_options.arch.IsValid())
445-
m_options.arch = target->GetArchitecture();
445+
m_options.arch = target.GetArchitecture();
446446

447447
if (!m_options.arch.IsValid()) {
448448
result.AppendError(
@@ -535,7 +535,7 @@ void CommandObjectDisassemble::DoExecute(Args &command,
535535
} else {
536536
result.AppendErrorWithFormat(
537537
"Failed to disassemble memory at 0x%8.8" PRIx64 ".\n",
538-
cur_range.GetBaseAddress().GetLoadAddress(target));
538+
cur_range.GetBaseAddress().GetLoadAddress(&target));
539539
}
540540
}
541541
if (print_sc_header)

0 commit comments

Comments
 (0)