forked from OSchip/llvm-project
[ORC] Check for underflow on SymbolStringPtr ref-counts.
This commit is contained in:
parent
20634ece15
commit
4272fca2db
|
@ -62,8 +62,10 @@ public:
|
|||
}
|
||||
|
||||
SymbolStringPtr& operator=(const SymbolStringPtr &Other) {
|
||||
if (isRealPoolEntry(S))
|
||||
if (isRealPoolEntry(S)) {
|
||||
assert(S->getValue() && "Releasing SymbolStringPtr with zero ref count");
|
||||
--S->getValue();
|
||||
}
|
||||
S = Other.S;
|
||||
if (isRealPoolEntry(S))
|
||||
++S->getValue();
|
||||
|
@ -75,16 +77,20 @@ public:
|
|||
}
|
||||
|
||||
SymbolStringPtr& operator=(SymbolStringPtr &&Other) {
|
||||
if (isRealPoolEntry(S))
|
||||
if (isRealPoolEntry(S)) {
|
||||
assert(S->getValue() && "Releasing SymbolStringPtr with zero ref count");
|
||||
--S->getValue();
|
||||
}
|
||||
S = nullptr;
|
||||
std::swap(S, Other.S);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~SymbolStringPtr() {
|
||||
if (isRealPoolEntry(S))
|
||||
if (isRealPoolEntry(S)) {
|
||||
assert(S->getValue() && "Releasing SymbolStringPtr with zero ref count");
|
||||
--S->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
explicit operator bool() const { return S; }
|
||||
|
|
Loading…
Reference in New Issue