[lldb] Unify target checking in CommandObject
authorRaphael Isemann <teemperor@gmail.com>
Sat, 31 Aug 2019 09:41:25 +0000 (09:41 +0000)
committerRaphael Isemann <teemperor@gmail.com>
Sat, 31 Aug 2019 09:41:25 +0000 (09:41 +0000)
commit04a4c0910b08fcd3961ad8cc74f99535efdee39a
tree65a472863f8ed47d0fa2c5ca03353e06d1e8b894
parentd4df363b14fe91ac235c830f295551fd0f3e867b
[lldb] Unify target checking in CommandObject

Summary:
We currently have several CommandObjects that manually reimplement the checking for a selected target
or a target in the execution context (which is the selected target when they are invoked). This patch removes
all these checks and replaces them by setting the eCommandRequiresTarget flag that Pavel suggested. With
this flag we are doing the same check but without having to duplicate this code in all these CommandObjects.

I also added a `GetSelectedTarget()` variant of the `GetSelectedOrDummyTarget()` function to the
CommandObject that checks that the flag is set and then returns a reference to the target. I didn't rewrite
all the `target` variables from `Target *` to `Target &` in this patch as last time this change caused a lot of merge
conflicts in Swift and I would prefer having that in a separate NFC commit.

Reviewers: labath, clayborg

Reviewed By: labath, clayborg

Subscribers: clayborg, JDevlieghere, jingham, amccarth, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D66863

llvm-svn: 370571
lldb/include/lldb/Interpreter/CommandObject.h
lldb/source/Commands/CommandObjectBreakpointCommand.cpp
lldb/source/Commands/CommandObjectDisassemble.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Commands/CommandObjectWatchpoint.cpp
lldb/source/Commands/CommandObjectWatchpointCommand.cpp
lldb/source/Interpreter/CommandObject.cpp