mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 03:32:35 +08:00
Replace test_throw.h header with a single test macro
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283030 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_iterators.h"
|
#include "test_iterators.h"
|
||||||
#include "test_throw.h"
|
|
||||||
|
|
||||||
struct Counted {
|
struct Counted {
|
||||||
static int count;
|
static int count;
|
||||||
@@ -43,7 +42,7 @@ struct ThrowsCounted {
|
|||||||
explicit ThrowsCounted() {
|
explicit ThrowsCounted() {
|
||||||
++constructed;
|
++constructed;
|
||||||
if (throw_after > 0 && --throw_after == 0) {
|
if (throw_after > 0 && --throw_after == 0) {
|
||||||
test_throw<int>();
|
TEST_THROW(1);
|
||||||
}
|
}
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_iterators.h"
|
#include "test_iterators.h"
|
||||||
#include "test_throw.h"
|
|
||||||
|
|
||||||
struct Counted {
|
struct Counted {
|
||||||
static int count;
|
static int count;
|
||||||
@@ -43,7 +42,7 @@ struct ThrowsCounted {
|
|||||||
explicit ThrowsCounted() {
|
explicit ThrowsCounted() {
|
||||||
++constructed;
|
++constructed;
|
||||||
if (throw_after > 0 && --throw_after == 0) {
|
if (throw_after > 0 && --throw_after == 0) {
|
||||||
test_throw<int>();
|
TEST_THROW(1);
|
||||||
}
|
}
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_iterators.h"
|
#include "test_iterators.h"
|
||||||
#include "test_throw.h"
|
|
||||||
|
|
||||||
struct Counted {
|
struct Counted {
|
||||||
static int count;
|
static int count;
|
||||||
@@ -43,7 +42,7 @@ struct ThrowsCounted {
|
|||||||
explicit ThrowsCounted() {
|
explicit ThrowsCounted() {
|
||||||
++constructed;
|
++constructed;
|
||||||
if (throw_after > 0 && --throw_after == 0) {
|
if (throw_after > 0 && --throw_after == 0) {
|
||||||
test_throw<int>();
|
TEST_THROW(1);
|
||||||
}
|
}
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_iterators.h"
|
#include "test_iterators.h"
|
||||||
#include "test_throw.h"
|
|
||||||
|
|
||||||
struct Counted {
|
struct Counted {
|
||||||
static int count;
|
static int count;
|
||||||
@@ -42,7 +41,7 @@ struct ThrowsCounted {
|
|||||||
explicit ThrowsCounted() {
|
explicit ThrowsCounted() {
|
||||||
++constructed;
|
++constructed;
|
||||||
if (throw_after > 0 && --throw_after == 0) {
|
if (throw_after > 0 && --throw_after == 0) {
|
||||||
test_throw<int>();
|
TEST_THROW(1);
|
||||||
}
|
}
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_iterators.h"
|
#include "test_iterators.h"
|
||||||
#include "test_throw.h"
|
|
||||||
|
|
||||||
struct Counted {
|
struct Counted {
|
||||||
static int count;
|
static int count;
|
||||||
@@ -43,7 +42,7 @@ struct ThrowsCounted {
|
|||||||
explicit ThrowsCounted(int&& x) {
|
explicit ThrowsCounted(int&& x) {
|
||||||
++constructed;
|
++constructed;
|
||||||
if (throw_after > 0 && --throw_after == 0) {
|
if (throw_after > 0 && --throw_after == 0) {
|
||||||
test_throw<int>();
|
TEST_THROW(1);
|
||||||
}
|
}
|
||||||
++count;
|
++count;
|
||||||
x = 0;
|
x = 0;
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_iterators.h"
|
#include "test_iterators.h"
|
||||||
#include "test_throw.h"
|
|
||||||
|
|
||||||
struct Counted {
|
struct Counted {
|
||||||
static int count;
|
static int count;
|
||||||
@@ -43,7 +42,7 @@ struct ThrowsCounted {
|
|||||||
explicit ThrowsCounted(int&& x) {
|
explicit ThrowsCounted(int&& x) {
|
||||||
++constructed;
|
++constructed;
|
||||||
if (throw_after > 0 && --throw_after == 0) {
|
if (throw_after > 0 && --throw_after == 0) {
|
||||||
test_throw<int>();
|
TEST_THROW(1);
|
||||||
}
|
}
|
||||||
++count;
|
++count;
|
||||||
x = 0;
|
x = 0;
|
||||||
|
@@ -140,4 +140,15 @@ struct is_same<T, T> { enum {value = 1}; };
|
|||||||
static_assert(test_macros_detail::is_same<__VA_ARGS__>::value, \
|
static_assert(test_macros_detail::is_same<__VA_ARGS__>::value, \
|
||||||
"Types differ uexpectedly")
|
"Types differ uexpectedly")
|
||||||
|
|
||||||
|
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||||
|
#define TEST_THROW(...) throw __VA_ARGS__
|
||||||
|
#else
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define TEST_THROW(...) __builtin_abort()
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define TEST_THROW(...) ::abort()
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // SUPPORT_TEST_MACROS_HPP
|
#endif // SUPPORT_TEST_MACROS_HPP
|
||||||
|
@@ -1,27 +0,0 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
//===---------------------------- test_macros.h ---------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef SUPPORT_TEST_THROW_H
|
|
||||||
#define SUPPORT_TEST_THROW_H
|
|
||||||
|
|
||||||
#include "test_macros.h"
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
template <class Ex>
|
|
||||||
TEST_NORETURN
|
|
||||||
inline void test_throw() {
|
|
||||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
|
||||||
throw Ex();
|
|
||||||
#else
|
|
||||||
std::abort();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // SUPPORT_TEST_THROW_H
|
|
Reference in New Issue
Block a user