summaryrefslogtreecommitdiffstats
path: root/libcxx/src/debug.cpp
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2011-09-16 19:52:23 +0000
committerHoward Hinnant <hhinnant@apple.com>2011-09-16 19:52:23 +0000
commitc36bfc499b57d826c5c08fef3d8c823a136b2492 (patch)
tree4e43bbc3e06f8bca891cf063074c793e60974a65 /libcxx/src/debug.cpp
parentefd182d9929cbe369a814a5bcd0d4f4b4ae64fc3 (diff)
downloadbcm5719-llvm-c36bfc499b57d826c5c08fef3d8c823a136b2492.tar.gz
bcm5719-llvm-c36bfc499b57d826c5c08fef3d8c823a136b2492.zip
Doug Gregor pointed out some problems with debug mode enabled in one TU and not another. This patch helps detect those situations and offers improved error messages to help get debug mode enabled in more TU's when it is absolutely necessary to do so. Thanks Doug.
llvm-svn: 139933
Diffstat (limited to 'libcxx/src/debug.cpp')
-rw-r--r--libcxx/src/debug.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp
index 04d506341aa..2d2d6432df1 100644
--- a/libcxx/src/debug.cpp
+++ b/libcxx/src/debug.cpp
@@ -110,7 +110,9 @@ __libcpp_db::__find_c_from_i(void* __i) const
{
RLock _(mut());
__i_node* i = __find_iterator(__i);
- return i != nullptr ? (i->__c_ != nullptr ? i->__c_->__c_ : nullptr) : nullptr;
+ _LIBCPP_ASSERT(i != nullptr, "iterator constructed in translation unit with debug mode not enabled."
+ " #define _LIBCPP_DEBUG2 1 for that translation unit.");
+ return i->__c_ != nullptr ? i->__c_->__c_ : nullptr;
}
void
@@ -118,14 +120,20 @@ __libcpp_db::__insert_ic(void* __i, const void* __c)
{
WLock _(mut());
__i_node* i = __insert_iterator(__i);
- _LIBCPP_ASSERT(__cbeg_ != __cend_, "debug mode internal logic error __insert_ic A");
+ _LIBCPP_ASSERT(__cbeg_ != __cend_, "Container constructed in a translation unit with debug mode disabled."
+ " But it is being used in a translation unit with debug mode enabled."
+ " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1");
size_t hc = hash<const void*>()(__c) % (__cend_ - __cbeg_);
__c_node* c = __cbeg_[hc];
- _LIBCPP_ASSERT(c != nullptr, "debug mode internal logic error __insert_ic B");
+ _LIBCPP_ASSERT(c != nullptr, "Container constructed in a translation unit with debug mode disabled."
+ " But it is being used in a translation unit with debug mode enabled."
+ " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1");
while (c->__c_ != __c)
{
c = c->__next_;
- _LIBCPP_ASSERT(c != nullptr, "debug mode internal logic error __insert_ic C");
+ _LIBCPP_ASSERT(c != nullptr, "Container constructed in a translation unit with debug mode disabled."
+ " But it is being used in a translation unit with debug mode enabled."
+ " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1");
}
c->__add(i);
i->__c_ = c;
@@ -365,6 +373,13 @@ __libcpp_db::swap(void* c1, void* c2)
(*p)->__c_ = p2;
}
+void
+__libcpp_db::__insert_i(void* __i)
+{
+ WLock _(mut());
+ __insert_iterator(__i);
+}
+
// private api
_LIBCPP_HIDDEN
OpenPOWER on IntegriCloud