Skip to content

Commit 703f8db

Browse files
authored
Merge pull request #15759 from ikesyo/sil-using-over-typedef
[gardening][SIL] Replace `typedef` with `using`
2 parents 86fef48 + 03fbd4a commit 703f8db

18 files changed

+40
-39
lines changed

include/swift/SIL/CFG.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct GraphTraits<swift::SILFunction *>
9292

9393
static NodeRef getEntryNode(GraphType F) { return &F->front(); }
9494

95-
typedef pointer_iterator<swift::SILFunction::iterator> nodes_iterator;
95+
using nodes_iterator = pointer_iterator<swift::SILFunction::iterator>;
9696
static nodes_iterator nodes_begin(GraphType F) {
9797
return nodes_iterator(F->begin());
9898
}
@@ -104,12 +104,12 @@ struct GraphTraits<swift::SILFunction *>
104104

105105
template <> struct GraphTraits<Inverse<swift::SILFunction*> >
106106
: public GraphTraits<Inverse<swift::SILBasicBlock*> > {
107-
typedef Inverse<swift::SILFunction *> GraphType;
108-
typedef NodeRef NodeRef;
107+
using GraphType = Inverse<swift::SILFunction *>;
108+
using NodeRef = NodeRef;
109109

110110
static NodeRef getEntryNode(GraphType F) { return &F.Graph->front(); }
111111

112-
typedef pointer_iterator<swift::SILFunction::iterator> nodes_iterator;
112+
using nodes_iterator = pointer_iterator<swift::SILFunction::iterator>;
113113
static nodes_iterator nodes_begin(GraphType F) {
114114
return nodes_iterator(F.Graph->begin());
115115
}

include/swift/SIL/Dominance.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ namespace llvm {
192192
/// iterable by generic graph iterators.
193193
template <> struct GraphTraits<swift::DominanceInfoNode *> {
194194
using ChildIteratorType = swift::DominanceInfoNode::iterator;
195-
typedef swift::DominanceInfoNode *NodeRef;
195+
using NodeRef = swift::DominanceInfoNode *;
196196

197197
static NodeRef getEntryNode(NodeRef N) { return N; }
198198
static inline ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
@@ -201,7 +201,7 @@ template <> struct GraphTraits<swift::DominanceInfoNode *> {
201201

202202
template <> struct GraphTraits<const swift::DominanceInfoNode *> {
203203
using ChildIteratorType = swift::DominanceInfoNode::const_iterator;
204-
typedef const swift::DominanceInfoNode *NodeRef;
204+
using NodeRef = const swift::DominanceInfoNode *;
205205

206206
static NodeRef getEntryNode(NodeRef N) { return N; }
207207
static inline ChildIteratorType child_begin(NodeRef N) { return N->begin(); }

include/swift/SIL/PatternMatch.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@ struct OneOf_match;
140140

141141
template <typename T0>
142142
struct OneOf_match<T0> {
143-
typedef T0 Ty;
143+
using Ty = T0;
144144
};
145145

146146
template <typename T0, typename T1>
147147
struct OneOf_match<T0, T1> {
148-
typedef match_combine_or<T0, T1> Ty;
148+
using Ty = match_combine_or<T0, T1>;
149149
};
150150

151151
template <typename T0, typename T1, typename ...Arguments>
152152
struct OneOf_match<T0, T1, Arguments ...> {
153-
typedef typename OneOf_match<match_combine_or<T0, T1>, Arguments ...>::Ty Ty;
153+
using Ty = typename OneOf_match<match_combine_or<T0, T1>, Arguments...>::Ty;
154154
};
155155

156156
/// This is a vararg version of m_CombineOr. It is a boolean "or" of
@@ -584,18 +584,18 @@ struct Apply_match;
584584

585585
template <typename CalleeTy>
586586
struct Apply_match<CalleeTy> {
587-
typedef Callee_match<CalleeTy> Ty;
587+
using Ty = Callee_match<CalleeTy>;
588588
};
589589

590590
template <typename CalleeTy, typename T0>
591591
struct Apply_match<CalleeTy, T0> {
592-
typedef match_combine_and<Callee_match<CalleeTy>, Argument_match<T0>> Ty;
592+
using Ty = match_combine_and<Callee_match<CalleeTy>, Argument_match<T0>>;
593593
};
594594

595595
template <typename CalleeTy, typename T0, typename ...Arguments>
596596
struct Apply_match<CalleeTy, T0, Arguments ...> {
597-
typedef match_combine_and<typename Apply_match<CalleeTy, Arguments ...>::Ty,
598-
Argument_match<T0> > Ty;
597+
using Ty = match_combine_and<typename Apply_match<CalleeTy, Arguments...>::Ty,
598+
Argument_match<T0>>;
599599
};
600600

601601
/// Match only an ApplyInst's Callee.

include/swift/SIL/SILCoverageMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ namespace llvm {
145145
template <>
146146
struct ilist_traits<::swift::SILCoverageMap>
147147
: public ilist_default_traits<::swift::SILCoverageMap> {
148-
typedef ::swift::SILCoverageMap SILCoverageMap;
148+
using SILCoverageMap = ::swift::SILCoverageMap;
149149

150150
public:
151151
static void deleteNode(SILCoverageMap *VT) { VT->~SILCoverageMap(); }

include/swift/SIL/SILDebuggerClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SILBuilder;
2727

2828
class SILDebuggerClient : public DebuggerClient {
2929
public:
30-
typedef SmallVectorImpl<LookupResultEntry> ResultVector;
30+
using ResultVector = SmallVectorImpl<LookupResultEntry>;
3131

3232
SILDebuggerClient(ASTContext &C) : DebuggerClient(C) { }
3333
virtual ~SILDebuggerClient() = default;

include/swift/SIL/SILDeclRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ enum ForDefinition_t : bool {
8080
/// declaration, such as uncurry levels of a function, the allocating and
8181
/// initializing entry points of a constructor, etc.
8282
struct SILDeclRef {
83-
typedef llvm::PointerUnion<ValueDecl *, AbstractClosureExpr *> Loc;
84-
83+
using Loc = llvm::PointerUnion<ValueDecl *, AbstractClosureExpr *>;
84+
8585
/// Represents the "kind" of the SILDeclRef. For some Swift decls there
8686
/// are multiple SIL entry points, and the kind is used to distinguish them.
8787
enum class Kind : unsigned {

include/swift/SIL/SILDefaultWitnessTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ namespace llvm {
174174
template <>
175175
struct ilist_traits<::swift::SILDefaultWitnessTable> :
176176
public ilist_default_traits<::swift::SILDefaultWitnessTable> {
177-
typedef ::swift::SILDefaultWitnessTable SILDefaultWitnessTable;
177+
using SILDefaultWitnessTable = ::swift::SILDefaultWitnessTable;
178178

179179
public:
180180
static void deleteNode(SILDefaultWitnessTable *WT) { WT->~SILDefaultWitnessTable(); }

include/swift/SIL/SILFunction.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class SILSpecializeAttr final {
9797
class SILFunction
9898
: public llvm::ilist_node<SILFunction>, public SILAllocated<SILFunction> {
9999
public:
100-
typedef llvm::iplist<SILBasicBlock> BlockListType;
100+
using BlockListType = llvm::iplist<SILBasicBlock>;
101101

102102
private:
103103
friend class SILBasicBlock;
@@ -694,9 +694,9 @@ class SILFunction
694694
BlockListType &getBlocks() { return BlockList; }
695695
const BlockListType &getBlocks() const { return BlockList; }
696696

697-
typedef BlockListType::iterator iterator;
698-
typedef BlockListType::reverse_iterator reverse_iterator;
699-
typedef BlockListType::const_iterator const_iterator;
697+
using iterator = BlockListType::iterator;
698+
using reverse_iterator = BlockListType::reverse_iterator;
699+
using const_iterator = BlockListType::const_iterator;
700700

701701
bool empty() const { return BlockList.empty(); }
702702
iterator begin() { return BlockList.begin(); }
@@ -881,7 +881,7 @@ namespace llvm {
881881
template <>
882882
struct ilist_traits<::swift::SILFunction> :
883883
public ilist_default_traits<::swift::SILFunction> {
884-
typedef ::swift::SILFunction SILFunction;
884+
using SILFunction = ::swift::SILFunction;
885885

886886
public:
887887
static void deleteNode(SILFunction *V) { V->~SILFunction(); }

include/swift/SIL/SILGlobalVariable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ namespace llvm {
214214
template <>
215215
struct ilist_traits<::swift::SILGlobalVariable> :
216216
public ilist_default_traits<::swift::SILGlobalVariable> {
217-
typedef ::swift::SILGlobalVariable SILGlobalVariable;
217+
using SILGlobalVariable = ::swift::SILGlobalVariable;
218218

219219
public:
220220
static void deleteNode(SILGlobalVariable *V) {}

include/swift/SIL/SILInstruction.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,8 +1081,8 @@ class InstructionBaseWithTrailingOperands
10811081
protected:
10821082
friend llvm::TrailingObjects<Derived, Operand, OtherTrailingTypes...>;
10831083

1084-
typedef llvm::TrailingObjects<Derived, Operand, OtherTrailingTypes...>
1085-
TrailingObjects;
1084+
using TrailingObjects =
1085+
llvm::TrailingObjects<Derived, Operand, OtherTrailingTypes...>;
10861086

10871087
using TrailingObjects::totalSizeToAlloc;
10881088

@@ -1158,8 +1158,9 @@ class UnaryInstructionWithTypeDependentOperandsBase
11581158
friend InstructionBaseWithTrailingOperands<Kind, Derived, Operand,
11591159
OtherTrailingTypes...>;
11601160

1161-
typedef InstructionBaseWithTrailingOperands<
1162-
Kind, Derived, Operand, OtherTrailingTypes...> TrailingObjects;
1161+
using TrailingObjects =
1162+
InstructionBaseWithTrailingOperands<Kind, Derived, Operand,
1163+
OtherTrailingTypes...>;
11631164

11641165
public:
11651166
template <typename... Args>

include/swift/SIL/SILLocation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class SILLocation {
6565
using type = Pattern;
6666
};
6767

68-
typedef llvm::PointerUnion4<Stmt*, Expr*, Decl*, Pattern*> ASTNodeTy;
68+
using ASTNodeTy = llvm::PointerUnion4<Stmt *, Expr *, Decl *, Pattern *>;
6969

7070
public:
7171
enum LocationKind : unsigned {
@@ -419,7 +419,7 @@ class SILLocation {
419419
}
420420

421421
/// Fingerprint a DebugLoc for use in a DenseMap.
422-
typedef std::pair<std::pair<unsigned, unsigned>, StringRef> DebugLocKey;
422+
using DebugLocKey = std::pair<std::pair<unsigned, unsigned>, StringRef>;
423423
struct DebugLocHash : public DebugLocKey {
424424
DebugLocHash(DebugLoc L) : DebugLocKey({{L.Line, L.Column}, L.Filename}) {}
425425
};

include/swift/SIL/SILModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class SILModule {
217217
// Callbacks registered by the SIL optimizer to run on each deserialized
218218
// function body. This is intentionally a stateless type because the
219219
// ModuleDecl and SILFunction should be sufficient context.
220-
typedef void (*SILFunctionBodyCallback)(ModuleDecl *, SILFunction *F);
220+
using SILFunctionBodyCallback = void (*)(ModuleDecl *, SILFunction *F);
221221
SmallVector<SILFunctionBodyCallback, 0> DeserializationCallbacks;
222222

223223
/// The SILLoader used when linking functions into this module.

include/swift/SIL/SILProperty.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace llvm {
7979
template <>
8080
struct ilist_traits<::swift::SILProperty>
8181
: public ilist_default_traits<::swift::SILProperty> {
82-
typedef ::swift::SILProperty SILProperty;
82+
using SILProperty = ::swift::SILProperty;
8383

8484
public:
8585
static void deleteNode(SILProperty *VT) { VT->~SILProperty(); }

include/swift/SIL/SILVTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ namespace llvm {
174174
template <>
175175
struct ilist_traits<::swift::SILVTable> :
176176
public ilist_default_traits<::swift::SILVTable> {
177-
typedef ::swift::SILVTable SILVTable;
177+
using SILVTable = ::swift::SILVTable;
178178

179179
static void deleteNode(SILVTable *VT) { VT->~SILVTable(); }
180180

include/swift/SIL/SILValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ class Operand {
440440
inline SILValue getSILValueType(const Operand &op) {
441441
return op.get();
442442
}
443-
typedef ArrayRefView<Operand,SILValue,getSILValueType> OperandValueArrayRef;
443+
using OperandValueArrayRef = ArrayRefView<Operand, SILValue, getSILValueType>;
444444

445445
/// An iterator over all uses of a ValueBase.
446446
class ValueBaseUseIterator : public std::iterator<std::forward_iterator_tag,
@@ -600,7 +600,7 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SILValue V) {
600600
namespace llvm {
601601
/// A SILValue casts like a ValueBase *.
602602
template<> struct simplify_type<const ::swift::SILValue> {
603-
typedef ::swift::ValueBase *SimpleType;
603+
using SimpleType = ::swift::ValueBase *;
604604
static SimpleType getSimplifiedValue(::swift::SILValue Val) {
605605
return Val;
606606
}

include/swift/SIL/SILWitnessTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ namespace llvm {
318318
template <>
319319
struct ilist_traits<::swift::SILWitnessTable> :
320320
public ilist_default_traits<::swift::SILWitnessTable> {
321-
typedef ::swift::SILWitnessTable SILWitnessTable;
321+
using SILWitnessTable = ::swift::SILWitnessTable;
322322

323323
public:
324324
static void deleteNode(SILWitnessTable *WT) { WT->~SILWitnessTable(); }

include/swift/SIL/TypeLowering.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ class GenericContextScope {
938938

939939
namespace llvm {
940940
template<> struct DenseMapInfo<swift::Lowering::TypeConverter::CachingTypeKey> {
941-
typedef swift::Lowering::TypeConverter::CachingTypeKey CachingTypeKey;
941+
using CachingTypeKey = swift::Lowering::TypeConverter::CachingTypeKey;
942942

943943
using APCachingKey = swift::Lowering::AbstractionPattern::CachingKey;
944944
using CachingKeyInfo = DenseMapInfo<APCachingKey>;
@@ -967,7 +967,7 @@ namespace llvm {
967967
};
968968

969969
template<> struct DenseMapInfo<swift::Lowering::TypeConverter::OverrideKey> {
970-
typedef swift::Lowering::TypeConverter::OverrideKey OverrideKey;
970+
using OverrideKey = swift::Lowering::TypeConverter::OverrideKey;
971971

972972
using SILDeclRefInfo = DenseMapInfo<swift::SILDeclRef>;
973973

include/swift/SIL/TypeSubstCloner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
3434
friend class SILInstructionVisitor<ImplClass>;
3535
friend class SILCloner<ImplClass>;
3636

37-
typedef SILClonerWithScopes<ImplClass> super;
37+
using super = SILClonerWithScopes<ImplClass>;
3838

3939
void postProcess(SILInstruction *Orig, SILInstruction *Cloned) {
4040
llvm_unreachable("Clients need to explicitly call a base class impl!");

0 commit comments

Comments
 (0)