Skip to content

Commit fd25cf3

Browse files
committed
Rename MoveExpr -> ConsumeExpr to reflect the final name.
NFC.
1 parent a155209 commit fd25cf3

File tree

10 files changed

+39
-36
lines changed

10 files changed

+39
-36
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6992,7 +6992,7 @@ ERROR(concurrency_task_to_thread_model_global_actor_annotation,none,
69926992

69936993
ERROR(moveOnly_not_allowed_here,none,
69946994
"'moveOnly' only applies to structs or enums", ())
6995-
ERROR(move_expression_not_passed_lvalue,none,
6995+
ERROR(consume_expression_not_passed_lvalue,none,
69966996
"'consume' can only be applied to lvalues", ())
69976997
ERROR(borrow_expression_not_passed_lvalue,none,
69986998
"'borrow' can only be applied to lvalues", ())

include/swift/AST/Expr.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,31 +2050,34 @@ 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.
2053+
/// ConsumeExpr - A 'consume' surrounding an lvalue expression marking the
2054+
/// lvalue as needing to be moved.
20552055
///
20562056
/// getSemanticsProvidingExpr() looks through this because it doesn't
20572057
/// provide the value and only very specific clients care where the
20582058
/// 'move' was written.
2059-
class MoveExpr final : public IdentityExpr {
2060-
SourceLoc MoveLoc;
2059+
class ConsumeExpr final : public IdentityExpr {
2060+
SourceLoc ConsumeLoc;
20612061

20622062
public:
2063-
MoveExpr(SourceLoc moveLoc, Expr *sub, Type type = Type(),
2064-
bool implicit = false)
2065-
: IdentityExpr(ExprKind::Move, sub, type, implicit), MoveLoc(moveLoc) {}
2063+
ConsumeExpr(SourceLoc consumeLoc, Expr *sub, Type type = Type(),
2064+
bool implicit = false)
2065+
: IdentityExpr(ExprKind::Consume, sub, type, implicit),
2066+
ConsumeLoc(consumeLoc) {}
20662067

2067-
static MoveExpr *createImplicit(ASTContext &ctx, SourceLoc moveLoc, Expr *sub,
2068-
Type type = Type()) {
2069-
return new (ctx) MoveExpr(moveLoc, sub, type, /*implicit=*/true);
2068+
static ConsumeExpr *createImplicit(ASTContext &ctx, SourceLoc moveLoc,
2069+
Expr *sub, Type type = Type()) {
2070+
return new (ctx) ConsumeExpr(moveLoc, sub, type, /*implicit=*/true);
20702071
}
20712072

2072-
SourceLoc getLoc() const { return MoveLoc; }
2073+
SourceLoc getLoc() const { return ConsumeLoc; }
20732074

2074-
SourceLoc getStartLoc() const { return MoveLoc; }
2075+
SourceLoc getStartLoc() const { return ConsumeLoc; }
20752076
SourceLoc getEndLoc() const { return getSubExpr()->getEndLoc(); }
20762077

2077-
static bool classof(const Expr *e) { return e->getKind() == ExprKind::Move; }
2078+
static bool classof(const Expr *e) {
2079+
return e->getKind() == ExprKind::Consume;
2080+
}
20782081
};
20792082

20802083
/// CopyExpr - A 'copy' surrounding an lvalue expression marking the lvalue as

include/swift/AST/ExprNodes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ABSTRACT_EXPR(Identity, Expr)
107107
EXPR(Paren, IdentityExpr)
108108
EXPR(DotSelf, IdentityExpr)
109109
EXPR(Await, IdentityExpr)
110-
EXPR(Move, IdentityExpr)
110+
EXPR(Consume, IdentityExpr)
111111
EXPR(Borrow, IdentityExpr)
112112
EXPR(UnresolvedMemberChainResult, IdentityExpr)
113113
EXPR_RANGE(Identity, Paren, UnresolvedMemberChainResult)

lib/AST/ASTDumper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,8 +2194,8 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
21942194
printRec(E->getSubExpr());
21952195
PrintWithColorRAII(OS, ParenthesisColor) << ')';
21962196
}
2197-
void visitMoveExpr(MoveExpr *E) {
2198-
printCommon(E, "move_expr");
2197+
void visitConsumeExpr(ConsumeExpr *E) {
2198+
printCommon(E, "consume_expr");
21992199
OS << '\n';
22002200
printRec(E->getSubExpr());
22012201
PrintWithColorRAII(OS, ParenthesisColor) << ')';

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4995,8 +4995,8 @@ void PrintAST::visitAwaitExpr(AwaitExpr *expr) {
49954995
visit(expr->getSubExpr());
49964996
}
49974997

4998-
void PrintAST::visitMoveExpr(MoveExpr *expr) {
4999-
Printer << "move ";
4998+
void PrintAST::visitConsumeExpr(ConsumeExpr *expr) {
4999+
Printer << "consume ";
50005000
visit(expr->getSubExpr());
50015001
}
50025002

lib/AST/Expr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ ConcreteDeclRef Expr::getReferencedDecl(bool stopAtParenExpr) const {
370370
PASS_THROUGH_REFERENCE(UnresolvedMemberChainResult, getSubExpr);
371371
PASS_THROUGH_REFERENCE(DotSelf, getSubExpr);
372372
PASS_THROUGH_REFERENCE(Await, getSubExpr);
373-
PASS_THROUGH_REFERENCE(Move, getSubExpr);
373+
PASS_THROUGH_REFERENCE(Consume, getSubExpr);
374374
PASS_THROUGH_REFERENCE(Copy, getSubExpr);
375375
PASS_THROUGH_REFERENCE(Borrow, getSubExpr);
376376
PASS_THROUGH_REFERENCE(Try, getSubExpr);
@@ -743,7 +743,7 @@ bool Expr::canAppendPostfixExpression(bool appendingPostfixOperator) const {
743743
return true;
744744

745745
case ExprKind::Await:
746-
case ExprKind::Move:
746+
case ExprKind::Consume:
747747
case ExprKind::Copy:
748748
case ExprKind::Borrow:
749749
case ExprKind::Try:
@@ -936,7 +936,7 @@ bool Expr::isValidParentOfTypeExpr(Expr *typeExpr) const {
936936
case ExprKind::Sequence:
937937
case ExprKind::Paren:
938938
case ExprKind::Await:
939-
case ExprKind::Move:
939+
case ExprKind::Consume:
940940
case ExprKind::Copy:
941941
case ExprKind::Borrow:
942942
case ExprKind::UnresolvedMemberChainResult:

lib/Parse/ParseExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ ParserResult<Expr> Parser::parseExprSequenceElement(Diag<> message,
418418
ParserResult<Expr> sub =
419419
parseExprSequenceElement(diag::expected_expr_after_move, isExprBasic);
420420
if (!sub.isNull()) {
421-
sub = makeParserResult(new (Context) MoveExpr(consumeLoc, sub.get()));
421+
sub = makeParserResult(new (Context) ConsumeExpr(consumeLoc, sub.get()));
422422
}
423423
return sub;
424424
}
@@ -448,7 +448,7 @@ ParserResult<Expr> Parser::parseExprSequenceElement(Diag<> message,
448448
ParserResult<Expr> sub =
449449
parseExprSequenceElement(diag::expected_expr_after_move, isExprBasic);
450450
if (!sub.hasCodeCompletion() && !sub.isNull()) {
451-
sub = makeParserResult(new (Context) MoveExpr(awaitLoc, sub.get()));
451+
sub = makeParserResult(new (Context) ConsumeExpr(awaitLoc, sub.get()));
452452
}
453453
return sub;
454454
}

lib/SILGen/SILGenExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ namespace {
551551
LinearFunctionExtractOriginalExpr *E, SGFContext C);
552552
RValue visitLinearToDifferentiableFunctionExpr(
553553
LinearToDifferentiableFunctionExpr *E, SGFContext C);
554-
RValue visitMoveExpr(MoveExpr *E, SGFContext C);
554+
RValue visitConsumeExpr(ConsumeExpr *E, SGFContext C);
555555
RValue visitCopyExpr(CopyExpr *E, SGFContext C);
556556
RValue visitMacroExpansionExpr(MacroExpansionExpr *E, SGFContext C);
557557
};
@@ -6115,7 +6115,7 @@ RValue RValueEmitter::visitErrorExpr(ErrorExpr *E, SGFContext C) {
61156115
llvm::report_fatal_error("Found an ErrorExpr but didn't emit an error?");
61166116
}
61176117

6118-
RValue RValueEmitter::visitMoveExpr(MoveExpr *E, SGFContext C) {
6118+
RValue RValueEmitter::visitConsumeExpr(ConsumeExpr *E, SGFContext C) {
61196119
auto *subExpr = cast<DeclRefExpr>(E->getSubExpr());
61206120
auto subASTType = subExpr->getType()->getCanonicalType();
61216121

lib/SILGen/SILGenLValue.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ class LLVM_LIBRARY_VISIBILITY SILGenLValue
332332
LValue visitKeyPathApplicationExpr(KeyPathApplicationExpr *e,
333333
SGFAccessKind accessKind,
334334
LValueOptions options);
335-
LValue visitMoveExpr(MoveExpr *e, SGFAccessKind accessKind,
336-
LValueOptions options);
335+
LValue visitConsumeExpr(ConsumeExpr *e, SGFAccessKind accessKind,
336+
LValueOptions options);
337337
LValue visitCopyExpr(CopyExpr *e, SGFAccessKind accessKind,
338338
LValueOptions options);
339339
LValue visitABISafeConversionExpr(ABISafeConversionExpr *e,
@@ -4004,8 +4004,8 @@ LValue SILGenLValue::visitInOutExpr(InOutExpr *e, SGFAccessKind accessKind,
40044004
return visitRec(e->getSubExpr(), accessKind, options);
40054005
}
40064006

4007-
LValue SILGenLValue::visitMoveExpr(MoveExpr *e, SGFAccessKind accessKind,
4008-
LValueOptions options) {
4007+
LValue SILGenLValue::visitConsumeExpr(ConsumeExpr *e, SGFAccessKind accessKind,
4008+
LValueOptions options) {
40094009
// Do formal evaluation of the base l-value.
40104010
LValue baseLV = visitRec(e->getSubExpr(), SGFAccessKind::ReadWrite,
40114011
options.forComputedBaseLValue());

lib/Sema/MiscDiagnostics.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
340340

341341
// Diagnose move expression uses where the sub expression is not a declref
342342
// expr.
343-
if (auto *moveExpr = dyn_cast<MoveExpr>(E)) {
344-
checkMoveExpr(moveExpr);
343+
if (auto *consumeExpr = dyn_cast<ConsumeExpr>(E)) {
344+
checkConsumeExpr(consumeExpr);
345345
}
346346

347347
// Diagnose copy expression uses where the sub expression is not a declref
@@ -421,10 +421,10 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC,
421421
}
422422
}
423423

424-
void checkMoveExpr(MoveExpr *moveExpr) {
425-
if (!isa<DeclRefExpr>(moveExpr->getSubExpr())) {
426-
Ctx.Diags.diagnose(moveExpr->getLoc(),
427-
diag::move_expression_not_passed_lvalue);
424+
void checkConsumeExpr(ConsumeExpr *consumeExpr) {
425+
if (!isa<DeclRefExpr>(consumeExpr->getSubExpr())) {
426+
Ctx.Diags.diagnose(consumeExpr->getLoc(),
427+
diag::consume_expression_not_passed_lvalue);
428428
}
429429
}
430430

0 commit comments

Comments
 (0)