NULL out the "ptr_" member of shared pointers for debug and release

builds (not build and integration builds) to help catch when a shared pointer
that might be in a collection class is used after the collection
has been freed.

llvm-svn: 149136
This commit is contained in:
Greg Clayton 2012-01-27 18:33:53 +00:00
parent ecc6116950
commit a896f574e0
1 changed files with 9 additions and 0 deletions

View File

@ -684,6 +684,15 @@ public:
~IntrusiveSharingPtr()
{
release_shared();
#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
// NULL out the pointer in objects which can help with leaks detection.
// We don't enable this for LLDB_CONFIGURATION_BUILD_AND_INTEGRATION or
// when none of the LLDB_CONFIGURATION_XXX macros are defined since
// those would be builds for release. But for debug and release builds
// that are for development, we NULL out the pointers to catch potential
// issues.
ptr_ = NULL;
#endif // #if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
}
T&