Skip to content

Commit c2536ed

Browse files
committed
[libc++][NFC] Make __type_info_implementations a namespace
1 parent f74e909 commit c2536ed

File tree

1 file changed

+80
-80
lines changed

1 file changed

+80
-80
lines changed

libcxx/include/typeinfo

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -186,99 +186,99 @@ public:
186186
# endif
187187
# endif
188188

189-
struct __type_info_implementations {
190-
struct __string_impl_base {
191-
typedef const char* __type_name_t;
192-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static const char*
193-
__type_name_to_string(__type_name_t __v) _NOEXCEPT {
194-
return __v;
195-
}
196-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static __type_name_t
197-
__string_to_type_name(const char* __v) _NOEXCEPT {
198-
return __v;
199-
}
200-
};
189+
namespace __type_info_implementations {
190+
struct __string_impl_base {
191+
typedef const char* __type_name_t;
192+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static const char*
193+
__type_name_to_string(__type_name_t __v) _NOEXCEPT {
194+
return __v;
195+
}
196+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR static __type_name_t
197+
__string_to_type_name(const char* __v) _NOEXCEPT {
198+
return __v;
199+
}
200+
};
201201

202-
struct __unique_impl : __string_impl_base {
203-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {
204-
return reinterpret_cast<size_t>(__v);
205-
}
206-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
207-
return __lhs == __rhs;
208-
}
209-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
210-
return __lhs < __rhs;
211-
}
212-
};
213-
214-
struct __non_unique_impl : __string_impl_base {
215-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __ptr) _NOEXCEPT {
216-
size_t __hash = 5381;
217-
while (unsigned char __c = static_cast<unsigned char>(*__ptr++))
218-
__hash = (__hash * 33) ^ __c;
219-
return __hash;
220-
}
221-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
222-
return __lhs == __rhs || __builtin_strcmp(__lhs, __rhs) == 0;
223-
}
224-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
225-
return __builtin_strcmp(__lhs, __rhs) < 0;
226-
}
227-
};
202+
struct __unique_impl : __string_impl_base {
203+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {
204+
return reinterpret_cast<size_t>(__v);
205+
}
206+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
207+
return __lhs == __rhs;
208+
}
209+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
210+
return __lhs < __rhs;
211+
}
212+
};
213+
214+
struct __non_unique_impl : __string_impl_base {
215+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __ptr) _NOEXCEPT {
216+
size_t __hash = 5381;
217+
while (unsigned char __c = static_cast<unsigned char>(*__ptr++))
218+
__hash = (__hash * 33) ^ __c;
219+
return __hash;
220+
}
221+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
222+
return __lhs == __rhs || __builtin_strcmp(__lhs, __rhs) == 0;
223+
}
224+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
225+
return __builtin_strcmp(__lhs, __rhs) < 0;
226+
}
227+
};
228228

229-
struct __non_unique_arm_rtti_bit_impl {
230-
typedef uintptr_t __type_name_t;
229+
struct __non_unique_arm_rtti_bit_impl {
230+
typedef uintptr_t __type_name_t;
231231

232-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static const char* __type_name_to_string(__type_name_t __v) _NOEXCEPT {
233-
return reinterpret_cast<const char*>(__v & ~__non_unique_rtti_bit::value);
234-
}
235-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static __type_name_t __string_to_type_name(const char* __v) _NOEXCEPT {
236-
return reinterpret_cast<__type_name_t>(__v);
237-
}
232+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static const char* __type_name_to_string(__type_name_t __v) _NOEXCEPT {
233+
return reinterpret_cast<const char*>(__v & ~__non_unique_rtti_bit::value);
234+
}
235+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static __type_name_t __string_to_type_name(const char* __v) _NOEXCEPT {
236+
return reinterpret_cast<__type_name_t>(__v);
237+
}
238238

239-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {
240-
if (__is_type_name_unique(__v))
241-
return __v;
242-
return __non_unique_impl::__hash(__type_name_to_string(__v));
243-
}
244-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
245-
if (__lhs == __rhs)
246-
return true;
247-
if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
248-
// Either both are unique and have a different address, or one of them
249-
// is unique and the other one isn't. In both cases they are unequal.
250-
return false;
251-
return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) == 0;
252-
}
253-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
254-
if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
255-
return __lhs < __rhs;
256-
return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) < 0;
257-
}
239+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static size_t __hash(__type_name_t __v) _NOEXCEPT {
240+
if (__is_type_name_unique(__v))
241+
return __v;
242+
return __non_unique_impl::__hash(__type_name_to_string(__v));
243+
}
244+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
245+
if (__lhs == __rhs)
246+
return true;
247+
if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
248+
// Either both are unique and have a different address, or one of them
249+
// is unique and the other one isn't. In both cases they are unequal.
250+
return false;
251+
return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) == 0;
252+
}
253+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
254+
if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
255+
return __lhs < __rhs;
256+
return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) < 0;
257+
}
258258

259-
private:
260-
// The unique bit is the top bit. It is expected that __type_name_t is 64 bits when
261-
// this implementation is actually used.
262-
typedef integral_constant<__type_name_t, (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))>
263-
__non_unique_rtti_bit;
259+
private:
260+
// The unique bit is the top bit. It is expected that __type_name_t is 64 bits when
261+
// this implementation is actually used.
262+
typedef integral_constant<__type_name_t, (1ULL << ((__CHAR_BIT__ * sizeof(__type_name_t)) - 1))>
263+
__non_unique_rtti_bit;
264264

265-
_LIBCPP_HIDE_FROM_ABI static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT {
266-
return !(__lhs & __non_unique_rtti_bit::value);
267-
}
268-
};
265+
_LIBCPP_HIDE_FROM_ABI static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT {
266+
return !(__lhs & __non_unique_rtti_bit::value);
267+
}
268+
};
269269

270-
typedef
270+
typedef
271271
# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
272-
__unique_impl
272+
__unique_impl
273273
# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2
274-
__non_unique_impl
274+
__non_unique_impl
275275
# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3
276-
__non_unique_arm_rtti_bit_impl
276+
__non_unique_arm_rtti_bit_impl
277277
# else
278278
# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
279279
# endif
280-
__impl;
281-
};
280+
__impl;
281+
} // namespace __type_info_implementations
282282

283283
# if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__)
284284
# if __has_feature(ptrauth_type_info_vtable_pointer_discrimination)

0 commit comments

Comments
 (0)