Skip to content

Commit f722615

Browse files
committed
[libc][NFC] Use STL case for type_traits
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion. Starting with the type_traits header. Differential Revision: https://reviews.llvm.org/D130727
1 parent d031101 commit f722615

Some content is hidden

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

45 files changed

+345
-358
lines changed

libc/fuzzing/math/Compare.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
#ifndef LLVM_LIBC_FUZZING_MATH_COMPARE_H
1010
#define LLVM_LIBC_FUZZING_MATH_COMPARE_H
1111

12-
#include "src/__support/CPP/TypeTraits.h"
12+
#include "src/__support/CPP/type_traits.h"
1313
#include "src/__support/FPUtil/FPBits.h"
1414

1515
template <typename T>
16-
__llvm_libc::cpp::EnableIfType<__llvm_libc::cpp::IsFloatingPointType<T>::Value,
17-
bool>
16+
__llvm_libc::cpp::enable_if_t<__llvm_libc::cpp::is_floating_point_v<T>, bool>
1817
ValuesEqual(T x1, T x2) {
1918
__llvm_libc::fputil::FPBits<T> bits1(x1);
2019
__llvm_libc::fputil::FPBits<T> bits2(x2);
@@ -27,7 +26,7 @@ ValuesEqual(T x1, T x2) {
2726
}
2827

2928
template <typename T>
30-
__llvm_libc::cpp::EnableIfType<__llvm_libc::cpp::IsIntegral<T>::Value, bool>
29+
__llvm_libc::cpp::enable_if_t<__llvm_libc::cpp::is_integral_v<T>, bool>
3130
ValuesEqual(T x1, T x2) {
3231
return x1 == x1;
3332
}

libc/src/__support/CPP/ArrayRef.h

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

1212
#include "Array.h"
13-
#include "TypeTraits.h" //RemoveCVType
13+
#include "type_traits.h" // RemoveCVType
1414

1515
#include <stddef.h> // For size_t.
1616

@@ -24,7 +24,7 @@ namespace cpp {
2424
namespace internal {
2525
template <typename QualifiedT> class ArrayRefBase {
2626
public:
27-
using value_type = RemoveCVType<QualifiedT>;
27+
using value_type = remove_cv_t<QualifiedT>;
2828
using pointer = value_type *;
2929
using const_pointer = const value_type *;
3030
using reference = value_type &;
@@ -109,7 +109,7 @@ template <typename QualifiedT> class ArrayRefBase {
109109

110110
template <typename T> struct ArrayRef : public internal::ArrayRefBase<const T> {
111111
private:
112-
static_assert(IsSameV<T, RemoveCVType<T>>,
112+
static_assert(is_same_v<T, remove_cv_t<T>>,
113113
"ArrayRef must have a non-const, non-volatile value_type");
114114
using Impl = internal::ArrayRefBase<const T>;
115115
using Impl::Impl;
@@ -128,7 +128,7 @@ template <typename T>
128128
struct MutableArrayRef : public internal::ArrayRefBase<T> {
129129
private:
130130
static_assert(
131-
IsSameV<T, RemoveCVType<T>>,
131+
is_same_v<T, remove_cv_t<T>>,
132132
"MutableArrayRef must have a non-const, non-volatile value_type");
133133
using Impl = internal::ArrayRefBase<T>;
134134
using Impl::Impl;

libc/src/__support/CPP/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ add_header_library(
7171
add_header_library(
7272
type_traits
7373
HDRS
74-
TypeTraits.h
74+
type_traits.h
7575
DEPENDS
7676
.uint
7777
)

libc/src/__support/CPP/TypeTraits.h

Lines changed: 0 additions & 157 deletions
This file was deleted.

libc/src/__support/CPP/Utility.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H
1010
#define LLVM_LIBC_SRC_SUPPORT_CPP_UTILITY_H
1111

12-
#include "src/__support/CPP/TypeTraits.h"
12+
#include "src/__support/CPP/type_traits.h"
1313

1414
namespace __llvm_libc::cpp {
1515

1616
template <typename T, T... Seq> struct IntegerSequence {
17-
static_assert(IsIntegral<T>::Value);
17+
static_assert(is_integral_v<T>);
1818
template <T Next> using append = IntegerSequence<T, Seq..., Next>;
1919
};
2020

libc/src/__support/CPP/atomic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_LIBC_SRC_SUPPORT_CPP_ATOMIC_H
1010
#define LLVM_LIBC_SRC_SUPPORT_CPP_ATOMIC_H
1111

12-
#include "TypeTraits.h"
12+
#include "type_traits.h"
1313

1414
namespace __llvm_libc {
1515
namespace cpp {
@@ -25,7 +25,7 @@ enum class MemoryOrder : int {
2525

2626
template <typename T> struct Atomic {
2727
// For now, we will restrict to only arithmetic types.
28-
static_assert(IsArithmetic<T>::Value, "Only arithmetic types can be atomic.");
28+
static_assert(is_arithmetic_v<T>, "Only arithmetic types can be atomic.");
2929

3030
private:
3131
// The value stored should be appropriately aligned so that

libc/src/__support/CPP/stringstream.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "ArrayRef.h"
1313
#include "StringView.h"
14-
#include "TypeTraits.h"
14+
#include "type_traits.h"
1515

1616
#include "src/__support/integer_to_string.h"
1717

@@ -56,17 +56,17 @@ class StringStream {
5656
}
5757

5858
// Write the |val| as string.
59-
template <typename T, EnableIfType<IsIntegral<T>::Value, int> = 0>
59+
template <typename T, enable_if_t<is_integral_v<T>, int> = 0>
6060
StringStream &operator<<(T val) {
6161
const auto int_to_str = integer_to_string(val);
6262
return operator<<(int_to_str.str());
6363
}
6464

65-
template <typename T, EnableIfType<IsFloatingPointType<T>::Value, int> = 0>
65+
template <typename T, enable_if_t<is_floating_point_v<T>, int> = 0>
6666
StringStream &operator<<(T val) {
6767
// If this specialization gets activated, then the static_assert will
6868
// trigger a compile error about missing floating point number support.
69-
static_assert(!IsFloatingPointType<T>::Value,
69+
static_assert(!is_floating_point_v<T>,
7070
"Writing floating point numbers is not yet supported");
7171
return *this;
7272
}

0 commit comments

Comments
 (0)