Skip to content

Commit ef73f89

Browse files
committed
Add Operand::isConsuming().
Use this whenever we're assuming an owned value.
1 parent 0bce7e8 commit ef73f89

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

include/swift/SIL/SILValue.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,9 @@ class Operand {
10371037
/// guaranteed scope.
10381038
bool isLifetimeEnding() const;
10391039

1040+
/// Returns true if this ends the lifetime of an owned operand.
1041+
bool isConsuming() const;
1042+
10401043
SILBasicBlock *getParentBlock() const;
10411044
SILFunction *getParentFunction() const;
10421045

lib/SIL/IR/SILValue.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@ bool Operand::isLifetimeEnding() const {
339339
return get().getOwnershipKind() != OwnershipKind::None;
340340
}
341341

342+
bool Operand::isConsuming() const {
343+
if (!getOwnershipConstraint().isConsuming())
344+
return false;
345+
346+
return get().getOwnershipKind() != OwnershipKind::None;
347+
}
348+
342349
//===----------------------------------------------------------------------===//
343350
// OperandConstraint
344351
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)