https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/84263

>From e5bed6b190687cc31ecb69da006bc93d9284994a Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee....@gmail.com>
Date: Wed, 6 Mar 2024 16:03:22 -0800
Subject: [PATCH 1/2] [lldb] Minor cleanup in StoringDiagnosticConsumer

---
 .../ExpressionParser/Clang/ClangModulesDeclVendor.cpp      | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 5ce0d35378230c..7fdaa2762be56d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -80,7 +80,6 @@ class StoringDiagnosticConsumer : public 
clang::DiagnosticConsumer {
   std::shared_ptr<llvm::raw_string_ostream> m_os;
   /// Output string filled by m_os. Will be reused for different diagnostics.
   std::string m_output;
-  Log *m_log;
   /// A Progress with explicitly managed lifetime.
   std::unique_ptr<Progress> m_current_progress_up;
   std::vector<std::string> m_module_build_stack;
@@ -142,12 +141,10 @@ class ClangModulesDeclVendorImpl : public 
ClangModulesDeclVendor {
 } // anonymous namespace
 
 StoringDiagnosticConsumer::StoringDiagnosticConsumer() {
-  m_log = GetLog(LLDBLog::Expressions);
-
-  clang::DiagnosticOptions *m_options = new clang::DiagnosticOptions();
+  clang::DiagnosticOptions *options = new clang::DiagnosticOptions();
   m_os = std::make_shared<llvm::raw_string_ostream>(m_output);
   m_diag_printer =
-      std::make_shared<clang::TextDiagnosticPrinter>(*m_os, m_options);
+      std::make_shared<clang::TextDiagnosticPrinter>(*m_os, options);
 }
 
 void StoringDiagnosticConsumer::HandleDiagnostic(

>From 13bfecf4740f7a3cf8cef98a91f4560fe6a59cfd Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee....@gmail.com>
Date: Wed, 6 Mar 2024 16:10:37 -0800
Subject: [PATCH 2/2] more cleanup

---
 .../Clang/ClangModulesDeclVendor.cpp                 | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 7fdaa2762be56d..2a992d6b36208d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -75,9 +75,11 @@ class StoringDiagnosticConsumer : public 
clang::DiagnosticConsumer {
   std::vector<IDAndDiagnostic> m_diagnostics;
   /// The DiagnosticPrinter used for creating the full diagnostic messages
   /// that are stored in m_diagnostics.
-  std::shared_ptr<clang::TextDiagnosticPrinter> m_diag_printer;
+  std::unique_ptr<clang::TextDiagnosticPrinter> m_diag_printer;
   /// Output stream of m_diag_printer.
-  std::shared_ptr<llvm::raw_string_ostream> m_os;
+  std::unique_ptr<llvm::raw_string_ostream> m_os;
+  /// Diagnostics options of m_diag_printer.
+  std::unique_ptr<clang::DiagnosticOptions> m_options;
   /// Output string filled by m_os. Will be reused for different diagnostics.
   std::string m_output;
   /// A Progress with explicitly managed lifetime.
@@ -141,10 +143,10 @@ class ClangModulesDeclVendorImpl : public 
ClangModulesDeclVendor {
 } // anonymous namespace
 
 StoringDiagnosticConsumer::StoringDiagnosticConsumer() {
-  clang::DiagnosticOptions *options = new clang::DiagnosticOptions();
-  m_os = std::make_shared<llvm::raw_string_ostream>(m_output);
+  m_options = std::make_unique<clang::DiagnosticOptions>();
+  m_os = std::make_unique<llvm::raw_string_ostream>(m_output);
   m_diag_printer =
-      std::make_shared<clang::TextDiagnosticPrinter>(*m_os, options);
+      std::make_unique<clang::TextDiagnosticPrinter>(*m_os, m_options.get());
 }
 
 void StoringDiagnosticConsumer::HandleDiagnostic(

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to