Skip to content

Commit

Permalink
[libc++][NFC] Rename _LIBCPP_NO_RTTI to _LIBCPP_HAS_NO_RTTI
Browse files Browse the repository at this point in the history
Other macros that disable parts of the library are named `_LIBCPP_HAS_NO_WHATEVER`.

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D143164

(cherry picked from commit cf65d27)
  • Loading branch information
philnik777 authored and tru committed Feb 14, 2023
1 parent 564b29c commit 8e12c6e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD

// Try to find out if RTTI is disabled.
# if !defined(__cpp_rtti) || __cpp_rtti < 199711L
# define _LIBCPP_NO_RTTI
# define _LIBCPP_HAS_NO_RTTI
# endif

# ifndef _LIBCPP_WEAK
Expand Down
38 changes: 19 additions & 19 deletions libcxx/include/__functional/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ class __base<_Rp(_ArgTypes...)>
virtual void destroy() _NOEXCEPT = 0;
virtual void destroy_deallocate() _NOEXCEPT = 0;
virtual _Rp operator()(_ArgTypes&& ...) = 0;
#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
virtual const void* target(const type_info&) const _NOEXCEPT = 0;
virtual const std::type_info& target_type() const _NOEXCEPT = 0;
#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI
};

// __func implements __base for a given functor type.
Expand Down Expand Up @@ -305,10 +305,10 @@ class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
virtual void destroy() _NOEXCEPT;
virtual void destroy_deallocate() _NOEXCEPT;
virtual _Rp operator()(_ArgTypes&&... __arg);
#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
virtual const void* target(const type_info&) const _NOEXCEPT;
virtual const std::type_info& target_type() const _NOEXCEPT;
#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI
};

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
Expand Down Expand Up @@ -356,7 +356,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
return __f_(_VSTD::forward<_ArgTypes>(__arg)...);
}

#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI

template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
const void*
Expand All @@ -374,7 +374,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
return typeid(_Fp);
}

#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI

// __value_func creates a value-type from a __func.

Expand Down Expand Up @@ -553,7 +553,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
_LIBCPP_INLINE_VISIBILITY
explicit operator bool() const _NOEXCEPT { return __f_ != nullptr; }

#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
_LIBCPP_INLINE_VISIBILITY
const std::type_info& target_type() const _NOEXCEPT
{
Expand All @@ -569,7 +569,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
return nullptr;
return (const _Tp*)__f_->target(typeid(_Tp));
}
#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI
};

// Storage for a functor object, to be used with __policy to manage copy and
Expand Down Expand Up @@ -616,7 +616,7 @@ struct __policy
{
static const _LIBCPP_CONSTEXPR __policy __policy_ = {nullptr, nullptr,
true,
#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
&typeid(void)
#else
nullptr
Expand All @@ -642,7 +642,7 @@ struct __policy
__choose_policy(/* is_small = */ false_type) {
static const _LIBCPP_CONSTEXPR __policy __policy_ = {
&__large_clone<_Fun>, &__large_destroy<_Fun>, false,
#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
&typeid(typename _Fun::_Target)
#else
nullptr
Expand All @@ -657,7 +657,7 @@ struct __policy
{
static const _LIBCPP_CONSTEXPR __policy __policy_ = {
nullptr, nullptr, false,
#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
&typeid(typename _Fun::_Target)
#else
nullptr
Expand Down Expand Up @@ -861,7 +861,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
return !__policy_->__is_null;
}

#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
_LIBCPP_INLINE_VISIBILITY
const std::type_info& target_type() const _NOEXCEPT
{
Expand All @@ -878,7 +878,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
else
return reinterpret_cast<const _Tp*>(&__buf_.__small);
}
#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI
};

#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME)
Expand Down Expand Up @@ -945,7 +945,7 @@ class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
}

#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
virtual const void* target(type_info const& __ti) const _NOEXCEPT {
if (__ti == typeid(__func::__block_type))
return &__f_;
Expand All @@ -955,7 +955,7 @@ class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
virtual const std::type_info& target_type() const _NOEXCEPT {
return typeid(__func::__block_type);
}
#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI
};

#endif // _LIBCPP_HAS_EXTENSION_BLOCKS
Expand Down Expand Up @@ -1056,12 +1056,12 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
// function invocation:
_Rp operator()(_ArgTypes...) const;

#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
// function target access:
const std::type_info& target_type() const _NOEXCEPT;
template <typename _Tp> _Tp* target() _NOEXCEPT;
template <typename _Tp> const _Tp* target() const _NOEXCEPT;
#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI
};

#if _LIBCPP_STD_VER >= 17
Expand Down Expand Up @@ -1156,7 +1156,7 @@ function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
return __f_(_VSTD::forward<_ArgTypes>(__arg)...);
}

#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI

template<class _Rp, class ..._ArgTypes>
const std::type_info&
Expand All @@ -1181,7 +1181,7 @@ function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
return __f_.template target<_Tp>();
}

#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI

template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
Expand Down
14 changes: 7 additions & 7 deletions libcxx/include/__memory/shared_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class __shared_ptr_pointer
__shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a)
: __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {}

#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
const void* __get_deleter(const type_info&) const _NOEXCEPT override;
#endif

Expand All @@ -228,7 +228,7 @@ class __shared_ptr_pointer
void __on_zero_shared_weak() _NOEXCEPT override;
};

#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI

template <class _Tp, class _Dp, class _Alloc>
const void*
Expand All @@ -237,7 +237,7 @@ __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) cons
return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : nullptr;
}

#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI

template <class _Tp, class _Dp, class _Alloc>
void
Expand Down Expand Up @@ -903,7 +903,7 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr
}
#endif

#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI
template <class _Dp>
_LIBCPP_HIDE_FROM_ABI
_Dp* __get_deleter() const _NOEXCEPT
Expand All @@ -912,7 +912,7 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr
? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp)))
: nullptr);
}
#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI

template<class _Yp, class _CntrlBlk>
_LIBCPP_HIDE_FROM_ABI
Expand Down Expand Up @@ -1510,7 +1510,7 @@ reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
typename shared_ptr<_Tp>::element_type*>(__r.get()));
}

#ifndef _LIBCPP_NO_RTTI
#ifndef _LIBCPP_HAS_NO_RTTI

template<class _Dp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -1520,7 +1520,7 @@ get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT
return __p.template __get_deleter<_Dp>();
}

#endif // _LIBCPP_NO_RTTI
#endif // _LIBCPP_HAS_NO_RTTI

template<class _Tp>
class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr
Expand Down
10 changes: 5 additions & 5 deletions libcxx/include/any
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ namespace __any_imp
inline _LIBCPP_INLINE_VISIBILITY
bool __compare_typeid(type_info const* __id, const void* __fallback_id)
{
#if !defined(_LIBCPP_NO_RTTI)
#if !defined(_LIBCPP_HAS_NO_RTTI)
if (__id && *__id == typeid(_Tp))
return true;
#endif
Expand Down Expand Up @@ -294,7 +294,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool has_value() const _NOEXCEPT { return __h_ != nullptr; }

#if !defined(_LIBCPP_NO_RTTI)
#if !defined(_LIBCPP_HAS_NO_RTTI)
_LIBCPP_INLINE_VISIBILITY
const type_info & type() const _NOEXCEPT {
if (__h_) {
Expand Down Expand Up @@ -426,7 +426,7 @@ namespace __any_imp
_LIBCPP_INLINE_VISIBILITY
static void* __type_info()
{
#if !defined(_LIBCPP_NO_RTTI)
#if !defined(_LIBCPP_HAS_NO_RTTI)
return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
#else
return nullptr;
Expand Down Expand Up @@ -514,7 +514,7 @@ namespace __any_imp
_LIBCPP_INLINE_VISIBILITY
static void* __type_info()
{
#if !defined(_LIBCPP_NO_RTTI)
#if !defined(_LIBCPP_HAS_NO_RTTI)
return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
#else
return nullptr;
Expand Down Expand Up @@ -680,7 +680,7 @@ any_cast(any * __any) _NOEXCEPT
typedef add_pointer_t<_ValueType> _ReturnType;
if (__any && __any->__h_) {
void *__p = __any->__call(_Action::_Get, nullptr,
#if !defined(_LIBCPP_NO_RTTI)
#if !defined(_LIBCPP_HAS_NO_RTTI)
&typeid(_ValueType),
#else
nullptr,
Expand Down

0 comments on commit 8e12c6e

Please sign in to comment.