bulbazord updated this revision to Diff 529029.
bulbazord added a comment.

Address @JDevlieghere's comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152220/new/

https://reviews.llvm.org/D152220

Files:
  lldb/include/lldb/Utility/Broadcaster.h
  lldb/source/API/SBBroadcaster.cpp
  lldb/source/Core/ThreadedCommunication.cpp
  lldb/source/Utility/Broadcaster.cpp
  lldb/source/Utility/Event.cpp
  lldb/source/Utility/Listener.cpp

Index: lldb/source/Utility/Listener.cpp
===================================================================
--- lldb/source/Utility/Listener.cpp
+++ lldb/source/Utility/Listener.cpp
@@ -234,7 +234,7 @@
 
     if (m_broadcaster_names) {
       bool found_source = false;
-      ConstString event_broadcaster_name =
+      const llvm::StringRef event_broadcaster_name =
           event_sp->GetBroadcaster()->GetBroadcasterName();
       for (uint32_t i = 0; i < m_num_broadcaster_names; ++i) {
         if (m_broadcaster_names[i] == event_broadcaster_name) {
Index: lldb/source/Utility/Event.cpp
===================================================================
--- lldb/source/Utility/Event.cpp
+++ lldb/source/Utility/Event.cpp
@@ -58,13 +58,13 @@
       s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x (%s), data = ",
                 static_cast<const void *>(this),
                 static_cast<void *>(broadcaster),
-                broadcaster->GetBroadcasterName().GetCString(), m_type,
+                broadcaster->GetBroadcasterName().c_str(), m_type,
                 event_name.GetData());
     else
       s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x, data = ",
                 static_cast<const void *>(this),
                 static_cast<void *>(broadcaster),
-                broadcaster->GetBroadcasterName().GetCString(), m_type);
+                broadcaster->GetBroadcasterName().c_str(), m_type);
   } else
     s->Printf("%p Event: broadcaster = NULL, type = 0x%8.8x, data = ",
               static_cast<const void *>(this), m_type);
Index: lldb/source/Utility/Broadcaster.cpp
===================================================================
--- lldb/source/Utility/Broadcaster.cpp
+++ lldb/source/Utility/Broadcaster.cpp
@@ -23,9 +23,9 @@
 using namespace lldb;
 using namespace lldb_private;
 
-Broadcaster::Broadcaster(BroadcasterManagerSP manager_sp, const char *name)
+Broadcaster::Broadcaster(BroadcasterManagerSP manager_sp, std::string name)
     : m_broadcaster_sp(std::make_shared<BroadcasterImpl>(*this)),
-      m_manager_sp(std::move(manager_sp)), m_broadcaster_name(name) {
+      m_manager_sp(std::move(manager_sp)), m_broadcaster_name(std::move(name)) {
   Log *log = GetLog(LLDBLog::Object);
   LLDB_LOG(log, "{0} Broadcaster::Broadcaster(\"{1}\")",
            static_cast<void *>(this), GetBroadcasterName());
@@ -216,8 +216,8 @@
     StreamString event_description;
     event_sp->Dump(&event_description);
     LLDB_LOGF(log,
-              "%p Broadcaster(\"%s\")::BroadcastEvent (event_sp = {%s}, "
-              "unique =%i) hijack = %p",
+              "{0:x} Broadcaster(\"{1}\")::BroadcastEvent (event_sp = {2}, "
+              "unique={3}) hijack = {4:x}",
               static_cast<void *>(this), GetBroadcasterName(),
               event_description.GetData(), unique,
               static_cast<void *>(hijacking_listener_sp.get()));
Index: lldb/source/Core/ThreadedCommunication.cpp
===================================================================
--- lldb/source/Core/ThreadedCommunication.cpp
+++ lldb/source/Core/ThreadedCommunication.cpp
@@ -57,7 +57,7 @@
 ThreadedCommunication::~ThreadedCommunication() {
   LLDB_LOG(GetLog(LLDBLog::Object | LLDBLog::Communication),
            "{0} ThreadedCommunication::~ThreadedCommunication (name = {1})",
-           this, GetBroadcasterName().AsCString());
+           this, GetBroadcasterName());
 }
 
 void ThreadedCommunication::Clear() {
Index: lldb/source/API/SBBroadcaster.cpp
===================================================================
--- lldb/source/API/SBBroadcaster.cpp
+++ lldb/source/API/SBBroadcaster.cpp
@@ -92,7 +92,7 @@
   LLDB_INSTRUMENT_VA(this);
 
   if (m_opaque_ptr)
-    return m_opaque_ptr->GetBroadcasterName().GetCString();
+    return ConstString(m_opaque_ptr->GetBroadcasterName()).GetCString();
   return nullptr;
 }
 
Index: lldb/include/lldb/Utility/Broadcaster.h
===================================================================
--- lldb/include/lldb/Utility/Broadcaster.h
+++ lldb/include/lldb/Utility/Broadcaster.h
@@ -149,10 +149,12 @@
 public:
   /// Construct with a broadcaster with a name.
   ///
+  /// \param[in] manager_sp
+  ///   A shared pointer to the BroadcasterManager that will manage this
+  ///   broadcaster.
   /// \param[in] name
-  ///     A NULL terminated C string that contains the name of the
-  ///     broadcaster object.
-  Broadcaster(lldb::BroadcasterManagerSP manager_sp, const char *name);
+  ///   A std::string of the name that this broadcaster will have.
+  Broadcaster(lldb::BroadcasterManagerSP manager_sp, std::string name);
 
   /// Destructor.
   ///
@@ -213,11 +215,12 @@
     return m_broadcaster_sp->AddListener(listener_sp, event_mask);
   }
 
-  /// Get the NULL terminated C string name of this Broadcaster object.
+  /// Get this broadcaster's name.
   ///
   /// \return
-  ///     The NULL terminated C string name of this Broadcaster.
-  ConstString GetBroadcasterName() { return m_broadcaster_name; }
+  ///     A reference to a constant std::string containing the name of the
+  ///     broadcaster.
+  const std::string &GetBroadcasterName() { return m_broadcaster_name; }
 
   /// Get the event name(s) for one or more event bits.
   ///
@@ -352,8 +355,8 @@
     uint32_t AddListener(const lldb::ListenerSP &listener_sp,
                          uint32_t event_mask);
 
-    const char *GetBroadcasterName() const {
-      return m_broadcaster.GetBroadcasterName().AsCString();
+    llvm::StringRef GetBroadcasterName() const {
+      return m_broadcaster.GetBroadcasterName();
     }
 
     Broadcaster *GetBroadcaster();
@@ -443,7 +446,7 @@
   lldb::BroadcasterManagerSP m_manager_sp;
 
   /// The name of this broadcaster object.
-  const ConstString m_broadcaster_name;
+  const std::string m_broadcaster_name;
 
   Broadcaster(const Broadcaster &) = delete;
   const Broadcaster &operator=(const Broadcaster &) = delete;
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to