mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 01:18:52 +08:00
Remove exception throwing debug mode handler support.
Summary: The reason libc++ implemented a throwing debug mode handler was for ease of testing. Specifically, I thought that if a debug violation aborted, we could only test one violation per file. This made it impossible to test debug mode. Which throwing behavior we could test more! However, the throwing approach didn't work either, since there are debug violations underneath noexcept functions. This lead to the introduction of `_NOEXCEPT_DEBUG`, which was only noexcept when debug mode was off. Having thought more and having grown wiser, `_NOEXCEPT_DEBUG` was a horrible decision. It was viral, it didn't cover all the cases it needed to, and it was observable to the user -- at worst changing the behavior of their program. This patch removes the throwing debug handler, and rewrites the debug tests using 'fork-ing' style death tests. Reviewers: mclow.lists, ldionne, thomasanderson Reviewed By: ldionne Subscribers: christof, arphaman, libcxx-commits, #libc Differential Revision: https://reviews.llvm.org/D59166 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356417 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -7,9 +7,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
|
||||
// UNSUPPORTED: libcpp-no-if-constexpr
|
||||
// MODULES_DEFINES: _LIBCPP_DEBUG=1
|
||||
// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
|
||||
|
||||
// Can't test the system lib because this test enables debug mode
|
||||
// UNSUPPORTED: with_system_cxx_lib
|
||||
@@ -17,11 +16,11 @@
|
||||
// test container debugging
|
||||
|
||||
#define _LIBCPP_DEBUG 1
|
||||
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "container_debug_tests.hpp"
|
||||
#include "debug_mode_helper.h"
|
||||
|
||||
using namespace IteratorDebugChecks;
|
||||
@@ -43,14 +42,11 @@ public:
|
||||
static void run() {
|
||||
Base::run_iterator_tests();
|
||||
Base::run_allocator_aware_tests();
|
||||
try {
|
||||
for (int N : {3, 128}) {
|
||||
FrontOnEmptyContainer(N);
|
||||
BackOnEmptyContainer(N);
|
||||
PopBack(N);
|
||||
}
|
||||
} catch (...) {
|
||||
assert(false && "uncaught debug exception");
|
||||
|
||||
for (int N : {3, 128}) {
|
||||
FrontOnEmptyContainer(N);
|
||||
BackOnEmptyContainer(N);
|
||||
PopBack(N);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,10 +59,10 @@ private:
|
||||
(void)C.back();
|
||||
(void)CC.back();
|
||||
C.pop_back();
|
||||
CHECK_DEBUG_THROWS( C.erase(it) );
|
||||
EXPECT_DEATH( C.erase(it) );
|
||||
C.clear();
|
||||
CHECK_DEBUG_THROWS( C.back() );
|
||||
CHECK_DEBUG_THROWS( CC.back() );
|
||||
EXPECT_DEATH( C.back() );
|
||||
EXPECT_DEATH( CC.back() );
|
||||
}
|
||||
|
||||
static void FrontOnEmptyContainer(int N) {
|
||||
@@ -76,8 +72,8 @@ private:
|
||||
(void)C.front();
|
||||
(void)CC.front();
|
||||
C.clear();
|
||||
CHECK_DEBUG_THROWS( C.front() );
|
||||
CHECK_DEBUG_THROWS( CC.front() );
|
||||
EXPECT_DEATH( C.front() );
|
||||
EXPECT_DEATH( CC.front() );
|
||||
}
|
||||
|
||||
static void PopBack(int N) {
|
||||
@@ -86,10 +82,10 @@ private:
|
||||
iterator it1 = C1.end();
|
||||
--it1;
|
||||
C1.pop_back();
|
||||
CHECK_DEBUG_THROWS( C1.erase(it1) );
|
||||
EXPECT_DEATH( C1.erase(it1) );
|
||||
C1.erase(C1.begin(), C1.end());
|
||||
assert(C1.size() == 0);
|
||||
CHECK_DEBUG_THROWS( C1.pop_back() );
|
||||
EXPECT_DEATH_MATCHES(DebugInfoMatcher("string::pop_back(): string is already empty"), C1.pop_back() );
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user