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

llvm-svn: 329019
This commit is contained in:
Lang Hames 2018-04-02 21:39:39 +00:00
parent e8f12eb952
commit a82c25a434
1 changed files with 10 additions and 0 deletions

View File

@ -27,6 +27,9 @@ class SymbolStringPtr;
class SymbolStringPool { class SymbolStringPool {
friend class SymbolStringPtr; friend class SymbolStringPtr;
public: public:
/// @brief Destroy a SymbolStringPool.
~SymbolStringPool();
/// @brief Create a symbol string pointer from the given string. /// @brief Create a symbol string pointer from the given string.
SymbolStringPtr intern(StringRef S); SymbolStringPtr intern(StringRef S);
@ -109,6 +112,13 @@ inline bool operator<(const SymbolStringPtr &LHS, const SymbolStringPtr &RHS) {
return LHS.S < RHS.S; 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) { inline SymbolStringPtr SymbolStringPool::intern(StringRef S) {
std::lock_guard<std::mutex> Lock(PoolMutex); std::lock_guard<std::mutex> Lock(PoolMutex);
PoolMap::iterator I; PoolMap::iterator I;