Skip to content

Commit 11c2923

Browse files
[ADT] Use "using" instead of "typedef" (NFC) (llvm#166129)
Identified with modernize-use-using.
1 parent 2458e15 commit 11c2923

36 files changed

+175
-181
lines changed

llvm/include/llvm/ADT/APFloat.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class APFloatBase {
152152
static constexpr unsigned integerPartWidth = APInt::APINT_BITS_PER_WORD;
153153

154154
/// A signed type to represent a floating point numbers unbiased exponent.
155-
typedef int32_t ExponentType;
155+
using ExponentType = int32_t;
156156

157157
/// \name Floating Point Semantics.
158158
/// @{
@@ -938,8 +938,8 @@ LLVM_ABI DoubleAPFloat frexp(const DoubleAPFloat &X, int &Exp, roundingMode);
938938
// This is a interface class that is currently forwarding functionalities from
939939
// detail::IEEEFloat.
940940
class APFloat : public APFloatBase {
941-
typedef detail::IEEEFloat IEEEFloat;
942-
typedef detail::DoubleAPFloat DoubleAPFloat;
941+
using IEEEFloat = detail::IEEEFloat;
942+
using DoubleAPFloat = detail::DoubleAPFloat;
943943

944944
static_assert(std::is_standard_layout<IEEEFloat>::value);
945945

llvm/include/llvm/ADT/APInt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ inline APInt operator-(APInt);
7777
///
7878
class [[nodiscard]] APInt {
7979
public:
80-
typedef uint64_t WordType;
80+
using WordType = uint64_t;
8181

8282
/// Byte size of a word.
8383
static constexpr unsigned APINT_WORD_SIZE = sizeof(WordType);

llvm/include/llvm/ADT/BitVector.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ template <typename BitVectorT> class const_set_bits_iterator_impl {
9999
};
100100

101101
class BitVector {
102-
typedef uintptr_t BitWord;
102+
using BitWord = uintptr_t;
103103

104104
enum { BITWORD_SIZE = (unsigned)sizeof(BitWord) * CHAR_BIT };
105105

@@ -147,8 +147,8 @@ class BitVector {
147147
}
148148
};
149149

150-
typedef const_set_bits_iterator_impl<BitVector> const_set_bits_iterator;
151-
typedef const_set_bits_iterator set_iterator;
150+
using const_set_bits_iterator = const_set_bits_iterator_impl<BitVector>;
151+
using set_iterator = const_set_bits_iterator;
152152

153153
const_set_bits_iterator set_bits_begin() const {
154154
return const_set_bits_iterator(*this);

llvm/include/llvm/ADT/GenericSSAContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ template <typename, bool> class DominatorTreeBase;
2525
template <typename> class SmallVectorImpl;
2626

2727
namespace Intrinsic {
28-
typedef unsigned ID;
28+
using ID = unsigned;
2929
}
3030

3131
// Specializations of this template should provide the types used by the

llvm/include/llvm/ADT/STLExtras.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,8 +1516,8 @@ template <class Iterator, class RNG>
15161516
void shuffle(Iterator first, Iterator last, RNG &&g) {
15171517
// It would be better to use a std::uniform_int_distribution,
15181518
// but that would be stdlib dependent.
1519-
typedef
1520-
typename std::iterator_traits<Iterator>::difference_type difference_type;
1519+
using difference_type =
1520+
typename std::iterator_traits<Iterator>::difference_type;
15211521
for (auto size = last - first; size > 1; ++first, (void)--size) {
15221522
difference_type offset = g() % size;
15231523
// Avoid self-assignment due to incorrect assertions in libstdc++

llvm/include/llvm/ADT/ilist.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,21 @@ template <typename Ty> struct ilist_traits<const Ty> {};
108108
/// list.
109109
template <class IntrusiveListT, class TraitsT>
110110
class iplist_impl : public TraitsT, IntrusiveListT {
111-
typedef IntrusiveListT base_list_type;
111+
using base_list_type = IntrusiveListT;
112112

113113
public:
114-
typedef typename base_list_type::pointer pointer;
115-
typedef typename base_list_type::const_pointer const_pointer;
116-
typedef typename base_list_type::reference reference;
117-
typedef typename base_list_type::const_reference const_reference;
118-
typedef typename base_list_type::value_type value_type;
119-
typedef typename base_list_type::size_type size_type;
120-
typedef typename base_list_type::difference_type difference_type;
121-
typedef typename base_list_type::iterator iterator;
122-
typedef typename base_list_type::const_iterator const_iterator;
123-
typedef typename base_list_type::reverse_iterator reverse_iterator;
124-
typedef
125-
typename base_list_type::const_reverse_iterator const_reverse_iterator;
114+
using pointer = typename base_list_type::pointer;
115+
using const_pointer = typename base_list_type::const_pointer;
116+
using reference = typename base_list_type::reference;
117+
using const_reference = typename base_list_type::const_reference;
118+
using value_type = typename base_list_type::value_type;
119+
using size_type = typename base_list_type::size_type;
120+
using difference_type = typename base_list_type::difference_type;
121+
using iterator = typename base_list_type::iterator;
122+
using const_iterator = typename base_list_type::const_iterator;
123+
using reverse_iterator = typename base_list_type::reverse_iterator;
124+
using const_reverse_iterator =
125+
typename base_list_type::const_reverse_iterator;
126126

127127
private:
128128
static bool op_less(const_reference L, const_reference R) { return L < R; }

llvm/include/llvm/ADT/ilist_node_options.h

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ namespace ilist_detail {
5858
template <bool IsExplicit> struct explicitness {
5959
static const bool is_explicit = IsExplicit;
6060
};
61-
typedef explicitness<true> is_explicit;
62-
typedef explicitness<false> is_implicit;
61+
using is_explicit = explicitness<true>;
62+
using is_implicit = explicitness<false>;
6363

6464
/// Check whether an option is valid.
6565
///
@@ -103,12 +103,12 @@ struct is_valid_option<ilist_sentinel_tracking<EnableSentinelTracking>>
103103
template <class... Options> struct extract_tag;
104104
template <class Tag, class... Options>
105105
struct extract_tag<ilist_tag<Tag>, Options...> {
106-
typedef Tag type;
106+
using type = Tag;
107107
};
108108
template <class Option1, class... Options>
109109
struct extract_tag<Option1, Options...> : extract_tag<Options...> {};
110110
template <> struct extract_tag<> {
111-
typedef void type;
111+
using type = void;
112112
};
113113
template <class Tag> struct is_valid_option<ilist_tag<Tag>> : std::true_type {};
114114

@@ -134,11 +134,13 @@ struct is_valid_option<ilist_iterator_bits<IteratorBits>> : std::true_type {};
134134
template <class... Options> struct extract_parent;
135135
template <class ParentTy, class... Options>
136136
struct extract_parent<ilist_parent<ParentTy>, Options...> {
137-
typedef ParentTy type;
137+
using type = ParentTy;
138138
};
139139
template <class Option1, class... Options>
140140
struct extract_parent<Option1, Options...> : extract_parent<Options...> {};
141-
template <> struct extract_parent<> { typedef void type; };
141+
template <> struct extract_parent<> {
142+
using type = void;
143+
};
142144
template <class ParentTy>
143145
struct is_valid_option<ilist_parent<ParentTy>> : std::true_type {};
144146

@@ -154,28 +156,27 @@ struct check_options : std::conjunction<is_valid_option<Options>...> {};
154156
template <class T, bool EnableSentinelTracking, bool IsSentinelTrackingExplicit,
155157
class TagT, bool HasIteratorBits, class ParentTy>
156158
struct node_options {
157-
typedef T value_type;
158-
typedef T *pointer;
159-
typedef T &reference;
160-
typedef const T *const_pointer;
161-
typedef const T &const_reference;
159+
using value_type = T;
160+
using pointer = T *;
161+
using reference = T &;
162+
using const_pointer = const T *;
163+
using const_reference = const T &;
162164

163165
static const bool enable_sentinel_tracking = EnableSentinelTracking;
164166
static const bool is_sentinel_tracking_explicit = IsSentinelTrackingExplicit;
165167
static const bool has_iterator_bits = HasIteratorBits;
166-
typedef TagT tag;
167-
typedef ParentTy parent_ty;
168-
typedef ilist_node_base<enable_sentinel_tracking, parent_ty> node_base_type;
169-
typedef ilist_base<enable_sentinel_tracking, parent_ty> list_base_type;
168+
using tag = TagT;
169+
using parent_ty = ParentTy;
170+
using node_base_type = ilist_node_base<enable_sentinel_tracking, parent_ty>;
171+
using list_base_type = ilist_base<enable_sentinel_tracking, parent_ty>;
170172
};
171173

172174
template <class T, class... Options> struct compute_node_options {
173-
typedef node_options<T, extract_sentinel_tracking<Options...>::value,
174-
extract_sentinel_tracking<Options...>::is_explicit,
175-
typename extract_tag<Options...>::type,
176-
extract_iterator_bits<Options...>::value,
177-
typename extract_parent<Options...>::type>
178-
type;
175+
using type = node_options<T, extract_sentinel_tracking<Options...>::value,
176+
extract_sentinel_tracking<Options...>::is_explicit,
177+
typename extract_tag<Options...>::type,
178+
extract_iterator_bits<Options...>::value,
179+
typename extract_parent<Options...>::type>;
179180
};
180181

181182
} // end namespace ilist_detail

llvm/unittests/ADT/APFloatTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10118,7 +10118,7 @@ TEST(APFloatTest, Float4E2M1FNToFloat) {
1011810118
}
1011910119

1012010120
TEST(APFloatTest, AddOrSubtractSignificand) {
10121-
typedef detail::IEEEFloatUnitTestHelper Helper;
10121+
using Helper = detail::IEEEFloatUnitTestHelper;
1012210122
// Test cases are all combinations of:
1012310123
// {equal exponents, LHS larger exponent, RHS larger exponent}
1012410124
// {equal significands, LHS larger significand, RHS larger significand}

llvm/unittests/ADT/BitVectorTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ template <typename T>
2121
class BitVectorTest : public ::testing::Test { };
2222

2323
// Test both BitVector and SmallBitVector with the same suite of tests.
24-
typedef ::testing::Types<BitVector, SmallBitVector> BitVectorTestTypes;
24+
using BitVectorTestTypes = ::testing::Types<BitVector, SmallBitVector>;
2525
TYPED_TEST_SUITE(BitVectorTest, BitVectorTestTypes, );
2626

2727
TYPED_TEST(BitVectorTest, TrivialOperation) {
@@ -857,7 +857,7 @@ TYPED_TEST(BitVectorTest, BinOps) {
857857
EXPECT_FALSE(B.anyCommon(A));
858858
}
859859

860-
typedef std::vector<std::pair<int, int>> RangeList;
860+
using RangeList = std::vector<std::pair<int, int>>;
861861

862862
template <typename VecType>
863863
static inline VecType createBitVector(uint32_t Size,

llvm/unittests/ADT/BreadthFirstIteratorTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using namespace llvm;
2121
namespace llvm {
2222

2323
TEST(BreadthFristIteratorTest, Basic) {
24-
typedef bf_iterator<Graph<4>> BFIter;
24+
using BFIter = bf_iterator<Graph<4>>;
2525

2626
Graph<4> G;
2727
G.AddEdge(0, 1);
@@ -46,7 +46,7 @@ TEST(BreadthFristIteratorTest, Basic) {
4646
}
4747

4848
TEST(BreadthFristIteratorTest, Cycle) {
49-
typedef bf_iterator<Graph<4>> BFIter;
49+
using BFIter = bf_iterator<Graph<4>>;
5050

5151
Graph<4> G;
5252
G.AddEdge(0, 1);

0 commit comments

Comments
 (0)