Sanity checking for statement reference counts. Thanks for the suggestion, Fariborz
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79995 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index b867177..53f0186 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -174,6 +174,7 @@
/// \brief Destroy the current statement and its children.
void Destroy(ASTContext &Ctx) {
+ assert(RefCount >= 0);
if (--RefCount == 0)
DoDestroy(Ctx);
}
@@ -183,6 +184,7 @@
/// Invoke the Retain() operation when this statement or expression
/// is being shared by another owner.
Stmt *Retain() {
+ assert(RefCount >= 1);
++RefCount;
return this;
}