Skip to content

Commit 86c13d3

Browse files
authored
Revert "Reimplement function builders as statement transformations."
1 parent acce4a0 commit 86c13d3

17 files changed

+268
-865
lines changed

include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
SWIFT_TYPEID(AncestryFlags)
1919
SWIFT_TYPEID(CtorInitializerKind)
20-
SWIFT_TYPEID(FunctionBuilderBodyPreCheck)
20+
SWIFT_TYPEID(FunctionBuilderClosurePreCheck)
2121
SWIFT_TYPEID(GenericSignature)
2222
SWIFT_TYPEID(ImplicitMemberAction)
2323
SWIFT_TYPEID(ParamSpecifier)

include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ConstructorDecl;
2828
class CustomAttr;
2929
class Decl;
3030
class EnumDecl;
31-
enum class FunctionBuilderBodyPreCheck : uint8_t;
31+
enum class FunctionBuilderClosurePreCheck : uint8_t;
3232
class GenericParamList;
3333
class GenericSignature;
3434
class GenericTypeParamType;

include/swift/AST/Expr.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3599,10 +3599,7 @@ class ClosureExpr : public AbstractClosureExpr {
35993599
/// the CaptureListExpr which would normally maintain this sort of
36003600
/// information about captured variables), we need to have some way to access
36013601
/// this information directly on the ClosureExpr.
3602-
///
3603-
/// The bit indicates whether this closure has had a function builder
3604-
/// applied to it.
3605-
llvm::PointerIntPair<VarDecl *, 1, bool> CapturedSelfDeclAndAppliedBuilder;
3602+
VarDecl *CapturedSelfDecl;
36063603

36073604
/// The location of the "throws", if present.
36083605
SourceLoc ThrowsLoc;
@@ -3627,8 +3624,7 @@ class ClosureExpr : public AbstractClosureExpr {
36273624
unsigned discriminator, DeclContext *parent)
36283625
: AbstractClosureExpr(ExprKind::Closure, Type(), /*Implicit=*/false,
36293626
discriminator, parent),
3630-
BracketRange(bracketRange),
3631-
CapturedSelfDeclAndAppliedBuilder(capturedSelfDecl, false),
3627+
BracketRange(bracketRange), CapturedSelfDecl(capturedSelfDecl),
36323628
ThrowsLoc(throwsLoc), ArrowLoc(arrowLoc), InLoc(inLoc),
36333629
ExplicitResultType(explicitResultType), Body(nullptr) {
36343630
setParameterList(params);
@@ -3730,23 +3726,13 @@ class ClosureExpr : public AbstractClosureExpr {
37303726
bool hasEmptyBody() const;
37313727

37323728
/// VarDecl captured by this closure under the literal name \c self , if any.
3733-
VarDecl *getCapturedSelfDecl() const {
3734-
return CapturedSelfDeclAndAppliedBuilder.getPointer();
3735-
}
3729+
VarDecl *getCapturedSelfDecl() const { return CapturedSelfDecl; }
37363730

37373731
/// Whether this closure captures the \c self param in its body in such a
37383732
/// way that implicit \c self is enabled within its body (i.e. \c self is
37393733
/// captured non-weakly).
37403734
bool capturesSelfEnablingImplictSelf() const;
37413735

3742-
bool hasAppliedFunctionBuilder() const {
3743-
return CapturedSelfDeclAndAppliedBuilder.getInt();
3744-
}
3745-
3746-
void setAppliedFunctionBuilder(bool flag = true) {
3747-
CapturedSelfDeclAndAppliedBuilder.setInt(flag);
3748-
}
3749-
37503736
static bool classof(const Expr *E) {
37513737
return E->getKind() == ExprKind::Closure;
37523738
}

include/swift/AST/TypeCheckRequests.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ class ValueWitnessRequest
17501750
void cacheResult(Witness value) const;
17511751
};
17521752

1753-
enum class FunctionBuilderBodyPreCheck : uint8_t {
1753+
enum class FunctionBuilderClosurePreCheck : uint8_t {
17541754
/// There were no problems pre-checking the closure.
17551755
Okay,
17561756

@@ -1763,7 +1763,7 @@ enum class FunctionBuilderBodyPreCheck : uint8_t {
17631763

17641764
class PreCheckFunctionBuilderRequest
17651765
: public SimpleRequest<PreCheckFunctionBuilderRequest,
1766-
FunctionBuilderBodyPreCheck(AnyFunctionRef),
1766+
FunctionBuilderClosurePreCheck(AnyFunctionRef),
17671767
CacheKind::Cached> {
17681768
public:
17691769
using SimpleRequest::SimpleRequest;
@@ -1772,7 +1772,7 @@ class PreCheckFunctionBuilderRequest
17721772
friend SimpleRequest;
17731773

17741774
// Evaluation.
1775-
llvm::Expected<FunctionBuilderBodyPreCheck>
1775+
llvm::Expected<FunctionBuilderClosurePreCheck>
17761776
evaluate(Evaluator &evaluator, AnyFunctionRef fn) const;
17771777

17781778
public:
@@ -2044,7 +2044,7 @@ AnyValue::Holder<GenericSignature>::equals(const HolderBase &other) const {
20442044
void simple_display(llvm::raw_ostream &out, Type value);
20452045
void simple_display(llvm::raw_ostream &out, const TypeRepr *TyR);
20462046
void simple_display(llvm::raw_ostream &out, ImplicitMemberAction action);
2047-
void simple_display(llvm::raw_ostream &out, FunctionBuilderBodyPreCheck pck);
2047+
void simple_display(llvm::raw_ostream &out, FunctionBuilderClosurePreCheck pck);
20482048

20492049
#define SWIFT_TYPEID_ZONE TypeChecker
20502050
#define SWIFT_TYPEID_HEADER "swift/AST/TypeCheckerTypeIDZone.def"

lib/AST/TypeCheckRequests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,15 +1122,15 @@ void ValueWitnessRequest::cacheResult(Witness type) const {
11221122
//----------------------------------------------------------------------------//
11231123

11241124
void swift::simple_display(llvm::raw_ostream &out,
1125-
FunctionBuilderBodyPreCheck value) {
1125+
FunctionBuilderClosurePreCheck value) {
11261126
switch (value) {
1127-
case FunctionBuilderBodyPreCheck::Okay:
1127+
case FunctionBuilderClosurePreCheck::Okay:
11281128
out << "okay";
11291129
break;
1130-
case FunctionBuilderBodyPreCheck::HasReturnStmt:
1130+
case FunctionBuilderClosurePreCheck::HasReturnStmt:
11311131
out << "has return statement";
11321132
break;
1133-
case FunctionBuilderBodyPreCheck::Error:
1133+
case FunctionBuilderClosurePreCheck::Error:
11341134
out << "error";
11351135
break;
11361136
}

0 commit comments

Comments
 (0)