Merge pull request #74707 from jckarter/consume-during-borrow-checks

MoveOnlyAddressChecker: More robust checking for consume-during-borrow.
This commit is contained in:
Joe Groff
2024-06-26 08:22:04 -07:00
committed by GitHub
13 changed files with 153 additions and 28 deletions

View File

@@ -4591,14 +4591,29 @@ public:
/// instruction in its use-def list.
class LoadBorrowInst :
public UnaryInstructionBase<SILInstructionKind::LoadBorrowInst,
SingleValueInstruction> {
SingleValueInstruction>
{
friend class SILBuilder;
bool Unchecked = false;
public:
LoadBorrowInst(SILDebugLocation DebugLoc, SILValue LValue)
: UnaryInstructionBase(DebugLoc, LValue,
LValue->getType().getObjectType()) {}
// True if the invariants on `load_borrow` have not been checked and
// should not be strictly enforced.
//
// This can only occur during raw SIL before move-only checking occurs.
// Developers can write incorrect code using noncopyable types that
// consumes or mutates a memory location while that location is borrowed,
// but the move-only checker must diagnose those problems before canonical
// SIL is formed.
bool isUnchecked() const { return Unchecked; }
void setUnchecked(bool value) { Unchecked = value; }
using EndBorrowRange =
decltype(std::declval<ValueBase>().getUsersOfType<EndBorrowInst>());