Skip to content

Commit 08644c1

Browse files
committed
[gardening][IRGen] Replace typedef with using
1 parent 69099a8 commit 08644c1

22 files changed

+50
-42
lines changed

include/swift/IRGen/Linking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ class LinkInfo {
855855

856856
/// Allow LinkEntity to be used as a key for a DenseMap.
857857
template <> struct llvm::DenseMapInfo<swift::irgen::LinkEntity> {
858-
typedef swift::irgen::LinkEntity LinkEntity;
858+
using LinkEntity = swift::irgen::LinkEntity;
859859
static LinkEntity getEmptyKey() {
860860
LinkEntity entity;
861861
entity.Pointer = nullptr;

lib/IRGen/ClassMetadataVisitor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class IRGenModule;
3535
template <class Impl> class ClassMetadataVisitor
3636
: public NominalMetadataVisitor<Impl>,
3737
public SILVTableVisitor<Impl> {
38-
typedef NominalMetadataVisitor<Impl> super;
38+
using super = NominalMetadataVisitor<Impl>;
3939

4040
protected:
4141
using super::IGM;
@@ -157,7 +157,8 @@ template <class Impl> class ClassMetadataVisitor
157157
/// the metadata layout, maintaining the offset of the next field.
158158
template <class Impl>
159159
class ClassMetadataScanner : public ClassMetadataVisitor<Impl> {
160-
typedef ClassMetadataVisitor<Impl> super;
160+
using super = ClassMetadataVisitor<Impl>;
161+
161162
protected:
162163
Size NextOffset = Size(0);
163164

lib/IRGen/EnumMetadataVisitor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ template <class Impl> class EnumMetadataVisitor
7070
/// pointer-sized chunks) into the metadata for the next field.
7171
template <class Impl>
7272
class EnumMetadataScanner : public EnumMetadataVisitor<Impl> {
73-
typedef EnumMetadataVisitor<Impl> super;
73+
using super = EnumMetadataVisitor<Impl>;
74+
7475
protected:
7576
Size NextOffset = Size(0);
7677

lib/IRGen/Explosion.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ class Explosion {
7373
return Values.size() - NextValue;
7474
}
7575

76-
typedef SmallVector<llvm::Value*, 8>::iterator iterator;
76+
using iterator = SmallVector<llvm::Value *, 8>::iterator;
7777
iterator begin() { return Values.begin() + NextValue; }
7878
iterator end() { return Values.end(); }
7979

80-
typedef SmallVector<llvm::Value*, 8>::const_iterator const_iterator;
80+
using const_iterator = SmallVector<llvm::Value *, 8>::const_iterator;
8181
const_iterator begin() const { return Values.begin() + NextValue; }
8282
const_iterator end() const { return Values.end(); }
8383

@@ -233,9 +233,9 @@ class ExplosionSchema {
233233
return Elements[index];
234234
}
235235

236-
typedef SmallVectorImpl<Element>::iterator iterator;
237-
typedef SmallVectorImpl<Element>::const_iterator const_iterator;
238-
236+
using iterator = SmallVectorImpl<Element>::iterator;
237+
using const_iterator = SmallVectorImpl<Element>::const_iterator;
238+
239239
iterator begin() { return Elements.begin(); }
240240
iterator end() { return Elements.end(); }
241241
const_iterator begin() const { return Elements.begin(); }

lib/IRGen/ForeignClassMetadataVisitor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class ForeignClassMetadataVisitor
5858
/// the metadata layout, maintaining the offset of the next field.
5959
template <class Impl>
6060
class ForeignClassMetadataScanner : public ForeignClassMetadataVisitor<Impl> {
61-
typedef ForeignClassMetadataVisitor<Impl> super;
61+
using super = ForeignClassMetadataVisitor<Impl>;
62+
6263
protected:
6364
Size NextOffset = Size(0);
6465

lib/IRGen/GenClass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ void IRGenModule::emitClassDecl(ClassDecl *D) {
10381038
}
10391039

10401040
namespace {
1041-
typedef std::pair<ClassDecl*, ModuleDecl*> CategoryNameKey;
1041+
using CategoryNameKey = std::pair<ClassDecl*, ModuleDecl*>;
10421042
/// Used to provide unique names to ObjC categories generated by Swift
10431043
/// extensions. The first category for a class in a module gets the module's
10441044
/// name as its key, e.g., NSObject (MySwiftModule). Another extension of the

lib/IRGen/GenClass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace irgen {
9292
Address emitTailProjection(IRGenFunction &IGF, llvm::Value *Base,
9393
SILType ClassType, SILType TailType);
9494

95-
typedef llvm::ArrayRef<std::pair<SILType, llvm::Value *>> TailArraysRef;
95+
using TailArraysRef = llvm::ArrayRef<std::pair<SILType, llvm::Value *>>;
9696

9797
/// Adds the size for tail allocated arrays to \p size and returns the new
9898
/// size value. Also updades the alignment mask to represent the alignment of

lib/IRGen/GenMeta.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ namespace {
10781078
/// generic metadata layout class.
10791079
template <class Impl, class Base>
10801080
class GenericMetadataBuilderBase : public Base {
1081-
typedef Base super;
1081+
using super = Base;
10821082

10831083
struct FillOp {
10841084
CanType Type;
@@ -2159,7 +2159,7 @@ namespace {
21592159
ClassMetadataBuilderBase<GenericClassMetadataBuilder,
21602160
ResilientClassMemberBuilder>>
21612161
{
2162-
typedef GenericMetadataBuilderBase super;
2162+
using super = GenericMetadataBuilderBase;
21632163

21642164
Optional<ConstantAggregateBuilderBase::PlaceholderPosition>
21652165
ClassRODataOffset, MetaclassObjectOffset, MetaclassRODataOffset;
@@ -2684,8 +2684,8 @@ namespace {
26842684
public GenericValueMetadataBuilderBase<GenericStructMetadataBuilder,
26852685
StructMetadataBuilderBase<GenericStructMetadataBuilder>> {
26862686

2687-
typedef GenericValueMetadataBuilderBase super;
2688-
2687+
using super = GenericValueMetadataBuilderBase;
2688+
26892689
public:
26902690
GenericStructMetadataBuilder(IRGenModule &IGM, StructDecl *theStruct,
26912691
ConstantStructBuilder &B)
@@ -3048,8 +3048,8 @@ namespace {
30483048
/// the first-used instance as the canonical instance for a process.
30493049
template<typename Impl, typename Base>
30503050
class ForeignMetadataBuilderBase : public Base {
3051-
typedef Base super;
3052-
3051+
using super = Base;
3052+
30533053
protected:
30543054
using super::IGM;
30553055
using super::asImpl;

lib/IRGen/GenRecord.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class RecordTypeInfoImpl : public Base,
100100
friend class llvm::TrailingObjects<Impl, FieldImpl_>;
101101

102102
public:
103-
typedef FieldImpl_ FieldImpl;
103+
using FieldImpl = FieldImpl_;
104104

105105
private:
106106
const unsigned NumFields;
@@ -298,7 +298,7 @@ template <class Impl, class Base, class FieldImpl>
298298
class RecordTypeInfo<Impl, Base, FieldImpl,
299299
/*IsFixedSize*/ false, /*IsLoadable*/ false>
300300
: public RecordTypeInfoImpl<Impl, Base, FieldImpl> {
301-
typedef RecordTypeInfoImpl<Impl, Base, FieldImpl> super;
301+
using super = RecordTypeInfoImpl<Impl, Base, FieldImpl>;
302302

303303
/// The index+1 of the unique non-empty field, or zero if there is none.
304304
unsigned UniqueNonEmptyFieldIndexPlusOne;
@@ -378,7 +378,8 @@ template <class Impl, class Base, class FieldImpl>
378378
class RecordTypeInfo<Impl, Base, FieldImpl,
379379
/*IsFixedSize*/ true, /*IsLoadable*/ false>
380380
: public RecordTypeInfoImpl<Impl, Base, FieldImpl> {
381-
typedef RecordTypeInfoImpl<Impl, Base, FieldImpl> super;
381+
using super = RecordTypeInfoImpl<Impl, Base, FieldImpl>;
382+
382383
protected:
383384
template <class... As>
384385
RecordTypeInfo(As&&...args) : super(std::forward<As>(args)...) {}
@@ -389,7 +390,7 @@ template <class Impl, class Base, class FieldImpl>
389390
class RecordTypeInfo<Impl, Base, FieldImpl,
390391
/*IsFixedSize*/ true, /*IsLoadable*/ true>
391392
: public RecordTypeInfoImpl<Impl, Base, FieldImpl> {
392-
typedef RecordTypeInfoImpl<Impl, Base, FieldImpl> super;
393+
using super = RecordTypeInfoImpl<Impl, Base, FieldImpl>;
393394

394395
unsigned ExplosionSize : 16;
395396

lib/IRGen/GenStruct.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ namespace {
107107
template <class Impl, class Base, class FieldInfoType = StructFieldInfo>
108108
class StructTypeInfoBase :
109109
public RecordTypeInfo<Impl, Base, FieldInfoType> {
110-
typedef RecordTypeInfo<Impl, Base, FieldInfoType> super;
110+
using super = RecordTypeInfo<Impl, Base, FieldInfoType>;
111111

112112
protected:
113113
template <class... As>

lib/IRGen/GenTuple.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace {
9292
template <class Impl, class Base>
9393
class TupleTypeInfoBase
9494
: public RecordTypeInfo<Impl, Base, TupleFieldInfo> {
95-
typedef RecordTypeInfo<Impl, Base, TupleFieldInfo> super;
95+
using super = RecordTypeInfo<Impl, Base, TupleFieldInfo>;
9696

9797
protected:
9898
template <class... As>

lib/IRGen/GenType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace irgen {
6060
class WeakTypeInfo;
6161

6262
/// Either a type or a forward-declaration.
63-
typedef llvm::PointerUnion<const TypeInfo*, llvm::Type*> TypeCacheEntry;
63+
using TypeCacheEntry = llvm::PointerUnion<const TypeInfo *, llvm::Type *>;
6464

6565
/// The helper class for generating types.
6666
class TypeConverter {

lib/IRGen/GenValueWitness.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ namespace {
118118
/// An implementation of DynamicPackingPHIMapping for Addresses.
119119
template <> class DynamicPackingPHIMapping<Address>
120120
: private DynamicPackingPHIMapping<llvm::Value*> {
121-
typedef DynamicPackingPHIMapping<llvm::Value*> super;
121+
using super = DynamicPackingPHIMapping<llvm::Value *>;
122+
122123
public:
123124
void collect(IRGenFunction &IGF, Address value) {
124125
super::collect(IGF, value.getAddress());

lib/IRGen/HeapTypeInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ enum class IsaEncoding : uint8_t {
5353
/// ReferenceCounting getReferenceCounting() const;
5454
template <class Impl>
5555
class HeapTypeInfo : public SingleScalarTypeInfo<Impl, ReferenceTypeInfo> {
56-
typedef SingleScalarTypeInfo<Impl, ReferenceTypeInfo> super;
56+
using super = SingleScalarTypeInfo<Impl, ReferenceTypeInfo>;
57+
5758
protected:
5859
using super::asDerived;
5960
public:

lib/IRGen/IRBuilder.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ namespace irgen {
2929
class FunctionPointer;
3030
class IRGenModule;
3131

32-
typedef llvm::IRBuilder<> IRBuilderBase;
32+
using IRBuilderBase = llvm::IRBuilder<>;
3333

3434
class IRBuilder : public IRBuilderBase {
3535
public:
3636
// Without this, it keeps resolving to llvm::IRBuilderBase because
3737
// of the injected class name.
38-
typedef irgen::IRBuilderBase IRBuilderBase;
38+
using IRBuilderBase = irgen::IRBuilderBase;
3939

4040
private:
4141
/// The block containing the insertion point when the insertion
@@ -115,7 +115,7 @@ class IRBuilder : public IRBuilderBase {
115115
class StableIP {
116116
/// Either an instruction that we're inserting after or the basic
117117
/// block that we're inserting at the beginning of.
118-
typedef llvm::PointerUnion<llvm::Instruction*, llvm::BasicBlock*> UnionTy;
118+
using UnionTy = llvm::PointerUnion<llvm::Instruction *, llvm::BasicBlock *>;
119119
UnionTy After;
120120
public:
121121
StableIP() = default;
@@ -400,7 +400,8 @@ class IRBuilder : public IRBuilderBase {
400400

401401
namespace llvm {
402402
template <> struct PointerLikeTypeTraits<swift::irgen::IRBuilder::StableIP> {
403-
typedef swift::irgen::IRBuilder::StableIP type;
403+
using type = swift::irgen::IRBuilder::StableIP;
404+
404405
public:
405406
static void *getAsVoidPointer(type IP) {
406407
return IP.getOpaqueValue();

lib/IRGen/IRGen.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ inline bool operator<=(OperationCost l, OperationCost r) {
293293
/// An alignment value, in eight-bit units.
294294
class Alignment {
295295
public:
296-
typedef uint32_t int_type;
296+
using int_type = uint32_t;
297297

298298
constexpr Alignment() : Value(0) {}
299299
constexpr explicit Alignment(int_type Value) : Value(Value) {}
@@ -334,7 +334,7 @@ class Alignment {
334334
/// A size value, in eight-bit units.
335335
class Size {
336336
public:
337-
typedef uint64_t int_type;
337+
using int_type = uint64_t;
338338

339339
constexpr Size() : Value(0) {}
340340
explicit constexpr Size(int_type Value) : Value(Value) {}

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ using namespace swift;
5959
using namespace irgen;
6060

6161
namespace {
62-
typedef llvm::DenseMap<const llvm::MDString *, llvm::TrackingMDNodeRef>
63-
TrackingDIRefMap;
62+
using TrackingDIRefMap =
63+
llvm::DenseMap<const llvm::MDString *, llvm::TrackingMDNodeRef>;
6464

6565
class IRGenDebugInfoImpl : public IRGenDebugInfo {
6666
friend class IRGenDebugInfoImpl;
@@ -71,7 +71,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
7171
IRGenModule &IGM;
7272

7373
/// Used for caching SILDebugScopes without inline information.
74-
typedef std::pair<const void *, const void *> LocalScopeHash;
74+
using LocalScopeHash = std::pair<const void *, const void *>;
7575
struct LocalScope : public LocalScopeHash {
7676
LocalScope(const SILDebugScope *DS)
7777
: LocalScopeHash({DS->Loc.getOpaquePointerValue(),

lib/IRGen/IRGenModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ class IRGenModule {
808808
llvm::Constant *getOrCreateReleaseFunction(const TypeInfo &objectTI, Type t,
809809
llvm::Type *llvmType);
810810

811-
typedef llvm::Constant *(IRGenModule::*OutlinedCopyAddrFunction)(
811+
using OutlinedCopyAddrFunction = llvm::Constant *(IRGenModule::*)(
812812
const TypeInfo &objectTI, llvm::Type *llvmType, SILType addrTy,
813813
const llvm::MapVector<CanType, llvm::Value *> *typeToMetadataVec);
814814

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ class IRGenSILFunction :
380380
/// With closure captures it is actually possible to have two function
381381
/// arguments that both have the same name. Until this is fixed, we need to
382382
/// also hash the ArgNo here.
383-
typedef std::pair<unsigned, std::pair<const SILDebugScope *, StringRef>>
384-
StackSlotKey;
383+
using StackSlotKey =
384+
std::pair<unsigned, std::pair<const SILDebugScope *, StringRef>>;
385385
/// Keeps track of the mapping of source variables to -O0 shadow copy allocas.
386386
llvm::SmallDenseMap<StackSlotKey, Address, 8> ShadowStackSlots;
387387
llvm::SmallDenseMap<Decl *, SmallString<4>, 8> AnonymousVariables;

lib/IRGen/NonFixedTypeInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void emitStoreEnumTagSinglePayload(IRGenFunction &IGF, llvm::Value *whichCase,
4646
template <class Impl>
4747
class WitnessSizedTypeInfo : public IndirectTypeInfo<Impl, TypeInfo> {
4848
private:
49-
typedef IndirectTypeInfo<Impl, TypeInfo> super;
49+
using super = IndirectTypeInfo<Impl, TypeInfo>;
5050

5151
protected:
5252
const Impl &asImpl() const { return static_cast<const Impl &>(*this); }

lib/IRGen/StructLayout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ enum class LayoutKind {
6060
class NonFixedOffsetsImpl;
6161

6262
/// The type to pass around for non-fixed offsets.
63-
typedef Optional<NonFixedOffsetsImpl*> NonFixedOffsets;
63+
using NonFixedOffsets = Optional<NonFixedOffsetsImpl *>;
6464

6565
/// An abstract class for determining non-fixed offsets.
6666
class NonFixedOffsetsImpl {

lib/IRGen/StructMetadataVisitor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ template <class Impl> class StructMetadataVisitor
6969
/// the metadata layout, maintaining the offset of the next field.
7070
template <class Impl>
7171
class StructMetadataScanner : public StructMetadataVisitor<Impl> {
72-
typedef StructMetadataVisitor<Impl> super;
72+
using super = StructMetadataVisitor<Impl>;
73+
7374
protected:
7475
Size NextOffset = Size(0);
7576

0 commit comments

Comments
 (0)