Skip to content

Commit c6ce324

Browse files
committed
[lldb] Eliminate more Targer* in favor of Target& in CommandObjects (NFC)
The majority of the replaced Target pointers were already used unconditionally and the few that were shouldn't even be NULL.
1 parent 1c1b8c2 commit c6ce324

File tree

5 files changed

+67
-75
lines changed

5 files changed

+67
-75
lines changed

lldb/source/Commands/CommandObjectBreakpoint.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ class CommandObjectBreakpointModify : public CommandObjectParsed {
848848
BreakpointIDList valid_bp_ids;
849849

850850
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
851-
command, &target, result, &valid_bp_ids,
851+
command, target, result, &valid_bp_ids,
852852
BreakpointName::Permissions::PermissionKinds::disablePerm);
853853

854854
if (result.Succeeded()) {
@@ -929,7 +929,7 @@ class CommandObjectBreakpointEnable : public CommandObjectParsed {
929929
// Particular breakpoint selected; enable that breakpoint.
930930
BreakpointIDList valid_bp_ids;
931931
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
932-
command, &target, result, &valid_bp_ids,
932+
command, target, result, &valid_bp_ids,
933933
BreakpointName::Permissions::PermissionKinds::disablePerm);
934934

935935
if (result.Succeeded()) {
@@ -1035,7 +1035,7 @@ the second re-enables the first location.");
10351035
BreakpointIDList valid_bp_ids;
10361036

10371037
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
1038-
command, &target, result, &valid_bp_ids,
1038+
command, target, result, &valid_bp_ids,
10391039
BreakpointName::Permissions::PermissionKinds::disablePerm);
10401040

10411041
if (result.Succeeded()) {
@@ -1180,7 +1180,7 @@ class CommandObjectBreakpointList : public CommandObjectParsed {
11801180
// Particular breakpoints selected; show info about that breakpoint.
11811181
BreakpointIDList valid_bp_ids;
11821182
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
1183-
command, &target, result, &valid_bp_ids,
1183+
command, target, result, &valid_bp_ids,
11841184
BreakpointName::Permissions::PermissionKinds::listPerm);
11851185

11861186
if (result.Succeeded()) {
@@ -1459,7 +1459,7 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
14591459

14601460
if (!command.empty()) {
14611461
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
1462-
command, &target, result, &excluded_bp_ids,
1462+
command, target, result, &excluded_bp_ids,
14631463
BreakpointName::Permissions::PermissionKinds::deletePerm);
14641464
if (!result.Succeeded())
14651465
return;
@@ -1478,7 +1478,7 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
14781478
}
14791479
} else {
14801480
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
1481-
command, &target, result, &valid_bp_ids,
1481+
command, target, result, &valid_bp_ids,
14821482
BreakpointName::Permissions::PermissionKinds::deletePerm);
14831483
if (!result.Succeeded())
14841484
return;
@@ -1781,7 +1781,7 @@ class CommandObjectBreakpointNameAdd : public CommandObjectParsed {
17811781
// Particular breakpoint selected; disable that breakpoint.
17821782
BreakpointIDList valid_bp_ids;
17831783
CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs(
1784-
command, &target, result, &valid_bp_ids,
1784+
command, target, result, &valid_bp_ids,
17851785
BreakpointName::Permissions::PermissionKinds::listPerm);
17861786

17871787
if (result.Succeeded()) {
@@ -1855,7 +1855,7 @@ class CommandObjectBreakpointNameDelete : public CommandObjectParsed {
18551855
// Particular breakpoint selected; disable that breakpoint.
18561856
BreakpointIDList valid_bp_ids;
18571857
CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs(
1858-
command, &target, result, &valid_bp_ids,
1858+
command, target, result, &valid_bp_ids,
18591859
BreakpointName::Permissions::PermissionKinds::deletePerm);
18601860

18611861
if (result.Succeeded()) {
@@ -2328,7 +2328,7 @@ class CommandObjectBreakpointWrite : public CommandObjectParsed {
23282328
BreakpointIDList valid_bp_ids;
23292329
if (!command.empty()) {
23302330
CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs(
2331-
command, &target, result, &valid_bp_ids,
2331+
command, target, result, &valid_bp_ids,
23322332
BreakpointName::Permissions::PermissionKinds::listPerm);
23332333

23342334
if (!result.Succeeded()) {
@@ -2410,7 +2410,7 @@ CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint(
24102410
CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint() = default;
24112411

24122412
void CommandObjectMultiwordBreakpoint::VerifyIDs(
2413-
Args &args, Target *target, bool allow_locations,
2413+
Args &args, Target &target, bool allow_locations,
24142414
CommandReturnObject &result, BreakpointIDList *valid_ids,
24152415
BreakpointName::Permissions ::PermissionKinds purpose) {
24162416
// args can be strings representing 1). integers (for breakpoint ids)
@@ -2427,9 +2427,9 @@ void CommandObjectMultiwordBreakpoint::VerifyIDs(
24272427
Args temp_args;
24282428

24292429
if (args.empty()) {
2430-
if (target->GetLastCreatedBreakpoint()) {
2430+
if (target.GetLastCreatedBreakpoint()) {
24312431
valid_ids->AddBreakpointID(BreakpointID(
2432-
target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID));
2432+
target.GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID));
24332433
result.SetStatus(eReturnStatusSuccessFinishNoResult);
24342434
} else {
24352435
result.AppendError(
@@ -2445,7 +2445,7 @@ void CommandObjectMultiwordBreakpoint::VerifyIDs(
24452445
// into TEMP_ARGS.
24462446

24472447
if (llvm::Error err = BreakpointIDList::FindAndReplaceIDRanges(
2448-
args, target, allow_locations, purpose, temp_args)) {
2448+
args, &target, allow_locations, purpose, temp_args)) {
24492449
result.SetError(std::move(err));
24502450
return;
24512451
}
@@ -2469,7 +2469,7 @@ void CommandObjectMultiwordBreakpoint::VerifyIDs(
24692469
for (size_t i = 0; i < count; ++i) {
24702470
BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex(i);
24712471
Breakpoint *breakpoint =
2472-
target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
2472+
target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
24732473
if (breakpoint != nullptr) {
24742474
const size_t num_locations = breakpoint->GetNumLocations();
24752475
if (static_cast<size_t>(cur_bp_id.GetLocationID()) > num_locations) {

lldb/source/Commands/CommandObjectBreakpoint.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ class CommandObjectMultiwordBreakpoint : public CommandObjectMultiword {
2323
~CommandObjectMultiwordBreakpoint() override;
2424

2525
static void VerifyBreakpointOrLocationIDs(
26-
Args &args, Target *target, CommandReturnObject &result,
26+
Args &args, Target &target, CommandReturnObject &result,
2727
BreakpointIDList *valid_ids,
2828
BreakpointName::Permissions ::PermissionKinds purpose) {
2929
VerifyIDs(args, target, true, result, valid_ids, purpose);
3030
}
3131

3232
static void
33-
VerifyBreakpointIDs(Args &args, Target *target, CommandReturnObject &result,
33+
VerifyBreakpointIDs(Args &args, Target &target, CommandReturnObject &result,
3434
BreakpointIDList *valid_ids,
3535
BreakpointName::Permissions::PermissionKinds purpose) {
3636
VerifyIDs(args, target, false, result, valid_ids, purpose);
3737
}
3838

3939
private:
40-
static void VerifyIDs(Args &args, Target *target, bool allow_locations,
40+
static void VerifyIDs(Args &args, Target &target, bool allow_locations,
4141
CommandReturnObject &result,
4242
BreakpointIDList *valid_ids,
4343
BreakpointName::Permissions::PermissionKinds purpose);

lldb/source/Commands/CommandObjectBreakpointCommand.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ are no syntax errors may indicate that a function was declared but never called.
343343

344344
BreakpointIDList valid_bp_ids;
345345
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
346-
command, &target, result, &valid_bp_ids,
346+
command, target, result, &valid_bp_ids,
347347
BreakpointName::Permissions::PermissionKinds::listPerm);
348348

349349
m_bp_options_vec.clear();
@@ -499,7 +499,7 @@ class CommandObjectBreakpointCommandDelete : public CommandObjectParsed {
499499

500500
BreakpointIDList valid_bp_ids;
501501
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
502-
command, &target, result, &valid_bp_ids,
502+
command, target, result, &valid_bp_ids,
503503
BreakpointName::Permissions::PermissionKinds::listPerm);
504504

505505
if (result.Succeeded()) {
@@ -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()) {

lldb/source/Commands/CommandObjectProcess.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
510510
}
511511
}
512512

513-
Target *target = m_exe_ctx.GetTargetPtr();
513+
Target &target = GetTarget();
514514
BreakpointIDList run_to_bkpt_ids;
515515
// Don't pass an empty run_to_breakpoint list, as Verify will look for the
516516
// default breakpoint.
@@ -538,7 +538,7 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
538538
// the breakpoint.location specifications since the latter require
539539
// special handling. We also figure out whether there's at least one
540540
// specifier in the set that is enabled.
541-
BreakpointList &bkpt_list = target->GetBreakpointList();
541+
BreakpointList &bkpt_list = target.GetBreakpointList();
542542
std::unordered_set<break_id_t> bkpts_seen;
543543
std::unordered_set<break_id_t> bkpts_with_locs_seen;
544544
BreakpointIDList with_locs;
@@ -666,7 +666,7 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
666666
}
667667

668668
// Now re-enable the breakpoints we disabled:
669-
BreakpointList &bkpt_list = target->GetBreakpointList();
669+
BreakpointList &bkpt_list = target.GetBreakpointList();
670670
for (break_id_t bp_id : bkpts_disabled) {
671671
BreakpointSP bp_sp = bkpt_list.FindBreakpointByID(bp_id);
672672
if (bp_sp)

0 commit comments

Comments
 (0)