[llvm] r329019 - [ORC] Add a debugging check to catch dangling references to SymbolStringPools.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 2 14:39:39 PDT 2018


Author: lhames
Date: Mon Apr  2 14:39:39 2018
New Revision: 329019

URL: http://llvm.org/viewvc/llvm-project?rev=329019&view=rev
Log:
[ORC] Add a debugging check to catch dangling references to SymbolStringPools.

Modified:
    llvm/trunk/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h

Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h?rev=329019&r1=329018&r2=329019&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h Mon Apr  2 14:39:39 2018
@@ -27,6 +27,9 @@ class SymbolStringPtr;
 class SymbolStringPool {
   friend class SymbolStringPtr;
 public:
+  /// @brief Destroy a SymbolStringPool.
+  ~SymbolStringPool();
+
   /// @brief Create a symbol string pointer from the given string.
   SymbolStringPtr intern(StringRef S);
 
@@ -109,6 +112,13 @@ inline bool operator<(const SymbolString
   return LHS.S < RHS.S;
 }
 
+inline SymbolStringPool::~SymbolStringPool() {
+#ifndef NDEBUG
+  clearDeadEntries();
+  assert(Pool.empty() && "Dangling references at pool destruction time");
+#endif // NDEBUG
+}
+
 inline SymbolStringPtr SymbolStringPool::intern(StringRef S) {
   std::lock_guard<std::mutex> Lock(PoolMutex);
   PoolMap::iterator I;




More information about the llvm-commits mailing list