Skip to content

Commit cd96aa7

Browse files
[libc] Use LIBC_HAS_BUILTIN instead of __has_builtin directly.
Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D158313
1 parent db158c7 commit cd96aa7

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

libc/src/__support/CPP/type_traits.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLVM_LIBC_SRC_SUPPORT_CPP_TYPETRAITS_H
1111

1212
#include "src/__support/macros/attributes.h"
13+
#include "src/__support/macros/config.h"
1314

1415
#include <stddef.h> // For size_t.
1516

@@ -219,16 +220,17 @@ constexpr bool
219220
declval<F>()))>> = true;
220221

221222
namespace details {
222-
#if __has_builtin(__is_lvalue_reference) && \
223-
__has_builtin(__is_rvalue_reference) && __has_builtin(__is_reference)
223+
#if LIBC_HAS_BUILTIN(__is_lvalue_reference) && \
224+
LIBC_HAS_BUILTIN(__is_rvalue_reference) && \
225+
LIBC_HAS_BUILTIN(__is_reference)
224226

225227
template <typename T>
226228
struct is_lvalue_reference : bool_constant<__is_lvalue_reference(T)> {};
227229
template <typename T>
228230
struct is_rvalue_reference : bool_constant<__is_rvalue_reference(T)> {};
229231
template <typename T> struct is_reference : bool_constant<__is_reference(T)> {};
230232

231-
#else // __has_builtin(__is_lvalue_reference) && etc...
233+
#else // LIBC_HAS_BUILTIN(__is_lvalue_reference) && etc...
232234

233235
template <typename T> struct is_lvalue_reference : public false_type {};
234236
template <typename T> struct is_lvalue_reference<T &> : public true_type {};
@@ -240,9 +242,9 @@ template <typename T> struct is_reference : public false_type {};
240242
template <typename T> struct is_reference<T &> : public true_type {};
241243
template <typename T> struct is_reference<T &&> : public true_type {};
242244

243-
#endif // __has_builtin(__is_lvalue_reference) && etc...
245+
#endif // LIBC_HAS_BUILTIN(__is_lvalue_reference) && etc...
244246

245-
#if __has_builtin(__remove_all_extents)
247+
#if LIBC_HAS_BUILTIN(__remove_all_extents)
246248
template <typename T> using __remove_all_extents_t = __remove_all_extents(T);
247249
#else
248250
template <typename T> struct remove_all_extents {
@@ -257,9 +259,9 @@ template <typename T, size_t _Np> struct remove_all_extents<T[_Np]> {
257259

258260
template <typename T>
259261
using __remove_all_extents_t = typename remove_all_extents<T>::type;
260-
#endif // __has_builtin(__remove_all_extents)
262+
#endif // LIBC_HAS_BUILTIN(__remove_all_extents)
261263

262-
#if __has_builtin(__is_function)
264+
#if LIBC_HAS_BUILTIN(__is_function)
263265

264266
template <typename T>
265267
struct is_function : integral_constant<bool, __is_function(T)> {};
@@ -271,14 +273,14 @@ struct is_function
271273
: public integral_constant<bool, !(is_reference<T>::value ||
272274
is_const<const T>::value)> {};
273275

274-
#endif // __has_builtin(__is_function)
276+
#endif // LIBC_HAS_BUILTIN(__is_function)
275277

276-
#if __has_builtin(__is_destructible)
278+
#if LIBC_HAS_BUILTIN(__is_destructible)
277279

278280
template <typename T>
279281
struct is_destructible : bool_constant<__is_destructible(T)> {};
280282

281-
#else // __has_builtin(__is_destructible)
283+
#else // LIBC_HAS_BUILTIN(__is_destructible)
282284

283285
// if it's a reference, return true
284286
// if it's a function, return false
@@ -324,24 +326,22 @@ struct is_destructible : public __destructible_false<T, is_function<T>::value> {
324326
template <typename T> struct is_destructible<T[]> : public false_type {};
325327
template <> struct is_destructible<void> : public false_type {};
326328

327-
#endif // __has_builtin(__is_destructible)
329+
#endif // LIBC_HAS_BUILTIN(__is_destructible)
328330
} // namespace details
329331

330-
#if __has_builtin(__is_trivially_destructible)
332+
#if LIBC_HAS_BUILTIN(__is_trivially_destructible)
331333

332334
template <typename T>
333335
struct is_trivially_destructible
334336
: public integral_constant<bool, __is_trivially_destructible(T)> {};
335337

336-
#elif __has_builtin(__has_trivial_destructor)
337-
338+
#else
338339
template <typename T>
339340
struct is_trivially_destructible
340341
: public integral_constant<
341342
bool, __llvm_libc::cpp::details::is_destructible<T>::value
342343
&&__has_trivial_destructor(T)> {};
343-
344-
#endif // __has_builtin(__is_trivially_destructible)
344+
#endif // LIBC_HAS_BUILTIN(__is_trivially_destructible)
345345

346346
} // namespace cpp
347347
} // namespace __llvm_libc

0 commit comments

Comments
 (0)