Skip to content

[gardening][Sema] Replace typedef with using #15706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/Sema/IDETypeChecking.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ namespace swift {
bool IsSynthesized;
};

typedef llvm::function_ref<void(ArrayRef<ExtensionInfo>)>
ExtensionGroupOperation;
using ExtensionGroupOperation =
llvm::function_ref<void(ArrayRef<ExtensionInfo>)>;

class SynthesizedExtensionAnalyzer {
struct Implementation;
Expand Down
4 changes: 2 additions & 2 deletions include/swift/Sema/TypeCheckRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class TypeCheckRequest {
public:
// The payload types.
#define TYPE_CHECK_REQUEST_PAYLOAD(PayloadName,...) \
typedef __VA_ARGS__ PayloadName##PayloadType;
using PayloadName##PayloadType = __VA_ARGS__;

#include "swift/Sema/TypeCheckRequestPayloads.def"

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

// Create requestXXX functions to more easily form type check requests
// of the appropriate type.
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ namespace {
}

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

/// \brief Convert the given literal expression via a protocol pair.
///
Expand Down
4 changes: 2 additions & 2 deletions lib/Sema/CSDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ enum TCCFlags {
TCC_AllowUnresolvedTypeVariables = 0x04
};

typedef OptionSet<TCCFlags> TCCOptions;
using TCCOptions = OptionSet<TCCFlags>;

inline TCCOptions operator|(TCCFlags flag1, TCCFlags flag2) {
return TCCOptions(flag1) | flag2;
Expand Down Expand Up @@ -1054,7 +1054,7 @@ bool FailureDiagnosis::diagnoseConstraintFailure() {
};

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

// This is a predicate that classifies constraints according to our
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/CSSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ void ConstraintSystem::Candidate::applySolutions(
}

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

// A collection of original domains of all of the expressions,
// so they can be restored in case of failure.
Expand Down
10 changes: 5 additions & 5 deletions lib/Sema/CalleeCandidateInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ namespace swift {
CalleeCandidateInfo(Type baseType, ArrayRef<OverloadChoice> candidates,
bool hasTrailingClosure, ConstraintSystem &CS,
bool selfAlreadyApplied = true);
typedef std::pair<CandidateCloseness, FailedArgumentInfo> ClosenessResultTy;
typedef const std::function<ClosenessResultTy(UncurriedCandidate)>
&ClosenessPredicate;

using ClosenessResultTy = std::pair<CandidateCloseness, FailedArgumentInfo>;
using ClosenessPredicate =
const std::function<ClosenessResultTy(UncurriedCandidate)> &;

/// After the candidate list is formed, it can be filtered down to discard
/// obviously mismatching candidates and compute a "closeness" for the
/// resultant set.
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/Constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ namespace llvm {
template<>
struct ilist_traits<swift::constraints::Constraint>
: public ilist_default_traits<swift::constraints::Constraint> {
typedef swift::constraints::Constraint Element;
using Element = swift::constraints::Constraint;

static Element *createNode(const Element &V) = delete;
static void deleteNode(Element *V) { /* never deleted */ }
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/ConstraintLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
friend class ConstraintSystem;
};

typedef ConstraintLocator::PathElement LocatorPathElt;
using LocatorPathElt = ConstraintLocator::PathElement;

/// \brief A simple stack-only builder object that constructs a
/// constraint locator without allocating memory.
Expand Down
21 changes: 11 additions & 10 deletions lib/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SavedTypeVariableBinding {
};

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

class ConstraintLocator;

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

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

typedef llvm::DenseMap<GenericTypeParamType *, TypeVariableType *> OpenedTypeMap;
using OpenedTypeMap =
llvm::DenseMap<GenericTypeParamType *, TypeVariableType *>;

/// \brief A complete solution to a constraint system.
///
Expand Down Expand Up @@ -789,7 +790,7 @@ struct SpecificConstraint {
};

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

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

/// Options that affect the constraint system as a whole.
typedef OptionSet<ConstraintSystemFlags> ConstraintSystemOptions;
using ConstraintSystemOptions = OptionSet<ConstraintSystemFlags>;

/// This struct represents the results of a member lookup of
struct MemberLookupResult {
Expand Down Expand Up @@ -1942,7 +1943,7 @@ class ConstraintSystem {
};

/// Options that govern how type matching should proceed.
typedef OptionSet<TypeMatchFlags> TypeMatchOptions;
using TypeMatchOptions = OptionSet<TypeMatchFlags>;

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

struct PotentialBindings {
typedef std::tuple<bool, bool, bool, bool, unsigned char, unsigned int>
BindingScore;
using BindingScore =
std::tuple<bool, bool, bool, bool, unsigned char, unsigned int>;

TypeVariableType *TypeVar;

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

/// Class used as the base for listeners to the \c matchCallArguments process.
///
Expand Down
6 changes: 3 additions & 3 deletions lib/Sema/OverloadChoice.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class OverloadChoice {

/// We mash together OverloadChoiceKind with tuple indices into a single
/// integer representation.
typedef llvm::PointerEmbeddedInt<uint32_t, 29>
OverloadChoiceKindWithTupleIndex;
using OverloadChoiceKindWithTupleIndex =
llvm::PointerEmbeddedInt<uint32_t, 29>;

/// Depending on the OverloadChoiceKind, this could be one of two cases:
/// 1) A ValueDecl for the cases that match to a Decl. The exactly kind of
/// decl reference is disambiguated with the DeclKind bits in
Expand Down
6 changes: 3 additions & 3 deletions lib/Sema/PlaygroundTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Instrumenter : InstrumenterBase {
BracePair(const SourceRange &BR) : BraceRange(BR) {}
};

typedef std::forward_list<BracePair> BracePairStack;
using BracePairStack = std::forward_list<BracePair>;

BracePairStack BracePairs;
class BracePairPusher {
Expand Down Expand Up @@ -95,7 +95,7 @@ class Instrumenter : InstrumenterBase {
}
};

typedef SmallVector<swift::ASTNode, 3> ElementVector;
using ElementVector = SmallVector<swift::ASTNode, 3>;

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

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

SourceRange SR = BS->getSourceRange();
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckAvailability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ class InnermostAncestorFinder : private ASTWalker {

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

private:
const SourceRange TargetRange;
Expand Down
13 changes: 6 additions & 7 deletions lib/Sema/TypeCheckProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,12 @@ struct InferredAssociatedTypesByWitness {

/// The set of witnesses that were considered when attempting to
/// infer associated types.
typedef SmallVector<InferredAssociatedTypesByWitness, 2>
InferredAssociatedTypesByWitnesses;
using InferredAssociatedTypesByWitnesses =
SmallVector<InferredAssociatedTypesByWitness, 2>;

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

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

/// Perform associated type inference.
///
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckProtocolInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ void AssociatedTypeInference::findSolutionsRec(
unsigned numTypeWitnesses,
unsigned numValueWitnessesInProtocolExtensions,
unsigned reqDepth) {
typedef decltype(typeWitnesses)::ScopeTy TypeWitnessesScope;
using TypeWitnessesScope = decltype(typeWitnesses)::ScopeTy;

// If we hit the last requirement, record and check this solution.
if (reqDepth == inferred.size()) {
Expand Down
20 changes: 10 additions & 10 deletions lib/Sema/TypeChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ namespace constraints {

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

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

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

typedef SmallVectorImpl<LookupResultEntry>::iterator iterator;
using iterator = SmallVectorImpl<LookupResultEntry>::iterator;
iterator begin() { return Results.begin(); }
iterator end() { return Results.end(); }
unsigned size() const { return Results.size(); }
Expand Down Expand Up @@ -135,7 +135,7 @@ class LookupTypeResult {
friend class TypeChecker;

public:
typedef SmallVectorImpl<std::pair<TypeDecl *, Type>>::iterator iterator;
using iterator = SmallVectorImpl<std::pair<TypeDecl *, Type>>::iterator;
iterator begin() { return Results.begin(); }
iterator end() { return Results.end(); }
unsigned size() const { return Results.size(); }
Expand Down Expand Up @@ -232,7 +232,7 @@ enum class TypeCheckExprFlags {
SkipApplyingSolution = 0x100,
};

typedef OptionSet<TypeCheckExprFlags> TypeCheckExprOptions;
using TypeCheckExprOptions = OptionSet<TypeCheckExprFlags>;

inline TypeCheckExprOptions operator|(TypeCheckExprFlags flag1,
TypeCheckExprFlags flag2) {
Expand Down Expand Up @@ -262,7 +262,7 @@ enum class NameLookupFlags {
};

/// A set of options that control name lookup.
typedef OptionSet<NameLookupFlags> NameLookupOptions;
using NameLookupOptions = OptionSet<NameLookupFlags>;

inline NameLookupOptions operator|(NameLookupFlags flag1,
NameLookupFlags flag2) {
Expand Down Expand Up @@ -545,7 +545,7 @@ enum class TypeResolutionFlags : unsigned {
};

/// Option set describing how type resolution should work.
typedef OptionSet<TypeResolutionFlags> TypeResolutionOptions;
using TypeResolutionOptions = OptionSet<TypeResolutionFlags>;

/// Strip the contextual options from the given type resolution options.
static inline TypeResolutionOptions
Expand Down Expand Up @@ -677,7 +677,7 @@ enum class ConformanceCheckFlags {
};

/// Options that control protocol conformance checking.
typedef OptionSet<ConformanceCheckFlags> ConformanceCheckOptions;
using ConformanceCheckOptions = OptionSet<ConformanceCheckFlags>;

inline ConformanceCheckOptions operator|(ConformanceCheckFlags lhs,
ConformanceCheckFlags rhs) {
Expand Down