[Lldb-commits] [lldb] 827c012 - [lldb] Replace calls to new with std::make_shared<> (NFC)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 19 11:20:22 PDT 2020


Author: Jonas Devlieghere
Date: 2020-06-19T11:20:15-07:00
New Revision: 827c012297f591ae8f82e3a8dbf36059ef9e0926

URL: https://github.com/llvm/llvm-project/commit/827c012297f591ae8f82e3a8dbf36059ef9e0926
DIFF: https://github.com/llvm/llvm-project/commit/827c012297f591ae8f82e3a8dbf36059ef9e0926.diff

LOG: [lldb] Replace calls to new with std::make_shared<> (NFC)

Added: 
    

Modified: 
    lldb/source/Interpreter/OptionValue.cpp
    lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
    lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
    lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp
index e127ad9550ea..198be85a7b47 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -7,10 +7,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Interpreter/OptionValue.h"
-
 #include "lldb/Interpreter/OptionValues.h"
 #include "lldb/Utility/StringList.h"
 
+#include <memory>
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -505,37 +506,37 @@ lldb::OptionValueSP OptionValue::CreateValueFromCStringForTypeMask(
   lldb::OptionValueSP value_sp;
   switch (type_mask) {
   case 1u << eTypeArch:
-    value_sp.reset(new OptionValueArch());
+    value_sp = std::make_shared<OptionValueArch>();
     break;
   case 1u << eTypeBoolean:
-    value_sp.reset(new OptionValueBoolean(false));
+    value_sp = std::make_shared<OptionValueBoolean>(false);
     break;
   case 1u << eTypeChar:
-    value_sp.reset(new OptionValueChar('\0'));
+    value_sp = std::make_shared<OptionValueChar>('\0');
     break;
   case 1u << eTypeFileSpec:
-    value_sp.reset(new OptionValueFileSpec());
+    value_sp = std::make_shared<OptionValueFileSpec>();
     break;
   case 1u << eTypeFormat:
-    value_sp.reset(new OptionValueFormat(eFormatInvalid));
+    value_sp = std::make_shared<OptionValueFormat>(eFormatInvalid);
     break;
   case 1u << eTypeFormatEntity:
-    value_sp.reset(new OptionValueFormatEntity(nullptr));
+    value_sp = std::make_shared<OptionValueFormatEntity>(nullptr);
     break;
   case 1u << eTypeLanguage:
-    value_sp.reset(new OptionValueLanguage(eLanguageTypeUnknown));
+    value_sp = std::make_shared<OptionValueLanguage>(eLanguageTypeUnknown);
     break;
   case 1u << eTypeSInt64:
-    value_sp.reset(new OptionValueSInt64());
+    value_sp = std::make_shared<OptionValueSInt64>();
     break;
   case 1u << eTypeString:
-    value_sp.reset(new OptionValueString());
+    value_sp = std::make_shared<OptionValueString>();
     break;
   case 1u << eTypeUInt64:
-    value_sp.reset(new OptionValueUInt64());
+    value_sp = std::make_shared<OptionValueUInt64>();
     break;
   case 1u << eTypeUUID:
-    value_sp.reset(new OptionValueUUID());
+    value_sp = std::make_shared<OptionValueUUID>();
     break;
   }
 

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 90dfbe288767..08b1ae0ccde2 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -161,8 +161,9 @@ class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer {
     DiagnosticOptions *m_options = new DiagnosticOptions(opts);
     m_options->ShowPresumedLoc = true;
     m_options->ShowLevel = false;
-    m_os.reset(new llvm::raw_string_ostream(m_output));
-    m_passthrough.reset(new clang::TextDiagnosticPrinter(*m_os, m_options));
+    m_os = std::make_shared<llvm::raw_string_ostream>(m_output);
+    m_passthrough =
+        std::make_shared<clang::TextDiagnosticPrinter>(*m_os, m_options);
   }
 
   void ResetManager(DiagnosticManager *manager = nullptr) {

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index e003de519884..f915a699a8e2 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <mutex>
-
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
@@ -38,6 +36,9 @@
 #include "lldb/Utility/Reproducer.h"
 #include "lldb/Utility/StreamString.h"
 
+#include <memory>
+#include <mutex>
+
 using namespace lldb_private;
 
 namespace {
@@ -130,8 +131,9 @@ StoringDiagnosticConsumer::StoringDiagnosticConsumer() {
   m_log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
 
   clang::DiagnosticOptions *m_options = new clang::DiagnosticOptions();
-  m_os.reset(new llvm::raw_string_ostream(m_output));
-  m_diag_printer.reset(new clang::TextDiagnosticPrinter(*m_os, m_options));
+  m_os = std::make_shared<llvm::raw_string_ostream>(m_output);
+  m_diag_printer =
+      std::make_shared<clang::TextDiagnosticPrinter>(*m_os, m_options);
 }
 
 void StoringDiagnosticConsumer::HandleDiagnostic(

diff  --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
index 310d9127f6db..5e3726548369 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -428,7 +428,8 @@ class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime {
 
   void InitSearchFilter(lldb::TargetSP target) {
     if (!m_filtersp)
-      m_filtersp.reset(new SearchFilterForUnconstrainedSearches(target));
+      m_filtersp =
+          std::make_shared<SearchFilterForUnconstrainedSearches>(target);
   }
 
   void FixupScriptDetails(lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);


        


More information about the lldb-commits mailing list