diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/tools/lldb-mi/MICmdFactory.cpp | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2 |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/tools/lldb-mi/MICmdFactory.cpp')
-rw-r--r-- | lldb/tools/lldb-mi/MICmdFactory.cpp | 235 |
1 files changed, 116 insertions, 119 deletions
diff --git a/lldb/tools/lldb-mi/MICmdFactory.cpp b/lldb/tools/lldb-mi/MICmdFactory.cpp index e2a8b5b..8f62154 100644 --- a/lldb/tools/lldb-mi/MICmdFactory.cpp +++ b/lldb/tools/lldb-mi/MICmdFactory.cpp @@ -9,35 +9,33 @@ // In-house headers: #include "MICmdFactory.h" -#include "MICmnResources.h" -#include "MICmdData.h" #include "MICmdBase.h" #include "MICmdCommands.h" +#include "MICmdData.h" +#include "MICmnResources.h" -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: CMICmdFactory constructor. // Type: Method. // Args: None. // Return: None. // Throws: None. //-- -CMICmdFactory::CMICmdFactory() -{ -} +CMICmdFactory::CMICmdFactory() {} -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: CMICmdFactory destructor. // Type: Overridable. // Args: None. // Return: None. // Throws: None. //-- -CMICmdFactory::~CMICmdFactory() -{ - Shutdown(); -} +CMICmdFactory::~CMICmdFactory() { Shutdown(); } -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: Initialize resources for *this Command factory. // Type: Method. // Args: None. @@ -45,22 +43,21 @@ CMICmdFactory::~CMICmdFactory() // MIstatus::failure - Functionality failed. // Throws: None. //-- -bool -CMICmdFactory::Initialize() -{ - m_clientUsageRefCnt++; +bool CMICmdFactory::Initialize() { + m_clientUsageRefCnt++; - if (m_bInitialized) - return MIstatus::success; + if (m_bInitialized) + return MIstatus::success; - m_bInitialized = true; + m_bInitialized = true; - MICmnCommands::RegisterAll(); + MICmnCommands::RegisterAll(); - return MIstatus::success; + return MIstatus::success; } -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: Release resources for *this Command Factory. // Type: Method. // Args: None. @@ -68,24 +65,24 @@ CMICmdFactory::Initialize() // MIstatus::failure - Functionality failed. // Throws: None. //-- -bool -CMICmdFactory::Shutdown() -{ - if (--m_clientUsageRefCnt > 0) - return MIstatus::success; +bool CMICmdFactory::Shutdown() { + if (--m_clientUsageRefCnt > 0) + return MIstatus::success; - if (!m_bInitialized) - return MIstatus::success; + if (!m_bInitialized) + return MIstatus::success; - m_mapMiCmdToCmdCreatorFn.clear(); + m_mapMiCmdToCmdCreatorFn.clear(); - m_bInitialized = false; + m_bInitialized = false; - return MIstatus::success; + return MIstatus::success; } -//++ ------------------------------------------------------------------------------------ -// Details: Register a command's creator function with the command identifier the MI +//++ +//------------------------------------------------------------------------------------ +// Details: Register a command's creator function with the command identifier +// the MI // command name i.e. 'file-exec-and-symbols'. // Type: Method. // Args: vMiCmd - (R) Command's name, the MI command. @@ -94,33 +91,33 @@ CMICmdFactory::Shutdown() // MIstatus::failure - Functionality failed. // Throws: None. //-- -bool -CMICmdFactory::CmdRegister(const CMIUtilString &vMiCmd, CmdCreatorFnPtr vCmdCreateFn) -{ - if (!IsValid(vMiCmd)) - { - SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMDFACTORY_ERR_INVALID_CMD_NAME), vMiCmd.c_str())); - return MIstatus::failure; - } - if (vCmdCreateFn == nullptr) - { - SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMDFACTORY_ERR_INVALID_CMD_CR8FN), vMiCmd.c_str())); - return MIstatus::failure; - } - - if (HaveAlready(vMiCmd)) - { - SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMDFACTORY_ERR_CMD_ALREADY_REGED), vMiCmd.c_str())); - return MIstatus::failure; - } - - MapPairMiCmdToCmdCreatorFn_t pr(vMiCmd, vCmdCreateFn); - m_mapMiCmdToCmdCreatorFn.insert(pr); - - return MIstatus::success; +bool CMICmdFactory::CmdRegister(const CMIUtilString &vMiCmd, + CmdCreatorFnPtr vCmdCreateFn) { + if (!IsValid(vMiCmd)) { + SetErrorDescription(CMIUtilString::Format( + MIRSRC(IDS_CMDFACTORY_ERR_INVALID_CMD_NAME), vMiCmd.c_str())); + return MIstatus::failure; + } + if (vCmdCreateFn == nullptr) { + SetErrorDescription(CMIUtilString::Format( + MIRSRC(IDS_CMDFACTORY_ERR_INVALID_CMD_CR8FN), vMiCmd.c_str())); + return MIstatus::failure; + } + + if (HaveAlready(vMiCmd)) { + SetErrorDescription(CMIUtilString::Format( + MIRSRC(IDS_CMDFACTORY_ERR_CMD_ALREADY_REGED), vMiCmd.c_str())); + return MIstatus::failure; + } + + MapPairMiCmdToCmdCreatorFn_t pr(vMiCmd, vCmdCreateFn); + m_mapMiCmdToCmdCreatorFn.insert(pr); + + return MIstatus::success; } -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: Check a command is already registered. // Type: Method. // Args: vMiCmd - (R) Command's name, the MI command. @@ -128,17 +125,17 @@ CMICmdFactory::CmdRegister(const CMIUtilString &vMiCmd, CmdCreatorFnPtr vCmdCrea // False - not found. // Throws: None. //-- -bool -CMICmdFactory::HaveAlready(const CMIUtilString &vMiCmd) const -{ - const MapMiCmdToCmdCreatorFn_t::const_iterator it = m_mapMiCmdToCmdCreatorFn.find(vMiCmd); - if (it != m_mapMiCmdToCmdCreatorFn.end()) - return true; +bool CMICmdFactory::HaveAlready(const CMIUtilString &vMiCmd) const { + const MapMiCmdToCmdCreatorFn_t::const_iterator it = + m_mapMiCmdToCmdCreatorFn.find(vMiCmd); + if (it != m_mapMiCmdToCmdCreatorFn.end()) + return true; - return false; + return false; } -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: Check a command's name is valid: // - name is not empty // - name does not have spaces @@ -148,25 +145,23 @@ CMICmdFactory::HaveAlready(const CMIUtilString &vMiCmd) const // False - not valid. // Throws: None. //-- -bool -CMICmdFactory::IsValid(const CMIUtilString &vMiCmd) const -{ - bool bValid = true; - - if (vMiCmd.empty()) - { - bValid = false; - return false; - } - - const size_t nPos = vMiCmd.find(' '); - if (nPos != std::string::npos) - bValid = false; - - return bValid; +bool CMICmdFactory::IsValid(const CMIUtilString &vMiCmd) const { + bool bValid = true; + + if (vMiCmd.empty()) { + bValid = false; + return false; + } + + const size_t nPos = vMiCmd.find(' '); + if (nPos != std::string::npos) + bValid = false; + + return bValid; } -//++ ------------------------------------------------------------------------------------ +//++ +//------------------------------------------------------------------------------------ // Details: Check a command is already registered. // Type: Method. // Args: vMiCmd - (R) Command's name, the MI command. @@ -174,49 +169,51 @@ CMICmdFactory::IsValid(const CMIUtilString &vMiCmd) const // False - not found. // Throws: None. //-- -bool -CMICmdFactory::CmdExist(const CMIUtilString &vMiCmd) const -{ - return HaveAlready(vMiCmd); +bool CMICmdFactory::CmdExist(const CMIUtilString &vMiCmd) const { + return HaveAlready(vMiCmd); } -//++ ------------------------------------------------------------------------------------ -// Details: Create a command given the specified MI command name. The command data object +//++ +//------------------------------------------------------------------------------------ +// Details: Create a command given the specified MI command name. The command +// data object // contains the options for the command. // Type: Method. // Args: vMiCmd - (R) Command's name, the MI command. -// vCmdData - (RW) Command's metadata status/information/result object. +// vCmdData - (RW) Command's metadata status/information/result +// object. // vpNewCmd - (W) New command instance. // Return: MIstatus::success - Functionality succeeded. // MIstatus::failure - Functionality failed. // Throws: None. //-- -bool -CMICmdFactory::CmdCreate(const CMIUtilString &vMiCmd, const SMICmdData &vCmdData, CMICmdBase *&vpNewCmd) -{ - vpNewCmd = nullptr; - - if (!IsValid(vMiCmd)) - { - SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMDFACTORY_ERR_INVALID_CMD_NAME), vMiCmd.c_str())); - return MIstatus::failure; - } - if (!HaveAlready(vMiCmd)) - { - SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMDFACTORY_ERR_CMD_NOT_REGISTERED), vMiCmd.c_str())); - return MIstatus::failure; - } - - const MapMiCmdToCmdCreatorFn_t::const_iterator it = m_mapMiCmdToCmdCreatorFn.find(vMiCmd); - const CMIUtilString &rMiCmd((*it).first); - MIunused(rMiCmd); - CmdCreatorFnPtr pFn = (*it).second; - CMICmdBase *pCmd = (*pFn)(); - - SMICmdData cmdData(vCmdData); - cmdData.id = pCmd->GetGUID(); - pCmd->SetCmdData(cmdData); - vpNewCmd = pCmd; - - return MIstatus::success; +bool CMICmdFactory::CmdCreate(const CMIUtilString &vMiCmd, + const SMICmdData &vCmdData, + CMICmdBase *&vpNewCmd) { + vpNewCmd = nullptr; + + if (!IsValid(vMiCmd)) { + SetErrorDescription(CMIUtilString::Format( + MIRSRC(IDS_CMDFACTORY_ERR_INVALID_CMD_NAME), vMiCmd.c_str())); + return MIstatus::failure; + } + if (!HaveAlready(vMiCmd)) { + SetErrorDescription(CMIUtilString::Format( + MIRSRC(IDS_CMDFACTORY_ERR_CMD_NOT_REGISTERED), vMiCmd.c_str())); + return MIstatus::failure; + } + + const MapMiCmdToCmdCreatorFn_t::const_iterator it = + m_mapMiCmdToCmdCreatorFn.find(vMiCmd); + const CMIUtilString &rMiCmd((*it).first); + MIunused(rMiCmd); + CmdCreatorFnPtr pFn = (*it).second; + CMICmdBase *pCmd = (*pFn)(); + + SMICmdData cmdData(vCmdData); + cmdData.id = pCmd->GetGUID(); + pCmd->SetCmdData(cmdData); + vpNewCmd = pCmd; + + return MIstatus::success; } |