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
llvm-svn: 353764
diff --git a/lldb/source/Target/CPPLanguageRuntime.cpp b/lldb/source/Target/CPPLanguageRuntime.cpp
index f3d3ad5..ead8d78 100644
--- a/lldb/source/Target/CPPLanguageRuntime.cpp
+++ b/lldb/source/Target/CPPLanguageRuntime.cpp
@@ -11,6 +11,8 @@
#include <string.h>
+#include <memory>
+
#include "llvm/ADT/StringRef.h"
#include "lldb/Symbol/Block.h"
@@ -327,16 +329,16 @@
value_sp->GetValueIsValid()) {
// We found the std::function wrapped callable and we have its address.
// We now create a ThreadPlan to run to the callable.
- ret_plan_sp.reset(new ThreadPlanRunToAddress(
- thread, callable_info.callable_address, stop_others));
+ ret_plan_sp = std::make_shared<ThreadPlanRunToAddress>(
+ thread, callable_info.callable_address, stop_others);
return ret_plan_sp;
} else {
// We are in std::function but we could not obtain the callable.
// We create a ThreadPlan to keep stepping through using the address range
// of the current function.
- ret_plan_sp.reset(new ThreadPlanStepInRange(thread, range_of_curr_func,
- sc, eOnlyThisThread,
- eLazyBoolYes, eLazyBoolYes));
+ ret_plan_sp = std::make_shared<ThreadPlanStepInRange>(
+ thread, range_of_curr_func, sc, eOnlyThisThread, eLazyBoolYes,
+ eLazyBoolYes);
return ret_plan_sp;
}
}