[Lldb-commits] [lldb] cee60bb - [lldb] Remove the user-defined copy-ctor in ConstString

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 23 13:09:15 PDT 2020


Author: Jonas Devlieghere
Date: 2020-07-23T13:09:08-07:00
New Revision: cee60bbf417dbec1cb3df6fc465ac06295a0cd9d

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

LOG: [lldb] Remove the user-defined copy-ctor in ConstString

ConstString is essentially trivially copyable yet it has a user defined
copy constructor that copies its one member pointer. Remove it so it
qualifies as trivial in the eyes of the compiler.

This also fixes two unused variable warnings now that the compiler knows
that the constructor has no side-effects.

Differential revision: https://reviews.llvm.org/D84440

Added: 
    

Modified: 
    lldb/include/lldb/Utility/ConstString.h
    lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h
index 5f4d747734ec..8a67faf5b54a 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -42,15 +42,7 @@ class ConstString {
   /// Default constructor
   ///
   /// Initializes the string to an empty string.
-  ConstString() : m_string(nullptr) {}
-
-  /// Copy constructor
-  ///
-  /// Copies the string value in \a rhs into this object.
-  ///
-  /// \param[in] rhs
-  ///     Another string object to copy.
-  ConstString(const ConstString &rhs) : m_string(rhs.m_string) {}
+  ConstString() = default;
 
   explicit ConstString(const llvm::StringRef &s);
 
@@ -86,12 +78,6 @@ class ConstString {
   ///     from \a cstr.
   explicit ConstString(const char *cstr, size_t max_cstr_len);
 
-  /// Destructor
-  ///
-  /// Since constant string values are currently not reference counted, there
-  /// isn't much to do here.
-  ~ConstString() = default;
-
   /// C string equality binary predicate function object for ConstString
   /// objects.
   struct StringIsEqual {
@@ -124,20 +110,6 @@ class ConstString {
   ///     false otherwise.
   explicit operator bool() const { return !IsEmpty(); }
 
-  /// Assignment operator
-  ///
-  /// Assigns the string in this object with the value from \a rhs.
-  ///
-  /// \param[in] rhs
-  ///     Another string object to copy into this object.
-  ///
-  /// \return
-  ///     A const reference to this object.
-  ConstString operator=(ConstString rhs) {
-    m_string = rhs.m_string;
-    return *this;
-  }
-
   /// Equal to operator
   ///
   /// Returns true if this string is equal to the string in \a rhs. This
@@ -445,8 +417,7 @@ class ConstString {
     return s;
   };
 
-  // Member variables
-  const char *m_string;
+  const char *m_string = nullptr;
 };
 
 /// Stream the string value \a str to the stream \a s

diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index f8fc91772198..de4bd2a79095 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1189,9 +1189,7 @@ class Application {
 
     ListenerSP listener_sp(
         Listener::MakeListener("lldb.IOHandler.curses.Application"));
-    ConstString broadcaster_class_target(Target::GetStaticBroadcasterClass());
     ConstString broadcaster_class_process(Process::GetStaticBroadcasterClass());
-    ConstString broadcaster_class_thread(Thread::GetStaticBroadcasterClass());
     debugger.EnableForwardEvents(listener_sp);
 
     bool update = true;


        


More information about the lldb-commits mailing list