@@ -2050,31 +2050,61 @@ class AwaitExpr final : public IdentityExpr {
20502050 }
20512051};
20522052
2053- // / MoveExpr - A 'move' surrounding an lvalue expression marking the lvalue as
2054- // / needing to be moved.
2055- // /
2056- // / getSemanticsProvidingExpr() looks through this because it doesn't
2057- // / provide the value and only very specific clients care where the
2058- // / 'move' was written.
2059- class MoveExpr final : public IdentityExpr {
2060- SourceLoc MoveLoc;
2053+ // / ConsumeExpr - A 'consume' surrounding an lvalue expression marking the
2054+ // / lvalue as needing to be moved.
2055+ class ConsumeExpr final : public Expr {
2056+ Expr *SubExpr;
2057+ SourceLoc ConsumeLoc;
20612058
20622059public:
2063- MoveExpr (SourceLoc moveLoc, Expr *sub, Type type = Type(),
2060+ ConsumeExpr (SourceLoc consumeLoc, Expr *sub, Type type = Type(),
2061+ bool implicit = false )
2062+ : Expr(ExprKind::Consume, implicit, type), SubExpr(sub),
2063+ ConsumeLoc (consumeLoc) {}
2064+
2065+ static ConsumeExpr *createImplicit (ASTContext &ctx, SourceLoc moveLoc,
2066+ Expr *sub, Type type = Type()) {
2067+ return new (ctx) ConsumeExpr (moveLoc, sub, type, /* implicit=*/ true );
2068+ }
2069+
2070+ SourceLoc getLoc () const { return ConsumeLoc; }
2071+
2072+ Expr *getSubExpr () const { return SubExpr; }
2073+ void setSubExpr (Expr *E) { SubExpr = E; }
2074+
2075+ SourceLoc getStartLoc () const { return getLoc (); }
2076+ SourceLoc getEndLoc () const { return getSubExpr ()->getEndLoc (); }
2077+
2078+ static bool classof (const Expr *e) {
2079+ return e->getKind () == ExprKind::Consume;
2080+ }
2081+ };
2082+
2083+ // / CopyExpr - A 'copy' surrounding an lvalue expression marking the lvalue as
2084+ // / needing a semantic copy. Used to force a copy of a no implicit copy type.
2085+ class CopyExpr final : public Expr {
2086+ Expr *SubExpr;
2087+ SourceLoc CopyLoc;
2088+
2089+ public:
2090+ CopyExpr (SourceLoc copyLoc, Expr *sub, Type type = Type(),
20642091 bool implicit = false )
2065- : IdentityExpr (ExprKind::Move, sub , type, implicit ), MoveLoc(moveLoc ) {}
2092+ : Expr (ExprKind::Copy, implicit , type), SubExpr(sub ), CopyLoc(copyLoc ) {}
20662093
2067- static MoveExpr *createImplicit (ASTContext &ctx, SourceLoc moveLoc , Expr *sub,
2094+ static CopyExpr *createImplicit (ASTContext &ctx, SourceLoc copyLoc , Expr *sub,
20682095 Type type = Type()) {
2069- return new (ctx) MoveExpr (moveLoc , sub, type, /* implicit=*/ true );
2096+ return new (ctx) CopyExpr (copyLoc , sub, type, /* implicit=*/ true );
20702097 }
20712098
2072- SourceLoc getLoc () const { return MoveLoc; }
2099+ SourceLoc getLoc () const { return CopyLoc; }
2100+
2101+ Expr *getSubExpr () const { return SubExpr; }
2102+ void setSubExpr (Expr *E) { SubExpr = E; }
20732103
2074- SourceLoc getStartLoc () const { return MoveLoc ; }
2104+ SourceLoc getStartLoc () const { return CopyLoc ; }
20752105 SourceLoc getEndLoc () const { return getSubExpr ()->getEndLoc (); }
20762106
2077- static bool classof (const Expr *e) { return e->getKind () == ExprKind::Move ; }
2107+ static bool classof (const Expr *e) { return e->getKind () == ExprKind::Copy ; }
20782108};
20792109
20802110// / BorrowExpr - A 'borrow' surrounding an lvalue/accessor expression at an
0 commit comments