@@ -3591,6 +3591,22 @@ class ArchetypeToSuperExpr : public ImplicitConversionExpr {
35913591 }
35923592};
35933593
3594+ // / An expression that models an implicit conversion from an uninhabited value
3595+ // / to any type. It cannot be evaluated.
3596+ class UnreachableExpr : public ImplicitConversionExpr {
3597+ UnreachableExpr (Expr *subExpr, Type ty)
3598+ : ImplicitConversionExpr(ExprKind::Unreachable, subExpr, ty) {}
3599+
3600+ public:
3601+ static UnreachableExpr *create (ASTContext &ctx, Expr *subExpr, Type ty) {
3602+ return new (ctx) UnreachableExpr (subExpr, ty);
3603+ }
3604+
3605+ static bool classof (const Expr *E) {
3606+ return E->getKind () == ExprKind::Unreachable;
3607+ }
3608+ };
3609+
35943610// / The builtin unary '&' operator, which converts the
35953611// / given lvalue into an 'inout' argument value.
35963612class InOutExpr : public Expr {
@@ -3927,9 +3943,7 @@ class AbstractClosureExpr : public DeclContext, public Expr {
39273943 bool hasSingleExpressionBody () const ;
39283944
39293945 // / Retrieve the body for closure that has a single expression for
3930- // / its body.
3931- // /
3932- // / Only valid when \c hasSingleExpressionBody() is true.
3946+ // / its body, or \c nullptr if there is no single expression body.
39333947 Expr *getSingleExpressionBody () const ;
39343948
39353949 // / Returns the body of closures that have a body
@@ -4055,9 +4069,9 @@ class ClosureExpr : public AbstractClosureExpr {
40554069 // / The explicitly-specified result type.
40564070 llvm::PointerIntPair<TypeExpr *, 2 , BodyState> ExplicitResultTypeAndBodyState;
40574071
4058- // / The body of the closure, along with a bit indicating whether it
4059- // / was originally just a single expression.
4060- llvm::PointerIntPair<BraceStmt *, 1 , bool > Body;
4072+ // / The body of the closure.
4073+ BraceStmt *Body;
4074+
40614075public:
40624076 ClosureExpr (const DeclAttributes &attributes,
40634077 SourceRange bracketRange, VarDecl *capturedSelfDecl,
@@ -4083,11 +4097,8 @@ class ClosureExpr : public AbstractClosureExpr {
40834097 SourceLoc getEndLoc () const ;
40844098 SourceLoc getLoc () const ;
40854099
4086- BraceStmt *getBody () const { return Body.getPointer (); }
4087- void setBody (BraceStmt *S, bool isSingleExpression) {
4088- Body.setPointer (S);
4089- Body.setInt (isSingleExpression);
4090- }
4100+ BraceStmt *getBody () const { return Body; }
4101+ void setBody (BraceStmt *S) { Body = S; }
40914102
40924103 DeclAttributes &getAttrs () { return Attributes; }
40934104 const DeclAttributes &getAttrs () const { return Attributes; }
@@ -4202,13 +4213,11 @@ class ClosureExpr : public AbstractClosureExpr {
42024213 // / ... even if the closure has been coerced to return Void by the type
42034214 // / checker. This function does not return true for empty closures.
42044215 bool hasSingleExpressionBody () const {
4205- return Body. getInt ();
4216+ return getSingleExpressionBody ();
42064217 }
42074218
42084219 // / Retrieve the body for closure that has a single expression for
4209- // / its body.
4210- // /
4211- // / Only valid when \c hasSingleExpressionBody() is true.
4220+ // / its body, or \c nullptr if there is no single expression body.
42124221 Expr *getSingleExpressionBody () const ;
42134222
42144223 // / Is this a completely empty closure?
0 commit comments