 
            Module: ppl/ppl Branch: master Commit: 1fd3370f93b3fbc26ad024a1bedc2d280660ecc3 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=1fd3370f93b3f...
Author: Abramo Bagnara abramo.bagnara@gmail.com Date: Sat Apr 21 11:52:50 2012 +0200
Protect in_assert flag from exceptions.
---
src/assert.hh | 3 +-- src/globals.cc | 4 +--- src/globals.defs.hh | 23 +++++++++++++++++------ src/globals.inlines.hh | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/assert.hh b/src/assert.hh index 7751da2..3c64266 100644 --- a/src/assert.hh +++ b/src/assert.hh @@ -82,9 +82,8 @@ site: http://bugseng.com/products/ppl/ . */ #else #define PPL_ASSERT_HEAVY(cond__) \ do { \ - ++Parma_Polyhedra_Library::Implementation::in_assert; \ + Parma_Polyhedra_Library::In_Assert guard; \ PPL_ASSERT_IMPL_(cond__); \ - --Parma_Polyhedra_Library::Implementation::in_assert; \ } while (false) #endif // !defined(NDEBUG)
diff --git a/src/globals.cc b/src/globals.cc index ea28df1..7e11305 100644 --- a/src/globals.cc +++ b/src/globals.cc @@ -35,11 +35,9 @@ Weightwatch_Traits::Threshold Weightwatch_Traits::weight = 0; void (*Weightwatch_Traits::check_function)(void) = 0;
#ifndef NDEBUG -namespace Implementation {
-unsigned int in_assert = 0; +unsigned int In_Assert::count = 0;
-} // namespace Implementation #endif
diff --git a/src/globals.defs.hh b/src/globals.defs.hh index 339aef3..e91ba78 100644 --- a/src/globals.defs.hh +++ b/src/globals.defs.hh @@ -146,12 +146,23 @@ struct Weightwatch_Traits {
#ifndef NDEBUG -namespace Implementation {
-//! Non zero during evaluation of PPL_ASSERT expression. -extern unsigned int in_assert; +class In_Assert { +private: + //! Non zero during evaluation of PPL_ASSERT expression. + static unsigned int count; +public: + In_Assert() { + ++count; + } + ~In_Assert() { + ++count; + } + static bool asserting() { + return count != 0; + } +};
-} // namespace Implementation #endif
@@ -524,12 +535,12 @@ least_significant_one_mask(dimension_type i); #define WEIGHT_BEGIN() #define WEIGHT_ADD(delta) \ do { \ - if (Implementation::in_assert == 0) \ + if (!In_Assert::asserting()) \ Weightwatch_Traits::weight += delta; \ } while (false) #define WEIGHT_ADD_MUL(delta, factor) \ do { \ - if (Implementation::in_assert == 0) \ + if (!In_Assert::asserting()) \ Weightwatch_Traits::weight += delta * factor; \ } while (false) #endif diff --git a/src/globals.inlines.hh b/src/globals.inlines.hh index ed9dc55..748f6dc 100644 --- a/src/globals.inlines.hh +++ b/src/globals.inlines.hh @@ -76,7 +76,7 @@ Throwable::~Throwable() { inline void maybe_abandon() { #ifndef NDEBUG - if (Implementation::in_assert != 0) + if (In_Assert::asserting()) return; #endif if (Weightwatch_Traits::check_function != 0)