Skip to content

Commit 7d4f6ff

Browse files
committed
[SIL] Added isLexical to ValueBase.
1 parent 5725108 commit 7d4f6ff

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/swift/SIL/SILValue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,8 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
540540
/// NOTE: This is implemented in ValueOwnership.cpp not SILValue.cpp.
541541
ValueOwnershipKind getOwnershipKind() const;
542542

543+
bool isLexical() const;
544+
543545
static bool classof(SILNodePointer node) {
544546
return node->getKind() >= SILNodeKind::First_ValueBase &&
545547
node->getKind() <= SILNodeKind::Last_ValueBase;

lib/SIL/IR/SILValue.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ ValueBase::getDefiningInstructionResult() {
9898
return None;
9999
}
100100

101+
bool ValueBase::isLexical() const {
102+
// TODO: Eventually, rather than SILGen'ing a borrow scope for owned
103+
// arguments, we will just have this check here.
104+
// if (auto *argument = dyn_cast<SILArgument>(this))
105+
// return argument->getOwnershipKind() == OwnershipKind::Owned;
106+
if (auto *bbi = dyn_cast<BeginBorrowInst>(this))
107+
return bbi->isLexical();
108+
if (auto *mvi = dyn_cast<MoveValueInst>(this))
109+
return mvi->isLexical();
110+
return false;
111+
}
112+
101113
SILBasicBlock *SILNode::getParentBlock() const {
102114
if (auto *Inst = dyn_cast<SILInstruction>(this))
103115
return Inst->getParent();

0 commit comments

Comments
 (0)