From 7dd8c12d847ba578b8783dc883611a7df13c5d68 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 15 Sep 2015 12:00:08 +0000 Subject: [lldb-mi] Clean up CMICmdArgSet usage. Summary: CMICmdArgSet stores a vector of non-const pointers to the arguments that it is validating. It owns them and is responsible for deleting them. We don't need to pass a const reference to the argument to CMICmdArgSet::Add and then take the address and const_cast it when we can just pass the argument pointer in directly. This lets us remove some noise at every call site for CMICmdArgSet::Add and then clean up a couple of bits inside CMICmdArgSet to remove const_casts. Reviewers: abidh, ki.stfu, domipheus Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D12878 llvm-svn: 247677 --- lldb/tools/lldb-mi/MICmdArgSet.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lldb/tools/lldb-mi/MICmdArgSet.cpp') diff --git a/lldb/tools/lldb-mi/MICmdArgSet.cpp b/lldb/tools/lldb-mi/MICmdArgSet.cpp index 7439e11dd71..9fe5b2d97dc 100644 --- a/lldb/tools/lldb-mi/MICmdArgSet.cpp +++ b/lldb/tools/lldb-mi/MICmdArgSet.cpp @@ -94,10 +94,9 @@ CMICmdArgSet::IsArgsPresentButNotHandledByCmd() const // Throws: None. //-- void -CMICmdArgSet::Add(const CMICmdArgValBase &vArg) +CMICmdArgSet::Add(CMICmdArgValBase *vArg) { - CMICmdArgValBase *pArg = const_cast(&vArg); - m_setCmdArgs.push_back(pArg); + m_setCmdArgs.push_back(vArg); } //++ ------------------------------------------------------------------------------------ @@ -169,25 +168,25 @@ CMICmdArgSet::Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdAr SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin(); while (it != m_setCmdArgs.end()) { - const CMICmdArgValBase *pArg(*it); + CMICmdArgValBase *pArg = *it; - if (!const_cast(pArg)->Validate(vwCmdArgsText)) + if (!pArg->Validate(vwCmdArgsText)) { if (pArg->GetFound()) { if (pArg->GetIsMissingOptions()) - m_setCmdArgsMissingInfo.push_back(const_cast(pArg)); + m_setCmdArgsMissingInfo.push_back(pArg); else if (!pArg->GetValid()) - m_setCmdArgsThatNotValid.push_back(const_cast(pArg)); + m_setCmdArgsThatNotValid.push_back(pArg); } else if (pArg->GetIsMandatory()) - m_setCmdArgsThatAreMissing.push_back(const_cast(pArg)); + m_setCmdArgsThatAreMissing.push_back(pArg); } if (pArg->GetFound() && !pArg->GetIsHandledByCmd()) { m_bIsArgsPresentButNotHandledByCmd = true; - m_setCmdArgsNotHandledByCmd.push_back(const_cast(pArg)); + m_setCmdArgsNotHandledByCmd.push_back(pArg); } // Next -- cgit v1.2.3