diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/assign.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/assign.pass.cpp index 80afe1e46aad..8b31a8f97498 100644 --- a/libcxx/test/std/localization/locales/locale/locale.cons/assign.pass.cpp +++ b/libcxx/test/std/localization/locales/locale/locale.cons/assign.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // REQUIRES: locale.ru_RU.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // @@ -18,21 +17,10 @@ #include #include +#include "count_new.hpp" + #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} void check(const std::locale& loc) { @@ -79,5 +67,5 @@ int main() check(loc); check(loc2); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp index b808a7650c47..c7021df8f577 100644 --- a/libcxx/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp +++ b/libcxx/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp @@ -10,7 +10,6 @@ // XFAIL: libcpp-no-exceptions // REQUIRES: locale.ru_RU.UTF-8 // REQUIRES: locale.zh_CN.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // @@ -20,21 +19,9 @@ #include #include +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} void check(const std::locale& loc) { @@ -101,5 +88,5 @@ int main() } std::locale ok(""); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/copy.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/copy.pass.cpp index 0760cc46cdd8..9e446e440851 100644 --- a/libcxx/test/std/localization/locales/locale/locale.cons/copy.pass.cpp +++ b/libcxx/test/std/localization/locales/locale/locale.cons/copy.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // REQUIRES: locale.fr_FR.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // @@ -18,22 +17,9 @@ #include #include +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - void check(const std::locale& loc) { assert(std::has_facet >(loc)); @@ -78,5 +64,5 @@ int main() check(loc); check(loc2); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp index 2a9e20fcf98d..eb381f9a580d 100644 --- a/libcxx/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp +++ b/libcxx/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp @@ -9,7 +9,6 @@ // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.ru_RU.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // @@ -19,22 +18,9 @@ #include #include +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - void check(const std::locale& loc) { assert(std::has_facet >(loc)); @@ -78,5 +64,5 @@ int main() std::locale loc2(loc, LOCALE_en_US_UTF_8, std::locale::monetary); check(loc2); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp index fb6e39e5742f..1144931e3d2c 100644 --- a/libcxx/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp +++ b/libcxx/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // REQUIRES: locale.ru_RU.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // @@ -18,21 +17,9 @@ #include #include +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} void check(const std::locale& loc) { @@ -80,7 +67,6 @@ struct my_facet std::locale::id my_facet::id; int main() -{ { { std::locale loc(LOCALE_ru_RU_UTF_8); @@ -91,9 +77,7 @@ int main() const my_facet& f = std::use_facet(loc2); assert(f.test() == 5); } - assert(new_called == 0); -} -{ + assert(globalMemCounter.checkOutstandingNewEq(0)); { std::locale loc; check(loc); @@ -101,6 +85,5 @@ int main() check(loc2); assert(loc == loc2); } - assert(new_called == 0); -} + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp index fa87eb20e9af..f1afff66580e 100644 --- a/libcxx/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp +++ b/libcxx/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp @@ -9,7 +9,6 @@ // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.ru_RU.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // @@ -19,22 +18,9 @@ #include #include +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - void check(const std::locale& loc) { assert(std::has_facet >(loc)); @@ -78,5 +64,5 @@ int main() std::locale loc2(loc, std::locale(LOCALE_en_US_UTF_8), std::locale::monetary); check(loc2); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp index 4454e1eabd37..eb63cd03b663 100644 --- a/libcxx/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp +++ b/libcxx/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp @@ -9,7 +9,6 @@ // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.ru_RU.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // @@ -19,21 +18,9 @@ #include #include +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} void check(const std::locale& loc) { @@ -78,5 +65,5 @@ int main() std::locale loc2(loc, std::string(LOCALE_en_US_UTF_8), std::locale::monetary); check(loc2); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/string.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/string.pass.cpp index c9f944196e73..6fc0808b2728 100644 --- a/libcxx/test/std/localization/locales/locale/locale.cons/string.pass.cpp +++ b/libcxx/test/std/localization/locales/locale/locale.cons/string.pass.cpp @@ -9,7 +9,6 @@ // REQUIRES: locale.ru_RU.UTF-8 // REQUIRES: locale.zh_CN.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // @@ -19,22 +18,9 @@ #include #include +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - void check(const std::locale& loc) { assert(std::has_facet >(loc)); @@ -83,5 +69,5 @@ int main() assert(!(loc == loc3)); assert(loc != loc3); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); }