Skip to content

Commit bb09ef9

Browse files
committed
[libc++] Fix failures when running the test suite without RTTI
1 parent 8e4bb9e commit bb09ef9

File tree

47 files changed

+283
-326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+283
-326
lines changed

libcxx/include/any

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ namespace __any_imp
156156
template <class _Tp>
157157
inline _LIBCPP_INLINE_VISIBILITY
158158
constexpr const void* __get_fallback_typeid() {
159-
return &__unique_typeinfo<decay_t<_Tp>>::__id;
159+
return &__unique_typeinfo<remove_cv_t<remove_reference_t<_Tp>>>::__id;
160160
}
161161

162162
template <class _Tp>

libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ int main(int, char**)
5151
std::function<int(int)> f1 = g;
5252
std::function<int(int)> f2 = ^(int x) { return x + 1; };
5353
assert(globalMemCounter.checkOutstandingNewEq(0));
54-
assert(*f1.target<int(*)(int)>() == g);
55-
assert(*f2.target<int(^)(int)>() != 0);
54+
RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
55+
RTTI_ASSERT(*f2.target<int(^)(int)>() != 0);
5656
swap(f1, f2);
5757
assert(globalMemCounter.checkOutstandingNewEq(0));
58-
assert(*f1.target<int(^)(int)>() != 0);
59-
assert(*f2.target<int(*)(int)>() == g);
58+
RTTI_ASSERT(*f1.target<int(^)(int)>() != 0);
59+
RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
6060
}
6161

6262
// operator bool
@@ -107,13 +107,13 @@ int main(int, char**)
107107
std::function<int(int)> f2 = ^(int x) { return x + 1; };
108108
assert(A::count == 1);
109109
assert(globalMemCounter.checkOutstandingNewEq(1));
110-
assert(f1.target<A>()->id() == 999);
111-
assert((*f2.target<int(^)(int)>())(13) == 14);
110+
RTTI_ASSERT(f1.target<A>()->id() == 999);
111+
RTTI_ASSERT((*f2.target<int(^)(int)>())(13) == 14);
112112
f1.swap(f2);
113113
assert(A::count == 1);
114114
assert(globalMemCounter.checkOutstandingNewEq(1));
115-
assert((*f1.target<int(^)(int)>())(13) == 14);
116-
assert(f2.target<A>()->id() == 999);
115+
RTTI_ASSERT((*f1.target<int(^)(int)>())(13) == 14);
116+
RTTI_ASSERT(f2.target<A>()->id() == 999);
117117
}
118118
assert(globalMemCounter.checkOutstandingNewEq(0));
119119
assert(A::count == 0);
@@ -132,15 +132,15 @@ int main(int, char**)
132132
{
133133
int (^block)(int) = Block_copy(^(int x) { return x + 1; });
134134
std::function<int(int)> f = block;
135-
assert(*f.target<int(^)(int)>() == block);
136-
assert(f.target<int(*)(int)>() == 0);
135+
RTTI_ASSERT(*f.target<int(^)(int)>() == block);
136+
RTTI_ASSERT(f.target<int(*)(int)>() == 0);
137137
Block_release(block);
138138
}
139139

140140
// target_type
141141
{
142142
std::function<int(int)> f = ^(int x) { return x + 1; };
143-
assert(f.target_type() == typeid(int(^)(int)));
143+
RTTI_ASSERT(f.target_type() == typeid(int(^)(int)));
144144
}
145145

146146
return 0;

libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ bool A::cancel = false;
3939
int main(int, char**)
4040
{
4141
A::global = A();
42-
assert(A::global.target<A>());
42+
RTTI_ASSERT(A::global.target<A>());
4343

4444
// Check that we don't recurse in A::~A().
4545
A::cancel = true;
4646
A::global = std::function<void()>(nullptr);
47-
assert(!A::global.target<A>());
47+
RTTI_ASSERT(!A::global.target<A>());
4848

4949
return 0;
5050
}

libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ bool A::cancel = false;
3939
int main(int, char**)
4040
{
4141
A::global = A();
42-
assert(A::global.target<A>());
42+
RTTI_ASSERT(A::global.target<A>());
4343

4444
// Check that we don't recurse in A::~A().
4545
A::cancel = true;
4646
A::global = nullptr;
47-
assert(!A::global.target<A>());
47+
RTTI_ASSERT(!A::global.target<A>());
4848

4949
return 0;
5050
}

libcxx/test/std/language.support/support.rtti/type.info/type_info.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
// test type_info
1010

11+
// UNSUPPORTED: -fno-rtti
12+
1113
#include <typeinfo>
1214
#include <string>
1315
#include <cstring>

libcxx/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
// test type_info
1010

11+
// UNSUPPORTED: -fno-rtti
12+
1113
#include <typeinfo>
1214
#include <cstring>
1315
#include <cassert>

libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_pointer.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ void test_cast_non_copyable_type()
156156
void test_cast_array() {
157157
int arr[3];
158158
std::any a(arr);
159-
assert(a.type() == typeid(int*)); // contained value is decayed
160-
// We can't get an array out
159+
RTTI_ASSERT(a.type() == typeid(int*)); // contained value is decayed
160+
// We can't get an array out
161161
int (*p)[3] = std::any_cast<int[3]>(&a);
162162
assert(p == nullptr);
163163
}

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ int main(int, char**)
7171
#endif
7272
assert(A::count == 2);
7373
assert(globalMemCounter.checkOutstandingNewEq(2));
74-
assert(f1.target<A>()->id() == 1);
75-
assert(f2.target<A>()->id() == 2);
74+
RTTI_ASSERT(f1.target<A>()->id() == 1);
75+
RTTI_ASSERT(f2.target<A>()->id() == 2);
7676
swap(f1, f2);
7777
assert(A::count == 2);
7878
assert(globalMemCounter.checkOutstandingNewEq(2));
79-
assert(f1.target<A>()->id() == 2);
80-
assert(f2.target<A>()->id() == 1);
79+
RTTI_ASSERT(f1.target<A>()->id() == 2);
80+
RTTI_ASSERT(f2.target<A>()->id() == 1);
8181
}
8282
assert(A::count == 0);
8383
assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -89,13 +89,13 @@ int main(int, char**)
8989
#endif
9090
assert(A::count == 1);
9191
assert(globalMemCounter.checkOutstandingNewEq(1));
92-
assert(f1.target<A>()->id() == 1);
93-
assert(*f2.target<int(*)(int)>() == g);
92+
RTTI_ASSERT(f1.target<A>()->id() == 1);
93+
RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
9494
swap(f1, f2);
9595
assert(A::count == 1);
9696
assert(globalMemCounter.checkOutstandingNewEq(1));
97-
assert(*f1.target<int(*)(int)>() == g);
98-
assert(f2.target<A>()->id() == 1);
97+
RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
98+
RTTI_ASSERT(f2.target<A>()->id() == 1);
9999
}
100100
assert(A::count == 0);
101101
assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -107,13 +107,13 @@ int main(int, char**)
107107
#endif
108108
assert(A::count == 1);
109109
assert(globalMemCounter.checkOutstandingNewEq(1));
110-
assert(*f1.target<int(*)(int)>() == g);
111-
assert(f2.target<A>()->id() == 1);
110+
RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
111+
RTTI_ASSERT(f2.target<A>()->id() == 1);
112112
swap(f1, f2);
113113
assert(A::count == 1);
114114
assert(globalMemCounter.checkOutstandingNewEq(1));
115-
assert(f1.target<A>()->id() == 1);
116-
assert(*f2.target<int(*)(int)>() == g);
115+
RTTI_ASSERT(f1.target<A>()->id() == 1);
116+
RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
117117
}
118118
assert(A::count == 0);
119119
assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -125,13 +125,13 @@ int main(int, char**)
125125
#endif
126126
assert(A::count == 0);
127127
assert(globalMemCounter.checkOutstandingNewEq(0));
128-
assert(*f1.target<int(*)(int)>() == g);
129-
assert(*f2.target<int(*)(int)>() == h);
128+
RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
129+
RTTI_ASSERT(*f2.target<int(*)(int)>() == h);
130130
swap(f1, f2);
131131
assert(A::count == 0);
132132
assert(globalMemCounter.checkOutstandingNewEq(0));
133-
assert(*f1.target<int(*)(int)>() == h);
134-
assert(*f2.target<int(*)(int)>() == g);
133+
RTTI_ASSERT(*f1.target<int(*)(int)>() == h);
134+
RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
135135
}
136136
assert(A::count == 0);
137137
assert(globalMemCounter.checkOutstandingNewEq(0));

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,35 +71,35 @@ int main(int, char**)
7171
std::function<int(int)> f = A();
7272
assert(A::count == 1);
7373
assert(globalMemCounter.checkOutstandingNewEq(1));
74-
assert(f.target<A>());
75-
assert(f.target<int(*)(int)>() == 0);
74+
RTTI_ASSERT(f.target<A>());
75+
RTTI_ASSERT(f.target<int(*)(int)>() == 0);
7676
}
7777
assert(A::count == 0);
7878
assert(globalMemCounter.checkOutstandingNewEq(0));
7979
{
8080
std::function<int(int)> f = g;
8181
assert(globalMemCounter.checkOutstandingNewEq(0));
82-
assert(f.target<int(*)(int)>());
83-
assert(f.target<A>() == 0);
82+
RTTI_ASSERT(f.target<int(*)(int)>());
83+
RTTI_ASSERT(f.target<A>() == 0);
8484
}
8585
assert(globalMemCounter.checkOutstandingNewEq(0));
8686
{
8787
std::function<int(int)> f = (int (*)(int))0;
8888
assert(!f);
8989
assert(globalMemCounter.checkOutstandingNewEq(0));
90-
assert(f.target<int(*)(int)>() == 0);
91-
assert(f.target<A>() == 0);
90+
RTTI_ASSERT(f.target<int(*)(int)>() == 0);
91+
RTTI_ASSERT(f.target<A>() == 0);
9292
}
9393
{
9494
std::function<int(const A*, int)> f = &A::foo;
9595
assert(f);
9696
assert(globalMemCounter.checkOutstandingNewEq(0));
97-
assert(f.target<int (A::*)(int) const>() != 0);
97+
RTTI_ASSERT(f.target<int (A::*)(int) const>() != 0);
9898
}
9999
{
100100
std::function<void(int)> f(&g);
101101
assert(f);
102-
assert(f.target<int(*)(int)>() != 0);
102+
RTTI_ASSERT(f.target<int(*)(int)>() != 0);
103103
f(1);
104104
}
105105
{

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,39 +75,39 @@ int main(int, char**)
7575
f = A();
7676
assert(A::count == 1);
7777
assert(globalMemCounter.checkOutstandingNewEq(1));
78-
assert(f.target<A>());
79-
assert(f.target<int(*)(int)>() == 0);
78+
RTTI_ASSERT(f.target<A>());
79+
RTTI_ASSERT(f.target<int(*)(int)>() == 0);
8080
}
8181
assert(A::count == 0);
8282
assert(globalMemCounter.checkOutstandingNewEq(0));
8383
{
8484
std::function<int(int)> f;
8585
f = g;
8686
assert(globalMemCounter.checkOutstandingNewEq(0));
87-
assert(f.target<int(*)(int)>());
88-
assert(f.target<A>() == 0);
87+
RTTI_ASSERT(f.target<int(*)(int)>());
88+
RTTI_ASSERT(f.target<A>() == 0);
8989
}
9090
assert(globalMemCounter.checkOutstandingNewEq(0));
9191
{
9292
std::function<int(int)> f;
9393
f = (int (*)(int))0;
9494
assert(!f);
9595
assert(globalMemCounter.checkOutstandingNewEq(0));
96-
assert(f.target<int(*)(int)>() == 0);
97-
assert(f.target<A>() == 0);
96+
RTTI_ASSERT(f.target<int(*)(int)>() == 0);
97+
RTTI_ASSERT(f.target<A>() == 0);
9898
}
9999
{
100100
std::function<int(const A*, int)> f;
101101
f = &A::foo;
102102
assert(f);
103103
assert(globalMemCounter.checkOutstandingNewEq(0));
104-
assert(f.target<int (A::*)(int) const>() != 0);
104+
RTTI_ASSERT(f.target<int (A::*)(int) const>() != 0);
105105
}
106106
{
107107
std::function<void(int)> f;
108108
f = &g;
109109
assert(f);
110-
assert(f.target<int(*)(int)>() != 0);
110+
RTTI_ASSERT(f.target<int(*)(int)>() != 0);
111111
f(1);
112112
}
113113
#if TEST_STD_VER >= 11

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,14 @@ void test_imp() {
167167
{ // Check that the null value is detected
168168
TestFn tf = nullptr;
169169
std::function<Fn> f = tf;
170-
assert(f.template target<TestFn>() == nullptr);
170+
RTTI_ASSERT(f.template target<TestFn>() == nullptr);
171171
}
172172
{ // Check that the non-null value is detected.
173173
TestFn tf = Creator<TestFn>::create();
174174
assert(tf != nullptr);
175175
std::function<Fn> f = tf;
176-
assert(f.template target<TestFn>() != nullptr);
177-
assert(*f.template target<TestFn>() == tf);
176+
RTTI_ASSERT(f.template target<TestFn>() != nullptr);
177+
RTTI_ASSERT(*f.template target<TestFn>() == tf);
178178
}
179179
}
180180

libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ void test_FunctionObject(AllocType& alloc)
3636
std::function<FuncType> f = FunctionObject();
3737
assert(FunctionObject::count == 1);
3838
assert(globalMemCounter.checkOutstandingNewEq(1));
39-
assert(f.template target<FunctionObject>());
40-
assert(f.template target<FuncType>() == 0);
41-
assert(f.template target<FuncType*>() == 0);
39+
RTTI_ASSERT(f.template target<FunctionObject>());
40+
RTTI_ASSERT(f.template target<FuncType>() == 0);
41+
RTTI_ASSERT(f.template target<FuncType*>() == 0);
4242
// Copy function with allocator
4343
std::function<FuncType> f2(std::allocator_arg, alloc, f);
4444
assert(FunctionObject::count == 2);
4545
assert(globalMemCounter.checkOutstandingNewEq(2));
46-
assert(f2.template target<FunctionObject>());
47-
assert(f2.template target<FuncType>() == 0);
48-
assert(f2.template target<FuncType*>() == 0);
46+
RTTI_ASSERT(f2.template target<FunctionObject>());
47+
RTTI_ASSERT(f2.template target<FuncType>() == 0);
48+
RTTI_ASSERT(f2.template target<FuncType*>() == 0);
4949
}
5050
assert(FunctionObject::count == 0);
5151
assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -60,15 +60,15 @@ void test_FreeFunction(AllocType& alloc)
6060
FuncType* target = &FreeFunction;
6161
std::function<FuncType> f = target;
6262
assert(globalMemCounter.checkOutstandingNewEq(0));
63-
assert(f.template target<FuncType*>());
64-
assert(*f.template target<FuncType*>() == target);
65-
assert(f.template target<FuncType>() == 0);
63+
RTTI_ASSERT(f.template target<FuncType*>());
64+
RTTI_ASSERT(*f.template target<FuncType*>() == target);
65+
RTTI_ASSERT(f.template target<FuncType>() == 0);
6666
// Copy function with allocator
6767
std::function<FuncType> f2(std::allocator_arg, alloc, f);
6868
assert(globalMemCounter.checkOutstandingNewEq(0));
69-
assert(f2.template target<FuncType*>());
70-
assert(*f2.template target<FuncType*>() == target);
71-
assert(f2.template target<FuncType>() == 0);
69+
RTTI_ASSERT(f2.template target<FuncType*>());
70+
RTTI_ASSERT(*f2.template target<FuncType*>() == target);
71+
RTTI_ASSERT(f2.template target<FuncType>() == 0);
7272
}
7373
assert(globalMemCounter.checkOutstandingNewEq(0));
7474
}
@@ -82,15 +82,15 @@ void test_MemFunClass(AllocType& alloc)
8282
TargetType target = &MemFunClass::foo;
8383
std::function<FuncType> f = target;
8484
assert(globalMemCounter.checkOutstandingNewEq(0));
85-
assert(f.template target<TargetType>());
86-
assert(*f.template target<TargetType>() == target);
87-
assert(f.template target<FuncType*>() == 0);
85+
RTTI_ASSERT(f.template target<TargetType>());
86+
RTTI_ASSERT(*f.template target<TargetType>() == target);
87+
RTTI_ASSERT(f.template target<FuncType*>() == 0);
8888
// Copy function with allocator
8989
std::function<FuncType> f2(std::allocator_arg, alloc, f);
9090
assert(globalMemCounter.checkOutstandingNewEq(0));
91-
assert(f2.template target<TargetType>());
92-
assert(*f2.template target<TargetType>() == target);
93-
assert(f2.template target<FuncType*>() == 0);
91+
RTTI_ASSERT(f2.template target<TargetType>());
92+
RTTI_ASSERT(*f2.template target<TargetType>() == target);
93+
RTTI_ASSERT(f2.template target<FuncType*>() == 0);
9494
}
9595
assert(globalMemCounter.checkOutstandingNewEq(0));
9696
}

0 commit comments

Comments
 (0)