Skip to content

Commit 4ba2303

Browse files
authored
Merge pull request #15706 from ikesyo/sema-using-over-typedef
[gardening][Sema] Replace `typedef` with `using`
2 parents 8e2a0f1 + 3c399de commit 4ba2303

15 files changed

+50
-50
lines changed

include/swift/Sema/IDETypeChecking.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ namespace swift {
147147
bool IsSynthesized;
148148
};
149149

150-
typedef llvm::function_ref<void(ArrayRef<ExtensionInfo>)>
151-
ExtensionGroupOperation;
150+
using ExtensionGroupOperation =
151+
llvm::function_ref<void(ArrayRef<ExtensionInfo>)>;
152152

153153
class SynthesizedExtensionAnalyzer {
154154
struct Implementation;

include/swift/Sema/TypeCheckRequest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class TypeCheckRequest {
105105
public:
106106
// The payload types.
107107
#define TYPE_CHECK_REQUEST_PAYLOAD(PayloadName,...) \
108-
typedef __VA_ARGS__ PayloadName##PayloadType;
108+
using PayloadName##PayloadType = __VA_ARGS__;
109109

110110
#include "swift/Sema/TypeCheckRequestPayloads.def"
111111

@@ -181,7 +181,7 @@ class TypeCheckRequest {
181181
/// A callback used to check whether a particular dependency of this
182182
/// operation has been satisfied. If so, it returns \c false. If not,
183183
/// the dependency will be recorded and this operation returns \c true.
184-
typedef llvm::function_ref<bool(TypeCheckRequest)> UnsatisfiedDependency;
184+
using UnsatisfiedDependency = llvm::function_ref<bool(TypeCheckRequest)>;
185185

186186
// Create requestXXX functions to more easily form type check requests
187187
// of the appropriate type.

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ namespace {
11771177
}
11781178

11791179
/// \brief Describes either a type or the name of a type to be resolved.
1180-
typedef llvm::PointerUnion<Identifier, Type> TypeOrName;
1180+
using TypeOrName = llvm::PointerUnion<Identifier, Type>;
11811181

11821182
/// \brief Convert the given literal expression via a protocol pair.
11831183
///

lib/Sema/CSDiag.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ enum TCCFlags {
795795
TCC_AllowUnresolvedTypeVariables = 0x04
796796
};
797797

798-
typedef OptionSet<TCCFlags> TCCOptions;
798+
using TCCOptions = OptionSet<TCCFlags>;
799799

800800
inline TCCOptions operator|(TCCFlags flag1, TCCFlags flag2) {
801801
return TCCOptions(flag1) | flag2;
@@ -1054,7 +1054,7 @@ bool FailureDiagnosis::diagnoseConstraintFailure() {
10541054
};
10551055

10561056
// Start out by classifying all the constraints.
1057-
typedef std::pair<Constraint*, ConstraintRanking> RCElt;
1057+
using RCElt = std::pair<Constraint *, ConstraintRanking>;
10581058
std::vector<RCElt> rankedConstraints;
10591059

10601060
// This is a predicate that classifies constraints according to our

lib/Sema/CSSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ void ConstraintSystem::Candidate::applySolutions(
984984
}
985985

986986
void ConstraintSystem::shrink(Expr *expr) {
987-
typedef llvm::SmallDenseMap<Expr *, ArrayRef<ValueDecl *>> DomainMap;
987+
using DomainMap = llvm::SmallDenseMap<Expr *, ArrayRef<ValueDecl *>>;
988988

989989
// A collection of original domains of all of the expressions,
990990
// so they can be restored in case of failure.

lib/Sema/CalleeCandidateInfo.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ namespace swift {
176176
CalleeCandidateInfo(Type baseType, ArrayRef<OverloadChoice> candidates,
177177
bool hasTrailingClosure, ConstraintSystem &CS,
178178
bool selfAlreadyApplied = true);
179-
180-
typedef std::pair<CandidateCloseness, FailedArgumentInfo> ClosenessResultTy;
181-
typedef const std::function<ClosenessResultTy(UncurriedCandidate)>
182-
&ClosenessPredicate;
183-
179+
180+
using ClosenessResultTy = std::pair<CandidateCloseness, FailedArgumentInfo>;
181+
using ClosenessPredicate =
182+
const std::function<ClosenessResultTy(UncurriedCandidate)> &;
183+
184184
/// After the candidate list is formed, it can be filtered down to discard
185185
/// obviously mismatching candidates and compute a "closeness" for the
186186
/// resultant set.

lib/Sema/Constraint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ namespace llvm {
704704
template<>
705705
struct ilist_traits<swift::constraints::Constraint>
706706
: public ilist_default_traits<swift::constraints::Constraint> {
707-
typedef swift::constraints::Constraint Element;
707+
using Element = swift::constraints::Constraint;
708708

709709
static Element *createNode(const Element &V) = delete;
710710
static void deleteNode(Element *V) { /* never deleted */ }

lib/Sema/ConstraintLocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
530530
friend class ConstraintSystem;
531531
};
532532

533-
typedef ConstraintLocator::PathElement LocatorPathElt;
533+
using LocatorPathElt = ConstraintLocator::PathElement;
534534

535535
/// \brief A simple stack-only builder object that constructs a
536536
/// constraint locator without allocating memory.

lib/Sema/ConstraintSystem.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class SavedTypeVariableBinding {
8484
};
8585

8686
/// \brief A set of saved type variable bindings.
87-
typedef SmallVector<SavedTypeVariableBinding, 16> SavedTypeVariableBindings;
87+
using SavedTypeVariableBindings = SmallVector<SavedTypeVariableBinding, 16>;
8888

8989
class ConstraintLocator;
9090

@@ -547,9 +547,10 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &out, const Score &score);
547547

548548
/// Describes a dependent type that has been opened to a particular type
549549
/// variable.
550-
typedef std::pair<GenericTypeParamType *, TypeVariableType *> OpenedType;
550+
using OpenedType = std::pair<GenericTypeParamType *, TypeVariableType *>;
551551

552-
typedef llvm::DenseMap<GenericTypeParamType *, TypeVariableType *> OpenedTypeMap;
552+
using OpenedTypeMap =
553+
llvm::DenseMap<GenericTypeParamType *, TypeVariableType *>;
553554

554555
/// \brief A complete solution to a constraint system.
555556
///
@@ -789,7 +790,7 @@ struct SpecificConstraint {
789790
};
790791

791792
/// An intrusive, doubly-linked list of constraints.
792-
typedef llvm::ilist<Constraint> ConstraintList;
793+
using ConstraintList = llvm::ilist<Constraint>;
793794

794795
enum class ConstraintSystemFlags {
795796
/// Whether we allow the solver to attempt fixes to the system.
@@ -805,7 +806,7 @@ enum class ConstraintSystemFlags {
805806
};
806807

807808
/// Options that affect the constraint system as a whole.
808-
typedef OptionSet<ConstraintSystemFlags> ConstraintSystemOptions;
809+
using ConstraintSystemOptions = OptionSet<ConstraintSystemFlags>;
809810

810811
/// This struct represents the results of a member lookup of
811812
struct MemberLookupResult {
@@ -1942,7 +1943,7 @@ class ConstraintSystem {
19421943
};
19431944

19441945
/// Options that govern how type matching should proceed.
1945-
typedef OptionSet<TypeMatchFlags> TypeMatchOptions;
1946+
using TypeMatchOptions = OptionSet<TypeMatchFlags>;
19461947

19471948
/// \brief Retrieve the fixed type corresponding to the given type variable,
19481949
/// or a null type if there is no fixed type.
@@ -2197,7 +2198,7 @@ class ConstraintSystem {
21972198
template <typename It>
21982199
ArrayRef<typename std::iterator_traits<It>::value_type>
21992200
allocateCopy(It start, It end) {
2200-
typedef typename std::iterator_traits<It>::value_type T;
2201+
using T = typename std::iterator_traits<It>::value_type;
22012202
T *result = (T*)getAllocator().Allocate(sizeof(T)*(end-start), alignof(T));
22022203
unsigned i;
22032204
for (i = 0; start != end; ++start, ++i)
@@ -2714,8 +2715,8 @@ class ConstraintSystem {
27142715
};
27152716

27162717
struct PotentialBindings {
2717-
typedef std::tuple<bool, bool, bool, bool, unsigned char, unsigned int>
2718-
BindingScore;
2718+
using BindingScore =
2719+
std::tuple<bool, bool, bool, bool, unsigned char, unsigned int>;
27192720

27202721
TypeVariableType *TypeVar;
27212722

@@ -3136,7 +3137,7 @@ static inline bool computeTupleShuffle(TupleType *fromTuple,
31363137
/// Describes the arguments to which a parameter binds.
31373138
/// FIXME: This is an awful data structure. We want the equivalent of a
31383139
/// TinyPtrVector for unsigned values.
3139-
typedef SmallVector<unsigned, 1> ParamBinding;
3140+
using ParamBinding = SmallVector<unsigned, 1>;
31403141

31413142
/// Class used as the base for listeners to the \c matchCallArguments process.
31423143
///

lib/Sema/OverloadChoice.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ class OverloadChoice {
8585

8686
/// We mash together OverloadChoiceKind with tuple indices into a single
8787
/// integer representation.
88-
typedef llvm::PointerEmbeddedInt<uint32_t, 29>
89-
OverloadChoiceKindWithTupleIndex;
90-
88+
using OverloadChoiceKindWithTupleIndex =
89+
llvm::PointerEmbeddedInt<uint32_t, 29>;
90+
9191
/// Depending on the OverloadChoiceKind, this could be one of two cases:
9292
/// 1) A ValueDecl for the cases that match to a Decl. The exactly kind of
9393
/// decl reference is disambiguated with the DeclKind bits in

lib/Sema/PlaygroundTransform.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Instrumenter : InstrumenterBase {
5252
BracePair(const SourceRange &BR) : BraceRange(BR) {}
5353
};
5454

55-
typedef std::forward_list<BracePair> BracePairStack;
55+
using BracePairStack = std::forward_list<BracePair>;
5656

5757
BracePairStack BracePairs;
5858
class BracePairPusher {
@@ -95,7 +95,7 @@ class Instrumenter : InstrumenterBase {
9595
}
9696
};
9797

98-
typedef SmallVector<swift::ASTNode, 3> ElementVector;
98+
using ElementVector = SmallVector<swift::ASTNode, 3>;
9999

100100
// Before a "return," "continue" or similar statement, emit pops of
101101
// all the braces up to its target.
@@ -370,7 +370,7 @@ class Instrumenter : InstrumenterBase {
370370

371371
BraceStmt *transformBraceStmt(BraceStmt *BS, bool TopLevel = false) override {
372372
ArrayRef<ASTNode> OriginalElements = BS->getElements();
373-
typedef SmallVector<swift::ASTNode, 3> ElementVector;
373+
using ElementVector = SmallVector<swift::ASTNode, 3>;
374374
ElementVector Elements(OriginalElements.begin(), OriginalElements.end());
375375

376376
SourceRange SR = BS->getSourceRange();

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ class InnermostAncestorFinder : private ASTWalker {
736736

737737
/// The type of a match predicate, which takes as input a node and its
738738
/// parent and returns a bool indicating whether the node matches.
739-
typedef std::function<bool(ASTNode, ASTWalker::ParentTy)> MatchPredicate;
739+
using MatchPredicate = std::function<bool(ASTNode, ASTWalker::ParentTy)>;
740740

741741
private:
742742
const SourceRange TargetRange;

lib/Sema/TypeCheckProtocol.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,12 @@ struct InferredAssociatedTypesByWitness {
115115

116116
/// The set of witnesses that were considered when attempting to
117117
/// infer associated types.
118-
typedef SmallVector<InferredAssociatedTypesByWitness, 2>
119-
InferredAssociatedTypesByWitnesses;
118+
using InferredAssociatedTypesByWitnesses =
119+
SmallVector<InferredAssociatedTypesByWitness, 2>;
120120

121121
/// A mapping from requirements to the set of matches with witnesses.
122-
typedef SmallVector<std::pair<ValueDecl *,
123-
InferredAssociatedTypesByWitnesses>, 4>
124-
InferredAssociatedTypes;
122+
using InferredAssociatedTypes =
123+
SmallVector<std::pair<ValueDecl *, InferredAssociatedTypesByWitnesses>, 4>;
125124

126125
/// A potential solution to the set of inferred type witnesses.
127126
struct InferredTypeWitnessesSolution {
@@ -816,8 +815,8 @@ class AssociatedTypeInference {
816815
public:
817816
/// Describes a mapping from associated type declarations to their
818817
/// type witnesses (as interface types).
819-
typedef std::vector<std::pair<AssociatedTypeDecl *, Type>>
820-
InferredTypeWitnesses;
818+
using InferredTypeWitnesses =
819+
std::vector<std::pair<AssociatedTypeDecl *, Type>>;
821820

822821
/// Perform associated type inference.
823822
///

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ void AssociatedTypeInference::findSolutionsRec(
11851185
unsigned numTypeWitnesses,
11861186
unsigned numValueWitnessesInProtocolExtensions,
11871187
unsigned reqDepth) {
1188-
typedef decltype(typeWitnesses)::ScopeTy TypeWitnessesScope;
1188+
using TypeWitnessesScope = decltype(typeWitnesses)::ScopeTy;
11891189

11901190
// If we hit the last requirement, record and check this solution.
11911191
if (reqDepth == inferred.size()) {

lib/Sema/TypeChecker.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ namespace constraints {
5353

5454
/// \brief A mapping from substitutable types to the protocol-conformance
5555
/// mappings for those types.
56-
typedef llvm::DenseMap<SubstitutableType *,
57-
SmallVector<ProtocolConformance *, 2>> ConformanceMap;
56+
using ConformanceMap =
57+
llvm::DenseMap<SubstitutableType *, SmallVector<ProtocolConformance *, 2>>;
5858

5959
/// \brief Used for recursive lookups into an expr that is already
6060
/// being type-checked and the constraint system in which its type is
6161
/// stored.
62-
typedef std::pair<Expr *,
63-
constraints::ConstraintSystem *> ExprAndConstraintSystem;
62+
using ExprAndConstraintSystem =
63+
std::pair<Expr *, constraints::ConstraintSystem *>;
6464

6565
/// Special-case type checking semantics for certain declarations.
6666
enum class DeclTypeCheckingSemantics {
@@ -93,7 +93,7 @@ class LookupResult {
9393
LookupResult(const SmallVectorImpl<LookupResultEntry> &Results)
9494
: Results(Results.begin(), Results.end()) {}
9595

96-
typedef SmallVectorImpl<LookupResultEntry>::iterator iterator;
96+
using iterator = SmallVectorImpl<LookupResultEntry>::iterator;
9797
iterator begin() { return Results.begin(); }
9898
iterator end() { return Results.end(); }
9999
unsigned size() const { return Results.size(); }
@@ -135,7 +135,7 @@ class LookupTypeResult {
135135
friend class TypeChecker;
136136

137137
public:
138-
typedef SmallVectorImpl<std::pair<TypeDecl *, Type>>::iterator iterator;
138+
using iterator = SmallVectorImpl<std::pair<TypeDecl *, Type>>::iterator;
139139
iterator begin() { return Results.begin(); }
140140
iterator end() { return Results.end(); }
141141
unsigned size() const { return Results.size(); }
@@ -232,7 +232,7 @@ enum class TypeCheckExprFlags {
232232
SkipApplyingSolution = 0x100,
233233
};
234234

235-
typedef OptionSet<TypeCheckExprFlags> TypeCheckExprOptions;
235+
using TypeCheckExprOptions = OptionSet<TypeCheckExprFlags>;
236236

237237
inline TypeCheckExprOptions operator|(TypeCheckExprFlags flag1,
238238
TypeCheckExprFlags flag2) {
@@ -262,7 +262,7 @@ enum class NameLookupFlags {
262262
};
263263

264264
/// A set of options that control name lookup.
265-
typedef OptionSet<NameLookupFlags> NameLookupOptions;
265+
using NameLookupOptions = OptionSet<NameLookupFlags>;
266266

267267
inline NameLookupOptions operator|(NameLookupFlags flag1,
268268
NameLookupFlags flag2) {
@@ -545,7 +545,7 @@ enum class TypeResolutionFlags : unsigned {
545545
};
546546

547547
/// Option set describing how type resolution should work.
548-
typedef OptionSet<TypeResolutionFlags> TypeResolutionOptions;
548+
using TypeResolutionOptions = OptionSet<TypeResolutionFlags>;
549549

550550
/// Strip the contextual options from the given type resolution options.
551551
static inline TypeResolutionOptions
@@ -677,7 +677,7 @@ enum class ConformanceCheckFlags {
677677
};
678678

679679
/// Options that control protocol conformance checking.
680-
typedef OptionSet<ConformanceCheckFlags> ConformanceCheckOptions;
680+
using ConformanceCheckOptions = OptionSet<ConformanceCheckFlags>;
681681

682682
inline ConformanceCheckOptions operator|(ConformanceCheckFlags lhs,
683683
ConformanceCheckFlags rhs) {

0 commit comments

Comments
 (0)