Skip to content

Commit 423adbc

Browse files
authored
Merge pull request #29292 from apple/revert-29133-generlize-function-builders
Revert "Reimplement function builders as statement transformations."
2 parents 9583261 + 86c13d3 commit 423adbc

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
@@ -1755,7 +1755,7 @@ class ValueWitnessRequest
17551755
void cacheResult(Witness value) const;
17561756
};
17571757

1758-
enum class FunctionBuilderBodyPreCheck : uint8_t {
1758+
enum class FunctionBuilderClosurePreCheck : uint8_t {
17591759
/// There were no problems pre-checking the closure.
17601760
Okay,
17611761

@@ -1768,7 +1768,7 @@ enum class FunctionBuilderBodyPreCheck : uint8_t {
17681768

17691769
class PreCheckFunctionBuilderRequest
17701770
: public SimpleRequest<PreCheckFunctionBuilderRequest,
1771-
FunctionBuilderBodyPreCheck(AnyFunctionRef),
1771+
FunctionBuilderClosurePreCheck(AnyFunctionRef),
17721772
CacheKind::Cached> {
17731773
public:
17741774
using SimpleRequest::SimpleRequest;
@@ -1777,7 +1777,7 @@ class PreCheckFunctionBuilderRequest
17771777
friend SimpleRequest;
17781778

17791779
// Evaluation.
1780-
llvm::Expected<FunctionBuilderBodyPreCheck>
1780+
llvm::Expected<FunctionBuilderClosurePreCheck>
17811781
evaluate(Evaluator &evaluator, AnyFunctionRef fn) const;
17821782

17831783
public:
@@ -2078,7 +2078,7 @@ AnyValue::Holder<GenericSignature>::equals(const HolderBase &other) const {
20782078
void simple_display(llvm::raw_ostream &out, Type value);
20792079
void simple_display(llvm::raw_ostream &out, const TypeRepr *TyR);
20802080
void simple_display(llvm::raw_ostream &out, ImplicitMemberAction action);
2081-
void simple_display(llvm::raw_ostream &out, FunctionBuilderBodyPreCheck pck);
2081+
void simple_display(llvm::raw_ostream &out, FunctionBuilderClosurePreCheck pck);
20822082

20832083
#define SWIFT_TYPEID_ZONE TypeChecker
20842084
#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
@@ -1125,15 +1125,15 @@ void ValueWitnessRequest::cacheResult(Witness type) const {
11251125
//----------------------------------------------------------------------------//
11261126

11271127
void swift::simple_display(llvm::raw_ostream &out,
1128-
FunctionBuilderBodyPreCheck value) {
1128+
FunctionBuilderClosurePreCheck value) {
11291129
switch (value) {
1130-
case FunctionBuilderBodyPreCheck::Okay:
1130+
case FunctionBuilderClosurePreCheck::Okay:
11311131
out << "okay";
11321132
break;
1133-
case FunctionBuilderBodyPreCheck::HasReturnStmt:
1133+
case FunctionBuilderClosurePreCheck::HasReturnStmt:
11341134
out << "has return statement";
11351135
break;
1136-
case FunctionBuilderBodyPreCheck::Error:
1136+
case FunctionBuilderClosurePreCheck::Error:
11371137
out << "error";
11381138
break;
11391139
}

0 commit comments

Comments
 (0)