Skip to content

Commit f3cee91

Browse files
committed
SwiftCompilerSources: add the LoadBorrowInst.isUnchecked API
1 parent 657abcc commit f3cee91

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,15 @@ final public class BeginBorrowInst : SingleValueInstruction, UnaryInstruction, B
12561256
}
12571257
}
12581258

1259-
final public class LoadBorrowInst : SingleValueInstruction, LoadInstruction, BorrowIntroducingInstruction {}
1259+
final public class LoadBorrowInst : SingleValueInstruction, LoadInstruction, BorrowIntroducingInstruction {
1260+
1261+
// True if the invariants on `load_borrow` have not been checked and should not be strictly enforced.
1262+
//
1263+
// This can only occur during raw SIL before move-only checking occurs. Developers can write incorrect
1264+
// code using noncopyable types that consumes or mutates a memory location while that location is borrowed,
1265+
// but the move-only checker must diagnose those problems before canonical SIL is formed.
1266+
public var isUnchecked: Bool { bridged.LoadBorrowInst_isUnchecked() }
1267+
}
12601268

12611269
final public class StoreBorrowInst : SingleValueInstruction, StoringInstruction, BorrowIntroducingInstruction {
12621270
var allocStack: AllocStackInst {

include/swift/SIL/SILBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ struct BridgedInstruction {
788788

789789
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef CondFailInst_getMessage() const;
790790
BRIDGED_INLINE SwiftInt LoadInst_getLoadOwnership() const ;
791+
BRIDGED_INLINE bool LoadBorrowInst_isUnchecked() const ;
791792
BRIDGED_INLINE BuiltinValueKind BuiltinInst_getID() const;
792793
BRIDGED_INLINE IntrinsicID BuiltinInst_getIntrinsicID() const;
793794
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap BuiltinInst_getSubstitutionMap() const;

include/swift/SIL/SILBridgingImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,10 @@ SwiftInt BridgedInstruction::LoadInst_getLoadOwnership() const {
10921092
return (SwiftInt)getAs<swift::LoadInst>()->getOwnershipQualifier();
10931093
}
10941094

1095+
bool BridgedInstruction::LoadBorrowInst_isUnchecked() const {
1096+
return (SwiftInt)getAs<swift::LoadBorrowInst>()->isUnchecked();
1097+
}
1098+
10951099
BridgedInstruction::BuiltinValueKind BridgedInstruction::BuiltinInst_getID() const {
10961100
return (BuiltinValueKind)getAs<swift::BuiltinInst>()->getBuiltinInfo().ID;
10971101
}

0 commit comments

Comments
 (0)