[TargetList] Delete the destructor
authorVedant Kumar <vsk@apple.com>
Fri, 6 Nov 2020 00:41:31 +0000 (16:41 -0800)
committerVedant Kumar <vsk@apple.com>
Fri, 6 Nov 2020 00:56:37 +0000 (16:56 -0800)
AFAICT, ~TargetList simply implements the default destructor, plus some
locking.

The history is murky, so I'm not sure why we do this locking. Perhaps,
at some point, it was possible to delete the same TargetList instance
from two different threads, setting up a race. If that were true, then
the locking would protect against the race.

Since TargetList is uniquely owned by Debugger (m_target_list), no such
race is possible today.

Testing: check-lldb

Differential Revision: https://reviews.llvm.org/D90895

lldb/include/lldb/Target/TargetList.h
lldb/source/Target/TargetList.cpp

index ff7fbd2..94b25f6 100644 (file)
@@ -42,8 +42,6 @@ public:
     return GetStaticBroadcasterClass();
   }
 
-  ~TargetList() override;
-
   /// Create a new Target.
   ///
   /// Clients must use this function to create a Target. This allows
index ce9661c..2be32c5 100644 (file)
@@ -42,12 +42,6 @@ TargetList::TargetList(Debugger &debugger)
   CheckInWithManager();
 }
 
-// Destructor
-TargetList::~TargetList() {
-  std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
-  m_target_list.clear();
-}
-
 Status TargetList::CreateTarget(Debugger &debugger,
                                 llvm::StringRef user_exe_path,
                                 llvm::StringRef triple_str,