diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-02-11 23:13:08 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-02-11 23:13:08 +0000 |
commit | 3feca93d161bef6ecf8238e338d83e9d6813402e (patch) | |
tree | 8ba3f140453de71aa1c3233144fcf92d6beec0e4 /source/Plugins/LanguageRuntime | |
parent | 16152679c4178a5b3cc44159875d2ac6a97bb94c (diff) | |
download | lldb-3feca93d161bef6ecf8238e338d83e9d6813402e.tar.gz |
Use std::make_shared in LLDB (NFC)
Unlike std::make_unique, which is only available since C++14,
std::make_shared is available since C++11. Not only is std::make_shared
a lot more readable compared to ::reset(new), it also performs a single
heap allocation for the object and control block.
Differential revision: https://reviews.llvm.org/D57990
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@353764 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source/Plugins/LanguageRuntime')
5 files changed, 25 insertions, 16 deletions
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index fde994737..1b1778293 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -31,6 +31,7 @@ #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" +#include <memory> #include <vector> using namespace lldb; @@ -111,10 +112,10 @@ AppleObjCRuntimeV1::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, BreakpointResolverSP resolver_sp; if (throw_bp) - resolver_sp.reset(new BreakpointResolverName( + resolver_sp = std::make_shared<BreakpointResolverName>( bkpt, std::get<1>(GetExceptionThrowLocation()).AsCString(), eFunctionNameTypeBase, eLanguageTypeUnknown, Breakpoint::Exact, 0, - eLazyBoolNo)); + eLazyBoolNo); // FIXME: don't do catch yet. return resolver_sp; } diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 96e2c098e..cd7f332c6 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -8,6 +8,7 @@ #include <stdint.h> +#include <memory> #include <string> #include <vector> @@ -803,10 +804,10 @@ AppleObjCRuntimeV2::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, BreakpointResolverSP resolver_sp; if (throw_bp) - resolver_sp.reset(new BreakpointResolverName( + resolver_sp = std::make_shared<BreakpointResolverName>( bkpt, std::get<1>(GetExceptionThrowLocation()).AsCString(), eFunctionNameTypeBase, eLanguageTypeUnknown, Breakpoint::Exact, 0, - eLazyBoolNo)); + eLazyBoolNo); // FIXME: We don't do catch breakpoints for ObjC yet. // Should there be some way for the runtime to specify what it can do in this // regard? @@ -2549,7 +2550,8 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA( ObjCLanguageRuntime::EncodingToTypeSP AppleObjCRuntimeV2::GetEncodingToType() { if (!m_encoding_to_type_sp) - m_encoding_to_type_sp.reset(new AppleObjCTypeEncodingParser(*this)); + m_encoding_to_type_sp = + std::make_shared<AppleObjCTypeEncodingParser>(*this); return m_encoding_to_type_sp; } diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index aeb8294b7..bd7484483 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "AppleObjCTrampolineHandler.h" - #include "AppleThreadPlanStepThroughObjCTrampoline.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" @@ -36,6 +35,8 @@ #include "llvm/ADT/STLExtras.h" +#include <memory> + using namespace lldb; using namespace lldb_private; @@ -1048,8 +1049,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, log->Printf("Found implementation address in cache: 0x%" PRIx64, impl_addr); - ret_plan_sp.reset( - new ThreadPlanRunToAddress(thread, impl_addr, stop_others)); + ret_plan_sp = std::make_shared<ThreadPlanRunToAddress>(thread, impl_addr, + stop_others); } else { // We haven't seen this class/selector pair yet. Look it up. StreamString errors; @@ -1128,9 +1129,9 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, // is not safe to run only one thread. So we override the // stop_others value passed in to us here: const bool trampoline_stop_others = false; - ret_plan_sp.reset(new AppleThreadPlanStepThroughObjCTrampoline( + ret_plan_sp = std::make_shared<AppleThreadPlanStepThroughObjCTrampoline>( thread, this, dispatch_values, isa_addr, sel_addr, - trampoline_stop_others)); + trampoline_stop_others); if (log) { StreamString s; ret_plan_sp->GetDescription(&s, eDescriptionLevelFull); diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp index 85fd6620c..bbfd8075d 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "AppleThreadPlanStepThroughObjCTrampoline.h" + #include "AppleObjCTrampolineHandler.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/FunctionCaller.h" @@ -20,6 +21,8 @@ #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Utility/Log.h" +#include <memory> + using namespace lldb; using namespace lldb_private; @@ -183,8 +186,8 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) { // Extract the target address from the value: - m_run_to_sp.reset( - new ThreadPlanRunToAddress(m_thread, target_so_addr, m_stop_others)); + m_run_to_sp = std::make_shared<ThreadPlanRunToAddress>( + m_thread, target_so_addr, m_stop_others); m_thread.QueueThreadPlan(m_run_to_sp, false); m_run_to_sp->SetPrivate(true); return false; diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp index bae1da0ed..b6739345c 100644 --- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -6,8 +6,6 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ADT/StringSwitch.h" - #include "RenderScriptRuntime.h" #include "RenderScriptScriptGroup.h" @@ -40,6 +38,10 @@ #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Status.h" +#include "llvm/ADT/StringSwitch.h" + +#include <memory> + using namespace lldb; using namespace lldb_private; using namespace lldb_renderscript; @@ -1211,7 +1213,7 @@ void RenderScriptRuntime::CaptureDebugHintScriptGroup2( } } if (!group) { - group.reset(new RSScriptGroupDescriptor); + group = std::make_shared<RSScriptGroupDescriptor>(); group->m_name = group_name; m_scriptGroups.push_back(group); } else { @@ -2854,7 +2856,7 @@ bool RenderScriptRuntime::LoadModule(const lldb::ModuleSP &module_sp) { switch (GetModuleKind(module_sp)) { case eModuleKindKernelObj: { RSModuleDescriptorSP module_desc; - module_desc.reset(new RSModuleDescriptor(module_sp)); + module_desc = std::make_shared<RSModuleDescriptor>(module_sp); if (module_desc->ParseRSInfo()) { m_rsmodules.push_back(module_desc); module_desc->WarnIfVersionMismatch(GetProcess() |