@@ -475,22 +475,24 @@ class alignas(8) Expr {
475
475
// /
476
476
// / This distinguishes static references to types, like Int, from metatype
477
477
// / values, "someTy: Any.Type".
478
- bool isTypeReference (llvm::function_ref<Type (const Expr *)> getType =
479
- [](const Expr *E) -> Type { return E->getType (); },
480
- llvm::function_ref<Decl *(const Expr *)> getDecl =
481
- [](const Expr *E) -> Decl * {
482
- return nullptr ;
483
- }) const ;
478
+ bool isTypeReference (
479
+ llvm::function_ref<Type (Expr *)> getType = [](Expr *E) -> Type {
480
+ return E->getType ();
481
+ },
482
+ llvm::function_ref<Decl *(Expr *)> getDecl = [](Expr *E) -> Decl * {
483
+ return nullptr ;
484
+ }) const ;
484
485
485
486
// / Determine whether this expression refers to a statically-derived metatype.
486
487
// /
487
488
// / This implies `isTypeReference`, but also requires that the referenced type
488
489
// / is not an archetype or dependent type.
489
490
bool isStaticallyDerivedMetatype (
490
- llvm::function_ref<Type (const Expr *)> getType =
491
- [](const Expr *E) -> Type { return E->getType (); },
492
- llvm::function_ref<bool (const Expr *)> isTypeReference =
493
- [](const Expr *E) { return E->isTypeReference (); }) const ;
491
+ llvm::function_ref<Type (Expr *)> getType = [](Expr *E) -> Type {
492
+ return E->getType ();
493
+ },
494
+ llvm::function_ref<bool (Expr *)> isTypeReference =
495
+ [](Expr *E) { return E->isTypeReference (); }) const ;
494
496
495
497
// / isImplicit - Determines whether this expression was implicitly-generated,
496
498
// / rather than explicitly written in the AST.
@@ -538,11 +540,12 @@ class alignas(8) Expr {
538
540
539
541
SWIFT_DEBUG_DUMP;
540
542
void dump (raw_ostream &OS, unsigned Indent = 0 ) const ;
541
- void dump (raw_ostream &OS, llvm::function_ref<Type (const Expr *)> getType,
542
- llvm::function_ref<Type (const TypeLoc &)> getTypeOfTypeLoc,
543
- llvm::function_ref<Type (const KeyPathExpr *E, unsigned index)> getTypeOfKeyPathComponent,
543
+ void dump (raw_ostream &OS, llvm::function_ref<Type (Expr *)> getType,
544
+ llvm::function_ref<Type (TypeLoc &)> getTypeOfTypeLoc,
545
+ llvm::function_ref<Type (KeyPathExpr *E, unsigned index)>
546
+ getTypeOfKeyPathComponent,
544
547
unsigned Indent = 0 ) const ;
545
-
548
+
546
549
void print (ASTPrinter &Printer, const PrintOptions &Opts) const ;
547
550
548
551
// Only allow allocation of Exprs using the allocator in ASTContext
@@ -1183,9 +1186,9 @@ class ObjectLiteralExpr final
1183
1186
// /
1184
1187
// / Note: prefer to use the second entry point, which separates out
1185
1188
// / arguments/labels/etc.
1186
- static ObjectLiteralExpr *
1187
- create (ASTContext &ctx, SourceLoc poundLoc, LiteralKind kind, Expr *arg,
1188
- bool implicit, llvm::function_ref<Type(const Expr *)> getType);
1189
+ static ObjectLiteralExpr *create (ASTContext &ctx, SourceLoc poundLoc,
1190
+ LiteralKind kind, Expr *arg, bool implicit ,
1191
+ llvm::function_ref<Type(Expr *)> getType);
1189
1192
1190
1193
// / Create a new object literal expression.
1191
1194
static ObjectLiteralExpr *create (ASTContext &ctx, SourceLoc poundLoc,
@@ -1778,11 +1781,12 @@ class DynamicSubscriptExpr final
1778
1781
// /
1779
1782
// / Note: do not create new callers to this entry point; use the entry point
1780
1783
// / that takes separate index arguments.
1781
- static DynamicSubscriptExpr *
1782
- create (ASTContext &ctx, Expr *base, Expr *index, ConcreteDeclRef decl,
1783
- bool implicit,
1784
- llvm::function_ref<Type(const Expr *)> getType =
1785
- [](const Expr *E) -> Type { return E->getType (); });
1784
+ static DynamicSubscriptExpr *create (
1785
+ ASTContext &ctx, Expr *base, Expr *index, ConcreteDeclRef decl,
1786
+ bool implicit,
1787
+ llvm::function_ref<Type(Expr *)> getType = [](Expr *E) -> Type {
1788
+ return E->getType ();
1789
+ });
1786
1790
1787
1791
// / getIndex - Retrieve the index of the subscript expression, i.e., the
1788
1792
// / "offset" into the base value.
@@ -2355,12 +2359,13 @@ class SubscriptExpr final : public LookupExpr,
2355
2359
// /
2356
2360
// / Note: do not create new callers to this entry point; use the entry point
2357
2361
// / that takes separate index arguments.
2358
- static SubscriptExpr *
2359
- create (ASTContext &ctx, Expr *base, Expr *index,
2360
- ConcreteDeclRef decl = ConcreteDeclRef(), bool implicit = false ,
2361
- AccessSemantics semantics = AccessSemantics::Ordinary,
2362
- llvm::function_ref<Type(const Expr *)> getType =
2363
- [](const Expr *E) -> Type { return E->getType (); });
2362
+ static SubscriptExpr *create (
2363
+ ASTContext &ctx, Expr *base, Expr *index,
2364
+ ConcreteDeclRef decl = ConcreteDeclRef(), bool implicit = false,
2365
+ AccessSemantics semantics = AccessSemantics::Ordinary,
2366
+ llvm::function_ref<Type(Expr *)> getType = [](Expr *E) -> Type {
2367
+ return E->getType ();
2368
+ });
2364
2369
2365
2370
// / Create a new subscript.
2366
2371
static SubscriptExpr *create (ASTContext &ctx, Expr *base,
@@ -3599,10 +3604,8 @@ class AbstractClosureExpr : public DeclContext, public Expr {
3599
3604
enum : unsigned { InvalidDiscriminator = 0xFFFF };
3600
3605
3601
3606
// / Retrieve the result type of this closure.
3602
- Type getResultType (llvm::function_ref<Type(const Expr *)> getType =
3603
- [](const Expr *E) -> Type {
3604
- return E->getType ();
3605
- }) const ;
3607
+ Type getResultType (llvm::function_ref<Type(Expr *)> getType =
3608
+ [](Expr *E) -> Type { return E->getType (); }) const ;
3606
3609
3607
3610
// / Return whether this closure is throwing when fully applied.
3608
3611
bool isBodyThrowing () const ;
@@ -4263,12 +4266,13 @@ class CallExpr final : public ApplyExpr,
4263
4266
// / Create a new call expression.
4264
4267
// /
4265
4268
// / Note: prefer to use the entry points that separate out the arguments.
4266
- static CallExpr *
4267
- create (ASTContext &ctx, Expr *fn, Expr *arg, ArrayRef<Identifier> argLabels,
4268
- ArrayRef<SourceLoc> argLabelLocs, bool hasTrailingClosure,
4269
- bool implicit, Type type = Type(),
4270
- llvm::function_ref<Type(const Expr *)> getType =
4271
- [](const Expr *E) -> Type { return E->getType (); });
4269
+ static CallExpr *create (
4270
+ ASTContext &ctx, Expr *fn, Expr *arg, ArrayRef<Identifier> argLabels,
4271
+ ArrayRef<SourceLoc> argLabelLocs, bool hasTrailingClosure, bool implicit,
4272
+ Type type = Type(),
4273
+ llvm::function_ref<Type(Expr *)> getType = [](Expr *E) -> Type {
4274
+ return E->getType ();
4275
+ });
4272
4276
4273
4277
// / Create a new implicit call expression without any source-location
4274
4278
// / information.
@@ -4277,11 +4281,12 @@ class CallExpr final : public ApplyExpr,
4277
4281
// / \param args The call arguments, not including a trailing closure (if any).
4278
4282
// / \param argLabels The argument labels, whose size must equal args.size(),
4279
4283
// / or which must be empty.
4280
- static CallExpr *
4281
- createImplicit (ASTContext &ctx, Expr *fn, ArrayRef<Expr *> args,
4282
- ArrayRef<Identifier> argLabels,
4283
- llvm::function_ref<Type(const Expr *)> getType =
4284
- [](const Expr *E) -> Type { return E->getType (); }) {
4284
+ static CallExpr *createImplicit (
4285
+ ASTContext &ctx, Expr *fn, ArrayRef<Expr *> args,
4286
+ ArrayRef<Identifier> argLabels,
4287
+ llvm::function_ref<Type(Expr *)> getType = [](Expr *E) -> Type {
4288
+ return E->getType ();
4289
+ }) {
4285
4290
return create (ctx, fn, SourceLoc (), args, argLabels, { }, SourceLoc (),
4286
4291
/* trailingClosure=*/ nullptr , /* implicit=*/ true , getType);
4287
4292
}
@@ -4295,12 +4300,13 @@ class CallExpr final : public ApplyExpr,
4295
4300
// / \param argLabelLocs The locations of the argument labels, whose size must
4296
4301
// / equal args.size() or which must be empty.
4297
4302
// / \param trailingClosure The trailing closure, if any.
4298
- static CallExpr *
4299
- create (ASTContext &ctx, Expr *fn, SourceLoc lParenLoc, ArrayRef<Expr *> args,
4300
- ArrayRef<Identifier> argLabels, ArrayRef<SourceLoc> argLabelLocs,
4301
- SourceLoc rParenLoc, Expr *trailingClosure, bool implicit,
4302
- llvm::function_ref<Type(const Expr *)> getType =
4303
- [](const Expr *E) -> Type { return E->getType (); });
4303
+ static CallExpr *create (
4304
+ ASTContext &ctx, Expr *fn, SourceLoc lParenLoc, ArrayRef<Expr *> args,
4305
+ ArrayRef<Identifier> argLabels, ArrayRef<SourceLoc> argLabelLocs,
4306
+ SourceLoc rParenLoc, Expr *trailingClosure, bool implicit,
4307
+ llvm::function_ref<Type(Expr *)> getType = [](Expr *E) -> Type {
4308
+ return E->getType ();
4309
+ });
4304
4310
4305
4311
SourceLoc getStartLoc () const {
4306
4312
SourceLoc fnLoc = getFn ()->getStartLoc ();
@@ -5622,18 +5628,15 @@ inline const SourceLoc *CollectionExpr::getTrailingSourceLocs() const {
5622
5628
// /
5623
5629
// / \param argLabelLocs The argument label locations, which might be updated by
5624
5630
// / this function.
5625
- Expr *packSingleArgument (ASTContext &ctx, SourceLoc lParenLoc,
5626
- ArrayRef<Expr *> args,
5627
- ArrayRef<Identifier> &argLabels,
5628
- ArrayRef<SourceLoc> &argLabelLocs,
5629
- SourceLoc rParenLoc,
5630
- Expr *trailingClosure, bool implicit,
5631
- SmallVectorImpl<Identifier> &argLabelsScratch,
5632
- SmallVectorImpl<SourceLoc> &argLabelLocsScratch,
5633
- llvm::function_ref<Type(const Expr *)> getType =
5634
- [](const Expr *E) -> Type {
5635
- return E->getType ();
5636
- });
5631
+ Expr *packSingleArgument (
5632
+ ASTContext &ctx, SourceLoc lParenLoc, ArrayRef<Expr *> args,
5633
+ ArrayRef<Identifier> &argLabels, ArrayRef<SourceLoc> &argLabelLocs,
5634
+ SourceLoc rParenLoc, Expr *trailingClosure, bool implicit,
5635
+ SmallVectorImpl<Identifier> &argLabelsScratch,
5636
+ SmallVectorImpl<SourceLoc> &argLabelLocsScratch,
5637
+ llvm::function_ref<Type(Expr *)> getType = [](Expr *E) -> Type {
5638
+ return E->getType ();
5639
+ });
5637
5640
5638
5641
void simple_display (llvm::raw_ostream &out, const ClosureExpr *CE);
5639
5642
void simple_display (llvm::raw_ostream &out, const DefaultArgumentExpr *expr);
0 commit comments