[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 {
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 SymbolStringPtr &LHS, const SymbolStringPtr &RHS) {
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;