Skip to content

Commit 5ed8f48

Browse files
[Support] Use "using" instead of "typedef" (NFC) (llvm#166130)
Identified with modernize-use-using.
1 parent 11c2923 commit 5ed8f48

30 files changed

+95
-98
lines changed

llvm/include/llvm/Support/Allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class BumpPtrAllocatorImpl
380380

381381
/// The standard BumpPtrAllocator which just uses the default template
382382
/// parameters.
383-
typedef BumpPtrAllocatorImpl<> BumpPtrAllocator;
383+
using BumpPtrAllocator = BumpPtrAllocatorImpl<>;
384384

385385
/// A BumpPtrAllocator that allows only elements of a specific type to be
386386
/// allocated.

llvm/include/llvm/Support/Atomic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ namespace llvm {
3030
LLVM_ABI void MemoryFence();
3131

3232
#ifdef _MSC_VER
33-
typedef long cas_flag;
33+
using cas_flag = long;
3434
#else
35-
typedef uint32_t cas_flag;
35+
using cas_flag = uint32_t;
3636
#endif
3737
LLVM_ABI cas_flag CompareAndSwap(volatile cas_flag *ptr, cas_flag new_value,
3838
cas_flag old_value);

llvm/include/llvm/Support/BinaryStreamArray.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class VarStreamArray {
9393
friend class VarStreamArrayIterator<ValueType, Extractor>;
9494

9595
public:
96-
typedef VarStreamArrayIterator<ValueType, Extractor> Iterator;
96+
using Iterator = VarStreamArrayIterator<ValueType, Extractor>;
9797

9898
VarStreamArray() = default;
9999

@@ -156,8 +156,8 @@ template <typename ValueType, typename Extractor>
156156
class VarStreamArrayIterator
157157
: public iterator_facade_base<VarStreamArrayIterator<ValueType, Extractor>,
158158
std::forward_iterator_tag, const ValueType> {
159-
typedef VarStreamArrayIterator<ValueType, Extractor> IterType;
160-
typedef VarStreamArray<ValueType, Extractor> ArrayType;
159+
using IterType = VarStreamArrayIterator<ValueType, Extractor>;
160+
using ArrayType = VarStreamArray<ValueType, Extractor>;
161161

162162
public:
163163
VarStreamArrayIterator(const ArrayType &Array, const Extractor &E,
@@ -260,7 +260,7 @@ template <typename T> class FixedStreamArray {
260260
friend class FixedStreamArrayIterator<T>;
261261

262262
public:
263-
typedef FixedStreamArrayIterator<T> Iterator;
263+
using Iterator = FixedStreamArrayIterator<T>;
264264

265265
FixedStreamArray() = default;
266266
explicit FixedStreamArray(BinaryStreamRef Stream) : Stream(Stream) {

llvm/include/llvm/Support/Chrono.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ template <> struct unit<std::nano> {
150150
template <typename Rep, typename Period>
151151
struct format_provider<std::chrono::duration<Rep, Period>> {
152152
private:
153-
typedef std::chrono::duration<Rep, Period> Dur;
154-
typedef std::conditional_t<std::chrono::treat_as_floating_point<Rep>::value,
155-
double, intmax_t>
156-
InternalRep;
153+
using Dur = std::chrono::duration<Rep, Period>;
154+
using InternalRep =
155+
std::conditional_t<std::chrono::treat_as_floating_point<Rep>::value,
156+
double, intmax_t>;
157157

158158
template <typename AsPeriod> static InternalRep getAs(const Dur &D) {
159159
using namespace std::chrono;

llvm/include/llvm/Support/ConvertUTF.h

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ namespace llvm {
126126
bit mask & shift operations.
127127
------------------------------------------------------------------------ */
128128

129-
typedef unsigned int UTF32; /* at least 32 bits */
130-
typedef unsigned short UTF16; /* at least 16 bits */
131-
typedef unsigned char UTF8; /* typically 8 bits */
132-
typedef unsigned char Boolean; /* 0 or 1 */
129+
using UTF32 = unsigned int; /* at least 32 bits */
130+
using UTF16 = unsigned short; /* at least 16 bits */
131+
using UTF8 = unsigned char; /* typically 8 bits */
132+
using Boolean = unsigned char; /* 0 or 1 */
133133

134134
/* Some fundamental constants */
135135
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
@@ -146,17 +146,14 @@ typedef unsigned char Boolean; /* 0 or 1 */
146146
#define UNI_UTF32_BYTE_ORDER_MARK_NATIVE 0x0000FEFF
147147
#define UNI_UTF32_BYTE_ORDER_MARK_SWAPPED 0xFFFE0000
148148

149-
typedef enum {
150-
conversionOK, /* conversion successful */
151-
sourceExhausted, /* partial character in source, but hit end */
152-
targetExhausted, /* insuff. room in target for conversion */
153-
sourceIllegal /* source sequence is illegal/malformed */
154-
} ConversionResult;
155-
156-
typedef enum {
157-
strictConversion = 0,
158-
lenientConversion
159-
} ConversionFlags;
149+
enum ConversionResult {
150+
conversionOK, /* conversion successful */
151+
sourceExhausted, /* partial character in source, but hit end */
152+
targetExhausted, /* insuff. room in target for conversion */
153+
sourceIllegal /* source sequence is illegal/malformed */
154+
};
155+
156+
enum ConversionFlags { strictConversion = 0, lenientConversion };
160157

161158
LLVM_ABI ConversionResult ConvertUTF8toUTF16(const UTF8 **sourceStart,
162159
const UTF8 *sourceEnd,

llvm/include/llvm/Support/DebugCounter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class DebugCounter {
140140
}
141141

142142
// Iterate through the registered counters
143-
typedef UniqueVector<std::string> CounterVector;
143+
using CounterVector = UniqueVector<std::string>;
144144
CounterVector::const_iterator begin() const {
145145
return RegisteredCounters.begin();
146146
}

llvm/include/llvm/Support/ErrorHandling.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class StringRef;
2121
class Twine;
2222

2323
/// An error handler callback.
24-
typedef void (*fatal_error_handler_t)(void *user_data, const char *reason,
25-
bool gen_crash_diag);
24+
using fatal_error_handler_t = void (*)(void *user_data, const char *reason,
25+
bool gen_crash_diag);
2626

2727
/// install_fatal_error_handler - Installs a new error handler to be used
2828
/// whenever a serious (non-recoverable) error is encountered by LLVM.

llvm/include/llvm/Support/FormatVariadicDetails.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ template <typename T> class missing_format_adapter;
6363
template <class T> class has_FormatProvider {
6464
public:
6565
using Decayed = std::decay_t<T>;
66-
typedef void (*Signature_format)(const Decayed &, llvm::raw_ostream &,
67-
StringRef);
66+
using Signature_format = void (*)(const Decayed &, llvm::raw_ostream &,
67+
StringRef);
6868

6969
template <typename U> using check = SameType<Signature_format, &U::format>;
7070

llvm/include/llvm/Support/GenericLoopInfo.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ template <class BlockT, class LoopT> class LoopBase {
150150
assert(!isInvalid() && "Loop not in a valid state!");
151151
return SubLoops;
152152
}
153-
typedef typename std::vector<LoopT *>::const_iterator iterator;
154-
typedef
155-
typename std::vector<LoopT *>::const_reverse_iterator reverse_iterator;
153+
using iterator = typename std::vector<LoopT *>::const_iterator;
154+
using reverse_iterator =
155+
typename std::vector<LoopT *>::const_reverse_iterator;
156156
iterator begin() const { return getSubLoops().begin(); }
157157
iterator end() const { return getSubLoops().end(); }
158158
reverse_iterator rbegin() const { return getSubLoops().rbegin(); }
@@ -174,7 +174,7 @@ template <class BlockT, class LoopT> class LoopBase {
174174
assert(!isInvalid() && "Loop not in a valid state!");
175175
return Blocks;
176176
}
177-
typedef typename ArrayRef<BlockT *>::const_iterator block_iterator;
177+
using block_iterator = typename ArrayRef<BlockT *>::const_iterator;
178178
block_iterator block_begin() const { return getBlocks().begin(); }
179179
block_iterator block_end() const { return getBlocks().end(); }
180180
inline iterator_range<block_iterator> blocks() const {
@@ -302,7 +302,7 @@ template <class BlockT, class LoopT> class LoopBase {
302302
bool hasNoExitBlocks() const;
303303

304304
/// Edge type.
305-
typedef std::pair<BlockT *, BlockT *> Edge;
305+
using Edge = std::pair<BlockT *, BlockT *>;
306306

307307
/// Return all pairs of (_inside_block_,_outside_block_).
308308
void getExitEdges(SmallVectorImpl<Edge> &ExitEdges) const;
@@ -575,9 +575,9 @@ template <class BlockT, class LoopT> class LoopInfoBase {
575575
/// iterator/begin/end - The interface to the top-level loops in the current
576576
/// function.
577577
///
578-
typedef typename std::vector<LoopT *>::const_iterator iterator;
579-
typedef
580-
typename std::vector<LoopT *>::const_reverse_iterator reverse_iterator;
578+
using iterator = typename std::vector<LoopT *>::const_iterator;
579+
using reverse_iterator =
580+
typename std::vector<LoopT *>::const_reverse_iterator;
581581
iterator begin() const { return TopLevelLoops.begin(); }
582582
iterator end() const { return TopLevelLoops.end(); }
583583
reverse_iterator rbegin() const { return TopLevelLoops.rbegin(); }

llvm/include/llvm/Support/GenericLoopInfoImpl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ template <class BlockT, class LoopT>
459459
static void discoverAndMapSubloop(LoopT *L, ArrayRef<BlockT *> Backedges,
460460
LoopInfoBase<BlockT, LoopT> *LI,
461461
const DomTreeBase<BlockT> &DomTree) {
462-
typedef GraphTraits<Inverse<BlockT *>> InvBlockTraits;
462+
using InvBlockTraits = GraphTraits<Inverse<BlockT *>>;
463463

464464
unsigned NumBlocks = 0;
465465
unsigned NumSubloops = 0;
@@ -513,8 +513,8 @@ static void discoverAndMapSubloop(LoopT *L, ArrayRef<BlockT *> Backedges,
513513

514514
/// Populate all loop data in a stable order during a single forward DFS.
515515
template <class BlockT, class LoopT> class PopulateLoopsDFS {
516-
typedef GraphTraits<BlockT *> BlockTraits;
517-
typedef typename BlockTraits::ChildIteratorType SuccIterTy;
516+
using BlockTraits = GraphTraits<BlockT *>;
517+
using SuccIterTy = typename BlockTraits::ChildIteratorType;
518518

519519
LoopInfoBase<BlockT, LoopT> *LI;
520520

0 commit comments

Comments
 (0)