diff options
author | Pete Lawrence <plawrence@apple.com> | 2023-10-30 10:21:00 -1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 13:21:00 -0700 |
commit | 92d8a28cc665d73d9d679b8c014dd04f95d1df18 (patch) | |
tree | 19b3a218ad57e05a911da01c0f4f80ca3c0a4bd4 /lldb/source/Commands/CommandObjectWatchpointCommand.cpp | |
parent | 2446439f51cf0d2dfb11c823436a930de7a4b8a2 (diff) | |
download | llvm-92d8a28cc665d73d9d679b8c014dd04f95d1df18.zip llvm-92d8a28cc665d73d9d679b8c014dd04f95d1df18.tar.gz llvm-92d8a28cc665d73d9d679b8c014dd04f95d1df18.tar.bz2 |
[lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (#69991)
[lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` to return
`void` instead of ~~`bool`~~
Justifications:
- The code doesn't ultimately apply the `true`/`false` return values.
- The methods already pass around a `CommandReturnObject`, typically
with a `result` parameter.
- Each command return object already contains:
- A more precise status
- The error code(s) that apply to that status
Part 1 refactors the `CommandObject::Execute(...)` method.
- See
[https://github.com/llvm/llvm-project/pull/69989](https://github.com/llvm/llvm-project/pull/69989)
rdar://117378957
Diffstat (limited to 'lldb/source/Commands/CommandObjectWatchpointCommand.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectWatchpointCommand.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp index 37052dd..b1629ce 100644 --- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp @@ -366,7 +366,7 @@ are no syntax errors may indicate that a function was declared but never called. }; protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Target *target = &GetSelectedTarget(); const WatchpointList &watchpoints = target->GetWatchpointList(); @@ -374,7 +374,7 @@ protected: if (num_watchpoints == 0) { result.AppendError("No watchpoints exist to have commands added"); - return false; + return; } if (!m_options.m_function_name.empty()) { @@ -388,7 +388,7 @@ protected: if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, valid_wp_ids)) { result.AppendError("Invalid watchpoints specification."); - return false; + return; } result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -441,8 +441,6 @@ protected: } } } - - return result.Succeeded(); } private: @@ -475,7 +473,7 @@ public: ~CommandObjectWatchpointCommandDelete() override = default; protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Target *target = &GetSelectedTarget(); const WatchpointList &watchpoints = target->GetWatchpointList(); @@ -483,20 +481,20 @@ protected: if (num_watchpoints == 0) { result.AppendError("No watchpoints exist to have commands deleted"); - return false; + return; } if (command.GetArgumentCount() == 0) { result.AppendError( "No watchpoint specified from which to delete the commands"); - return false; + return; } std::vector<uint32_t> valid_wp_ids; if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, valid_wp_ids)) { result.AppendError("Invalid watchpoints specification."); - return false; + return; } result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -509,10 +507,9 @@ protected: wp->ClearCallback(); } else { result.AppendErrorWithFormat("Invalid watchpoint ID: %u.\n", cur_wp_id); - return false; + return; } } - return result.Succeeded(); } }; @@ -543,7 +540,7 @@ public: ~CommandObjectWatchpointCommandList() override = default; protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Target *target = &GetSelectedTarget(); const WatchpointList &watchpoints = target->GetWatchpointList(); @@ -551,20 +548,20 @@ protected: if (num_watchpoints == 0) { result.AppendError("No watchpoints exist for which to list commands"); - return false; + return; } if (command.GetArgumentCount() == 0) { result.AppendError( "No watchpoint specified for which to list the commands"); - return false; + return; } std::vector<uint32_t> valid_wp_ids; if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, valid_wp_ids)) { result.AppendError("Invalid watchpoints specification."); - return false; + return; } result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -598,8 +595,6 @@ protected: } } } - - return result.Succeeded(); } }; |