[Lldb-commits] [lldb] de74756 - [lldb] Remove LogHandler::Create functions (NFC)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 16 21:04:13 PDT 2022


Author: Jonas Devlieghere
Date: 2022-06-16T21:04:08-07:00
New Revision: de7475657156658d16704e956a17a39709de2fdd

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

LOG: [lldb] Remove LogHandler::Create functions (NFC)

Remove the LogHandler::Create functions. Except for the StreamHandler
they were just forwarding their arguments to std::make_shared.

Added: 
    

Modified: 
    lldb/include/lldb/Utility/Log.h
    lldb/source/Core/Debugger.cpp
    lldb/source/Utility/Log.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h
index 0beb97b4891f1..806eb390773b9 100644
--- a/lldb/include/lldb/Utility/Log.h
+++ b/lldb/include/lldb/Utility/Log.h
@@ -58,12 +58,10 @@ class LogHandler {
 
 class StreamLogHandler : public LogHandler {
 public:
-  StreamLogHandler(int fd, bool should_close, bool unbuffered);
+  StreamLogHandler(int fd, bool should_close, bool unbuffered = true);
 
   void Emit(llvm::StringRef message) override;
 
-  static std::shared_ptr<StreamLogHandler> Create(int fd, bool unbuffered);
-
 private:
   llvm::raw_fd_ostream m_stream;
 };
@@ -74,9 +72,6 @@ class CallbackLogHandler : public LogHandler {
 
   void Emit(llvm::StringRef message) override;
 
-  static std::shared_ptr<CallbackLogHandler>
-  Create(lldb::LogOutputCallback callback, void *baton);
-
 private:
   lldb::LogOutputCallback m_callback;
   void *m_baton;
@@ -89,8 +84,6 @@ class RotatingLogHandler : public LogHandler {
   void Emit(llvm::StringRef message) override;
   void Dump(llvm::raw_ostream &stream) const;
 
-  static std::shared_ptr<RotatingLogHandler> Create(size_t size);
-
 private:
   size_t NormalizeIndex(size_t i) const;
   size_t GetNumMessages() const;

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 08d95c0ea6545..c6f1cbe581dac 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -757,7 +757,8 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
       m_forward_listener_sp(), m_clear_once() {
   m_instance_name.SetString(llvm::formatv("debugger_{0}", GetID()).str());
   if (log_callback)
-    m_callback_handler_sp = CallbackLogHandler::Create(log_callback, baton);
+    m_callback_handler_sp =
+        std::make_shared<CallbackLogHandler>(log_callback, baton);
   m_command_interpreter_up->Initialize();
   // Always add our default platform to the platform list
   PlatformSP default_platform_sp(Platform::GetHostPlatform());
@@ -1290,7 +1291,8 @@ void Debugger::SetLoggingCallback(lldb::LogOutputCallback log_callback,
   // For simplicity's sake, I am not going to deal with how to close down any
   // open logging streams, I just redirect everything from here on out to the
   // callback.
-  m_callback_handler_sp = CallbackLogHandler::Create(log_callback, baton);
+  m_callback_handler_sp =
+      std::make_shared<CallbackLogHandler>(log_callback, baton);
 }
 
 static void PrivateReportProgress(Debugger &debugger, uint64_t progress_id,
@@ -1417,8 +1419,8 @@ bool Debugger::EnableLog(llvm::StringRef channel,
     log_options |=
         LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
   } else if (log_file.empty()) {
-    log_handler_sp = StreamLogHandler::Create(GetOutputFile().GetDescriptor(),
-                                              !should_close);
+    log_handler_sp = std::make_shared<StreamLogHandler>(
+        GetOutputFile().GetDescriptor(), !should_close);
   } else {
     auto pos = m_stream_handlers.find(log_file);
     if (pos != m_stream_handlers.end())
@@ -1438,8 +1440,8 @@ bool Debugger::EnableLog(llvm::StringRef channel,
         return false;
       }
 
-      log_handler_sp =
-          StreamLogHandler::Create((*file)->GetDescriptor(), should_close);
+      log_handler_sp = std::make_shared<StreamLogHandler>(
+          (*file)->GetDescriptor(), should_close);
       m_stream_handlers[log_file] = log_handler_sp;
     }
   }

diff  --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp
index 62547154dbee5..6649dc0b9f730 100644
--- a/lldb/source/Utility/Log.cpp
+++ b/lldb/source/Utility/Log.cpp
@@ -347,12 +347,6 @@ void StreamLogHandler::Emit(llvm::StringRef message) {
   m_stream.flush();
 }
 
-std::shared_ptr<StreamLogHandler> StreamLogHandler::Create(int fd,
-                                                           bool should_close) {
-  constexpr const bool unbuffered = true;
-  return std::make_shared<StreamLogHandler>(fd, should_close, unbuffered);
-}
-
 CallbackLogHandler::CallbackLogHandler(lldb::LogOutputCallback callback,
                                        void *baton)
     : m_callback(callback), m_baton(baton) {}
@@ -361,11 +355,6 @@ void CallbackLogHandler::Emit(llvm::StringRef message) {
   m_callback(message.data(), m_baton);
 }
 
-std::shared_ptr<CallbackLogHandler>
-CallbackLogHandler::Create(lldb::LogOutputCallback callback, void *baton) {
-  return std::make_shared<CallbackLogHandler>(callback, baton);
-}
-
 RotatingLogHandler::RotatingLogHandler(size_t size)
     : m_messages(std::make_unique<std::string[]>(size)), m_size(size) {}
 
@@ -395,7 +384,3 @@ void RotatingLogHandler::Dump(llvm::raw_ostream &stream) const {
   }
   stream.flush();
 }
-
-std::shared_ptr<RotatingLogHandler> RotatingLogHandler::Create(size_t size) {
-  return std::make_shared<RotatingLogHandler>(size);
-}


        


More information about the lldb-commits mailing list