sun::borrow_checker::BorrowChecker
class · Source (opens in a new tab)
class sun::borrow_checker::BorrowCheckerMain borrow checker class Validates reference safety by tracking borrows across the AST.
Configuration is taken from sun::support::Config compile-time constants:
- FORBID_REF_RETURNS: If true, functions cannot return references
- FORBID_REF_FIELDS_IN_CLASSES: If true, classes cannot have ref fields
- STRICT_MUTATION_CHECKING: If true, disallow mutating borrowed variables
Types
- sun::borrow_checker::BorrowChecker::LifetimeValue (private)
- sun::borrow_checker::BorrowChecker::RefTargetInfo (private)
Public Functions
BorrowChecker
public · function · Source (opens in a new tab)
sun::borrow_checker::BorrowChecker::BorrowChecker()Initializes ownership checking with an empty scope and loan state.
check
public · function · Source (opens in a new tab)
std::vector< BorrowError > sun::borrow_checker::BorrowChecker::check(const sun::ast::BlockExprAST &program)Main entry point - check an entire program (BlockExprAST) Returns a list of borrow errors (empty if valid).
Related: BorrowError, sun::ast::BlockExprAST, BlockExprAST
Private Functions
- borrowHolderInputs
- borrowRefCallInputs
- checkArrayLiteral
- checkBinaryExpr
- checkBlockExpr
- checkBorrowBinding
- checkBorrowTargetIntact
- checkCallExpr
- checkCallMoveConflicts
- checkClassDef
- checkCompoundAssignment
- checkErasedLifetimeLambdaArgs
- checkExpr
- checkFieldsIntact
- checkForExpr
- checkForInExpr
- checkFrameStoreDepth
- checkFunctionDef
- checkIfExpr
- checkIndexExpr
- checkIndexedAssignment
- checkLambdaDef
- checkLoopBody
- checkMatchExpr
- checkMemberAccess
- checkMemberAssignment
- checkMoveAllowed
- checkNamedLifetimesAtCall
- checkReferenceCreation
- checkReturnLifetime
- checkReturnStmt
- checkTernaryExpr
- checkTryCatch
- checkUnsafeBlock
- checkVariableAssignment
- checkVariableCreation
- checkVariableReference
- checkVariableWrite
- checkWhileExpr
- classStoresMutableRefs
- classStoresRefs
- classStoresRefsWalk
- clearFieldPaths
- consumeOwnedValue
- destLifetimeValueForName
- enterFunctionScope
- enterScope
- exitFunctionScope
- exitScope
- fieldPath
- forEachHolderInput
- forbidFrameBoundByValueArgs
- getBaseVariableName
- getVariableName
- holderPointsIntoFrame
- inferCallReturnLifetime
- inferDestLifetimeValue
- inferEnvDepth
- inferEnvLifetimeValue
- inferExprLifetime
- isFrameBoundExpr
- isFrameSourcedLambdaExpr
- isRefCapturingLambdaExpr
- isRefExpr
- isReferenceType
- lifetimeValueOutlives
- lookupDeclDepth
- movedFieldOf
- nameOutlivesFrame
- noteFieldMove
- noteFrameSourcedLambdaStore
- noteLoopLocal
- recordMove
- reportConflict
- reportDanglingRef
- reportError
- reportFrameBoundEscapeThroughCall
- resolveRefTarget
- trackRef
- trackRefHolderStore
- typeContainsReference
borrowHolderInputs
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::borrowHolderInputs(const CallExprAST &call)A holder-producing call keeps pointing into its by-ref inputs after it returns, so the value holds a loan on each until scope exit.
Related: CallExprAST
borrowRefCallInputs
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::borrowRefCallInputs(const std::string &refName, const CallExprAST &call, bool isMutable, const sun::support::Position &refPos)Binding a ref-returning call's result to a name borrows every named variable the call could hand back a reference into: the receiver and each argument bound to a ref parameter.
Related: CallExprAST, sun::support::Position
checkArrayLiteral
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkArrayLiteral(const sun::ast::ArrayLiteralAST &literal)Checks ownership and lifetime rules for this array literal and updates active loans.
Related: sun::ast::ArrayLiteralAST
checkBinaryExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkBinaryExpr(const sun::ast::BinaryExprAST &binary)Checks ownership and lifetime rules for this binary expression and updates active loans.
Related: sun::ast::BinaryExprAST
checkBlockExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkBlockExpr(const sun::ast::BlockExprAST &block, size_t start=0)Checks ownership and lifetime rules for this block expression and updates active loans.
Related: sun::ast::BlockExprAST
checkBorrowBinding
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkBorrowBinding(const std::string &refName, const ExprAST &targetExpr, bool isMutable, const sun::support::Position &refPos)Shared by ref r = lvalue and var r: ref T = lvalue: both bind a borrow of the lvalue's storage rather than moving a value into r.
Related: ExprAST, sun::support::Position
checkBorrowTargetIntact
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkBorrowTargetIntact(const ExprAST &target, const sun::support::Position &refPos)Rejects borrowing a value whose ownership has already been moved.
Related: ExprAST, sun::support::Position
checkCallExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkCallExpr(const CallExprAST &call)Checks ownership and lifetime rules for this call expression and updates active loans.
Related: CallExprAST
checkCallMoveConflicts
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkCallMoveConflicts(const CallExprAST &call, const std::vector< TypePtr > ¶mTypes)Reject calls that borrow and move overlapping storage.
Related: CallExprAST, TypePtr
checkClassDef
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkClassDef(const sun::ast::ClassDefinitionAST &classDef)Checks ownership and lifetime rules for this class definition and updates active loans.
Related: sun::ast::ClassDefinitionAST
checkCompoundAssignment
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkCompoundAssignment(const sun::ast::CompoundAssignmentAST &assign)Checks ownership and lifetime rules for this compound assignment and updates active loans.
Related: sun::ast::CompoundAssignmentAST
checkErasedLifetimeLambdaArgs
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkErasedLifetimeLambdaArgs(const CallExprAST &call, const std::vector< TypePtr > ¶mTypes)Conservatively relate callbacks whose generic parameters lost lifetime names to every receiver and mutable-ref destination the callee can keep.
Related: CallExprAST, TypePtr
checkExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkExpr(const ExprAST &expr)AST traversal methods.
Related: ExprAST
checkFieldsIntact
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::checkFieldsIntact(const std::string &name, const sun::support::Position &pos)Reject moving a whole object whose field was moved out.
Returns true if name may be moved.
Related: sun::support::Position
checkForExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkForExpr(const sun::ast::ForExprAST &forExpr)Checks ownership and lifetime rules for this for loop and updates active loans.
Related: sun::ast::ForExprAST
checkForInExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkForInExpr(const sun::ast::ForInExprAST &forInExpr)Checks ownership and lifetime rules for this iteration loop and updates active loans.
Related: sun::ast::ForInExprAST
checkFrameStoreDepth
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::checkFrameStoreDepth(const std::string &destBase, size_t envDepth, const sun::support::Position &pos)A frame-sourced environment pinned at envDepth is entering the named frame-local destination.
Rejects the store when the destination's scope outlives the environment's - it would hold a dangling environment once the inner scope ends. Returns true when the store is allowed.
Related: sun::support::Position
checkFunctionDef
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkFunctionDef(const sun::ast::FunctionAST &func)Checks ownership and lifetime rules for this function definition and updates active loans.
Related: sun::ast::FunctionAST
checkIfExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkIfExpr(const sun::ast::IfExprAST &ifExpr)Checks ownership and lifetime rules for this if expression and updates active loans.
Related: sun::ast::IfExprAST
checkIndexExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkIndexExpr(const sun::ast::IndexAST &index)Checks ownership and lifetime rules for this index expression and updates active loans.
Related: sun::ast::IndexAST
checkIndexedAssignment
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkIndexedAssignment(const sun::ast::IndexedAssignmentAST &assign)Checks ownership and lifetime rules for this indexed assignment and updates active loans.
Related: sun::ast::IndexedAssignmentAST
checkLambdaDef
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkLambdaDef(const sun::ast::LambdaAST &lambda)Checks ownership and lifetime rules for this lambda definition and updates active loans.
Related: sun::ast::LambdaAST
checkLoopBody
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkLoopBody(const ExprAST *body, const std::vector< std::string > &loopVars={})Check a loop body: a move that is still standing when the body ends would run again on the next iteration, using a value that is already gone.
Related: ExprAST
checkMatchExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkMatchExpr(const MatchExprAST &matchExpr)Checks ownership and lifetime rules for this match expression and updates active loans.
Related: MatchExprAST
checkMemberAccess
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkMemberAccess(const sun::ast::MemberAccessAST &access)Checks ownership and lifetime rules for this member access and updates active loans.
Related: sun::ast::MemberAccessAST
checkMemberAssignment
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkMemberAssignment(const sun::ast::MemberAssignmentAST &assign)Checks ownership and lifetime rules for this member assignment and updates active loans.
Related: sun::ast::MemberAssignmentAST
checkMoveAllowed
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::checkMoveAllowed(const std::string &name, const sun::support::Position &pos)Reject moving out of a match binding / frozen discriminant.
Returns true if name may be moved.
Related: sun::support::Position
checkNamedLifetimesAtCall
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkNamedLifetimesAtCall(const CallExprAST &call, const std::vector< TypePtr > ¶mTypes)Enforce a callee's named-lifetime relations at one call: bind each name to its contributing arguments, require every source to outlive every destination sharing the name, and mark caller-local destinations frame-bound at the sources' depth.
Related: CallExprAST, TypePtr
checkReferenceCreation
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkReferenceCreation(const sun::ast::ReferenceCreationAST &ref)Checks ownership and lifetime rules for this reference creation and updates active loans.
Related: sun::ast::ReferenceCreationAST
checkReturnLifetime
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkReturnLifetime(const sun::ast::ReturnExprAST &ret)Check that a return statement's lifetime is valid.
A ref return is only valid if the returned value's lifetime is tied to a parameter (not a local variable).
Related: sun::ast::ReturnExprAST
checkReturnStmt
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkReturnStmt(const sun::ast::ReturnExprAST &ret)Checks ownership and lifetime rules for this return statement and updates active loans.
Related: sun::ast::ReturnExprAST
checkTernaryExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkTernaryExpr(const sun::ast::TernaryExprAST &ternary)Checks ownership and lifetime rules for this ternary expression and updates active loans.
Related: sun::ast::TernaryExprAST
checkTryCatch
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkTryCatch(const sun::ast::TryCatchExprAST &tryCatch)Checks ownership and lifetime rules for this try catch and updates active loans.
Related: sun::ast::TryCatchExprAST
checkUnsafeBlock
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkUnsafeBlock(const sun::ast::UnsafeBlockAST &unsafeBlock)Checks ownership and lifetime rules for this unsafe block and updates active loans.
Related: sun::ast::UnsafeBlockAST
checkVariableAssignment
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkVariableAssignment(const sun::ast::VariableAssignmentAST &assign)Checks ownership and lifetime rules for this variable assignment and updates active loans.
Related: sun::ast::VariableAssignmentAST
checkVariableCreation
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkVariableCreation(const sun::ast::VariableCreationAST &var)Specific node handlers.
Related: sun::ast::VariableCreationAST
checkVariableReference
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkVariableReference(const sun::ast::VariableReferenceAST &varRef)Checks ownership and lifetime rules for this variable reference and updates active loans.
Related: sun::ast::VariableReferenceAST
checkVariableWrite
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkVariableWrite(const std::string &varName, const TypePtr &valueType, const sun::support::Position &pos)Checks whether active loans permit replacing the named variable.
Related: TypePtr, sun::support::Position
checkWhileExpr
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::checkWhileExpr(const sun::ast::WhileExprAST &whileExpr)Checks ownership and lifetime rules for this while expression and updates active loans.
Related: sun::ast::WhileExprAST
classStoresMutableRefs
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::classStoresMutableRefs(const TypePtr &type) constDoes this class hold a mutable reference anywhere in its fields?
Related: TypePtr
classStoresRefs
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::classStoresRefs(const TypePtr &type) constDoes this type point into storage it does not own - a reference in any field, transitively, or a '<'_>' lambda environment it can carry?
Related: TypePtr
classStoresRefsWalk
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::classStoresRefsWalk(const TypePtr &type, std::unordered_set< const sun::types::Type * > &visited) constRecursively checks class fields for references while avoiding type cycles.
Related: TypePtr, sun::types::Type
clearFieldPaths
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::clearFieldPaths(const std::string &base)Forget every field path under base (it was reassigned or moved away).
consumeOwnedValue
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::consumeOwnedValue(const ExprAST &value)Records ownership transfers through expressions, including blocks and parentheses.
Related: ExprAST
destLifetimeValueForName
private · function · Source (opens in a new tab)
BorrowChecker::LifetimeValue sun::borrow_checker::BorrowChecker::destLifetimeValueForName(const std::string &base) constThe same, for a plain name (an assignment target).
Related: LifetimeValue
enterFunctionScope
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::enterFunctionScope(const std::string &funcName)Starts ownership tracking for the named function.
enterScope
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::enterScope()Scope management.
exitFunctionScope
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::exitFunctionScope()Leaves the current function and clears its function-local borrow state.
exitScope
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::exitScope()Leaves the current lexical scope and ends the loans created within it.
fieldPath
private · function · Source (opens in a new tab)
std::string sun::borrow_checker::BorrowChecker::fieldPath(const ExprAST &expr) const"cfg.line" for a read of a field of a named object; empty when the expression is not one (a temporary, a call result, an enum constant, a module-qualified name, a method).
Related: ExprAST
forEachHolderInput
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::forEachHolderInput(const CallExprAST &call, const std::function< void(const ExprAST &input, bool mutableRef)> &visit) constVisit the by-ref inputs a holder-producing call keeps pointing into: a constructor of a ref-storing class visits the arguments bound to its ref init parameters; a call returning such a class by value visits the receiver and the arguments bound to ref parameters.
mutableRef says whether the holder may write through that input. Returns false when the call produces no holder.
Related: CallExprAST, ExprAST
forbidFrameBoundByValueArgs
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::forbidFrameBoundByValueArgs(const CallExprAST &call, const std::vector< TypePtr > ¶mTypes)Reject frame-bound arguments bound to by-value parameters: the callee could keep them past this frame's death, and nothing in the parameter type says so.
Related: CallExprAST, TypePtr
getBaseVariableName
private · function · Source (opens in a new tab)
const std::string * sun::borrow_checker::BorrowChecker::getBaseVariableName(const ExprAST &expr) constReturns the base variable name stored by this object.
Related: ExprAST
getVariableName
private · function · Source (opens in a new tab)
const std::string * sun::borrow_checker::BorrowChecker::getVariableName(const ExprAST &expr) constGet the name of the variable being referenced (if expression is a variable ref).
Related: ExprAST
holderPointsIntoFrame
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::holderPointsIntoFrame(const ExprAST &value) constDoes a ref-storing value point into this frame?
A construction or holder-returning call fed a frame-local (or a temporary) by ref, or a local whose recorded bound names one. A holder built only from this, ref parameters and globals points at storage the caller owns.
Related: ExprAST
inferCallReturnLifetime
private · function · Source (opens in a new tab)
Lifetime sun::borrow_checker::BorrowChecker::inferCallReturnLifetime(const CallExprAST &call) constWhen a function returns ref and any ref param received a temporary, the return value has local lifetime (can't be stored).
This tracks whether the current expression being analyzed came from a call where temporaries were passed to ref params. Infer the lifetime of a call expression's return value, considering whether temporaries were passed to ref params.
Related: Lifetime, CallExprAST
inferDestLifetimeValue
private · function · Source (opens in a new tab)
BorrowChecker::LifetimeValue sun::borrow_checker::BorrowChecker::inferDestLifetimeValue(const ExprAST &arg) constThe lifetime of the storage a call argument lets the callee write into: the referent's declaration for a local, symbolic for a named ref parameter, outlives for an elided one.
Related: LifetimeValue, ExprAST
inferEnvDepth
private · function · Source (opens in a new tab)
size_t sun::borrow_checker::BorrowChecker::inferEnvDepth(const ExprAST &expr) constThe scope depth a frame-sourced value's environment is pinned to: the deepest declaration among a capture list's borrowed variables, a bound method's receiver's declaration, or a tracked local's recorded bound.
An environment that only depends on storage outliving the frame ranks as functionScopeDepth_, valid anywhere in the frame.
Related: ExprAST
inferEnvLifetimeValue
private · function · Source (opens in a new tab)
BorrowChecker::LifetimeValue sun::borrow_checker::BorrowChecker::inferEnvLifetimeValue(const ExprAST &expr) constThe lifetime of the captured environment an expression's value carries: concrete for frame-sourced values, symbolic for named parameters and calls composed of them, outlives for everything else.
Related: LifetimeValue, ExprAST
inferExprLifetime
private · function · Source (opens in a new tab)
Lifetime sun::borrow_checker::BorrowChecker::inferExprLifetime(const ExprAST &expr) constInfer the lifetime of an expression.
- Variable references return the variable's lifetime
- Member access inherits the object's lifetime
- Parameters have param lifetimes (outlive function body)
- Locals have local lifetimes (bound to their scope)
isFrameBoundExpr
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::isFrameBoundExpr(const ExprAST &expr) constA value that must not leave this frame: a call result built from a lambda with a capture list (spawn stores that lambda inside the Thread handle it returns), a local such a result was moved into, or a literal holding one.
See frameBoundVars_.
Related: ExprAST
isFrameSourcedLambdaExpr
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::isFrameSourcedLambdaExpr(const ExprAST &expr) constA lambda value whose captured environment provably lives in THIS frame: a capture-list literal, a bound method of a frame-local receiver, or a local one of those was assigned to.
See frameSourcedLambdas_.
Related: ExprAST
isRefCapturingLambdaExpr
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::isRefCapturingLambdaExpr(const ExprAST &expr) constReports whether a lambda expression retains borrowed captures.
Related: ExprAST
isRefExpr
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::isRefExpr(const ExprAST &expr) constCheck if an expression evaluates to a reference.
Related: ExprAST
isReferenceType
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::isReferenceType(const TypePtr &type) constHelper to check if a type is or contains a reference.
Related: TypePtr
lifetimeValueOutlives
private · function · static · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::lifetimeValueOutlives(const LifetimeValue &src, const LifetimeValue &dst)Does a value with lifetime src provably live at least as long as storage with lifetime dst?
Related: LifetimeValue
lookupDeclDepth
private · function · Source (opens in a new tab)
size_t sun::borrow_checker::BorrowChecker::lookupDeclDepth(const std::string &name) constThe scope depth the named storage was declared at, resolving ref aliases to their ultimate target.
Names that outlive the frame - this, ref parameters, globals - rank as 0: outer than every local.
movedFieldOf
private · function · Source (opens in a new tab)
const std::string * sun::borrow_checker::BorrowChecker::movedFieldOf(const std::string &name) constThe field of name that is currently moved out, if any.
nameOutlivesFrame
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::nameOutlivesFrame(const std::string &base) constTrue when the named place outlives this frame: this, a ref parameter's referent, or a global (any name this frame did not declare).
noteFieldMove
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::noteFieldMove(const ExprAST &value)Record that value moved a compound field out of its object.
Related: ExprAST
noteFrameSourcedLambdaStore
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::noteFrameSourcedLambdaStore(const std::string &destBase, size_t envDepth, const sun::support::Position &pos)A frame-sourced lambda is being stored into the named destination: reject if the destination outlives the frame or was declared in an outer scope than the lambda's environment, otherwise mark the destination frame-bound so the carrier cannot cross a call boundary.
Related: sun::support::Position
noteLoopLocal
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::noteLoopLocal(const std::string &name)Note a declaration in every enclosing loop body.
recordMove
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::recordMove(const std::string &place, const sun::support::Position &pos)Record that place (a variable name or a field path) was moved here.
Related: sun::support::Position
reportConflict
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::reportConflict(const std::string &msg, const sun::support::Position &pos, const Loan &conflict)Reports an ownership violation together with the loan that caused it.
Related: sun::support::Position, Loan
reportDanglingRef
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::reportDanglingRef(const std::string &varName, const sun::support::Position &pos)Report a dangling reference error.
Related: sun::support::Position
reportError
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::reportError(const std::string &msg, const sun::support::Position &pos)Error reporting - positions carry the file path so the driver can render the standard source-line-and-caret format.
Related: sun::support::Position
reportFrameBoundEscapeThroughCall
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::reportFrameBoundEscapeThroughCall(const sun::support::Position &pos)Reports a call that could let a frame-bound value escape its lifetime.
Related: sun::support::Position
resolveRefTarget
private · function · Source (opens in a new tab)
BorrowChecker::RefTargetInfo sun::borrow_checker::BorrowChecker::resolveRefTarget(const std::string &targetVarName) constResolve the actual target of a reference creation Handles rebinding through refs, ref params, and direct variable refs.
Related: RefTargetInfo
trackRef
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::trackRef(const std::string &refName, const std::string &targetVar, BorrowKind kind=BorrowKind::Mutable)Track reference variables in current scope.
Related: BorrowKind, BorrowKind::Mutable
trackRefHolderStore
private · function · Source (opens in a new tab)
void sun::borrow_checker::BorrowChecker::trackRefHolderStore(const std::string &destName, size_t destDepth, const ExprAST &value, const sun::support::Position &pos)A ref-storing class value is landing in the named destination (a fresh construction, or a holder local moved in).
Rejects a destination that outlives what the value borrows, and records the destination's own bound so later moves keep the whole journey in check.
Related: ExprAST, sun::support::Position
typeContainsReference
private · function · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::typeContainsReference(const TypePtr &type) constReports whether a value of this type can contain a borrowed reference.
Related: TypePtr
Private Fields
- activeClassLifetimes_
- classesWithRefFields_
- currentFunctionReturnsRef_
- currentFunction_
- currentScope_
- declDepths_
- discoveringMatchMoves_
- errors_
- fieldBaseDepth_
- frameBoundVars_
- frameLocalNames_
- frameSourcedLambdas_
- frozenDiscriminants_
- functionReturnTypes_
- functionScopeDepth_
- lambdaProtoStack_
- loopLocals_
- matchBorrowedBindings_
- matchConsumes_
- matchPayloadSources_
- matchResultLifetimes_
- moveLocations_
- movedVariables_
- nextLifetimeId_
- paramEnvNames_
- paramLifetimes_
- rawPointerLocals_
- refHolderBounds_
- refParamClassBindings_
- refParamNames_
- refTypedParams_
- refVariables_
- returnLifetimeName_
- state_
activeClassLifetimes_
private · variable · Source (opens in a new tab)
std::vector<std::string> sun::borrow_checker::BorrowChecker::activeClassLifetimes_No documentation comment.
classesWithRefFields_
private · variable · Source (opens in a new tab)
std::unordered_set<std::string> sun::borrow_checker::BorrowChecker::classesWithRefFields_No documentation comment.
currentFunctionReturnsRef_
private · variable · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::currentFunctionReturnsRef_ = falseNo documentation comment.
currentFunction_
private · variable · Source (opens in a new tab)
std::string sun::borrow_checker::BorrowChecker::currentFunction_No documentation comment.
currentScope_
private · variable · Source (opens in a new tab)
size_t sun::borrow_checker::BorrowChecker::currentScope_ = 0No documentation comment.
declDepths_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, size_t> sun::borrow_checker::BorrowChecker::declDepths_No documentation comment.
discoveringMatchMoves_
private · variable · Source (opens in a new tab)
bool sun::borrow_checker::BorrowChecker::discoveringMatchMoves_ = falseNo documentation comment.
errors_
private · variable · Source (opens in a new tab)
std::vector<BorrowError> sun::borrow_checker::BorrowChecker::errors_No documentation comment.
Related: BorrowError
fieldBaseDepth_
private · variable · Source (opens in a new tab)
int sun::borrow_checker::BorrowChecker::fieldBaseDepth_ = 0No documentation comment.
frameBoundVars_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, size_t> sun::borrow_checker::BorrowChecker::frameBoundVars_No documentation comment.
frameLocalNames_
private · variable · Source (opens in a new tab)
std::unordered_set<std::string> sun::borrow_checker::BorrowChecker::frameLocalNames_No documentation comment.
frameSourcedLambdas_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, size_t> sun::borrow_checker::BorrowChecker::frameSourcedLambdas_No documentation comment.
frozenDiscriminants_
private · variable · Source (opens in a new tab)
std::unordered_set<std::string> sun::borrow_checker::BorrowChecker::frozenDiscriminants_No documentation comment.
functionReturnTypes_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, TypePtr> sun::borrow_checker::BorrowChecker::functionReturnTypes_No documentation comment.
Related: TypePtr
functionScopeDepth_
private · variable · Source (opens in a new tab)
size_t sun::borrow_checker::BorrowChecker::functionScopeDepth_ = 0No documentation comment.
lambdaProtoStack_
private · variable · Source (opens in a new tab)
std::vector<const sun::ast::PrototypeAST*> sun::borrow_checker::BorrowChecker::lambdaProtoStack_No documentation comment.
Related: sun::ast::PrototypeAST
loopLocals_
private · variable · Source (opens in a new tab)
std::vector<std::unordered_set<std::string> > sun::borrow_checker::BorrowChecker::loopLocals_No documentation comment.
matchBorrowedBindings_
private · variable · Source (opens in a new tab)
std::unordered_set<std::string> sun::borrow_checker::BorrowChecker::matchBorrowedBindings_No documentation comment.
matchConsumes_
private · variable · Source (opens in a new tab)
std::unordered_map<const MatchExprAST*, bool> sun::borrow_checker::BorrowChecker::matchConsumes_No documentation comment.
Related: MatchExprAST
matchPayloadSources_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, const MatchExprAST*> sun::borrow_checker::BorrowChecker::matchPayloadSources_No documentation comment.
Related: MatchExprAST
matchResultLifetimes_
private · variable · Source (opens in a new tab)
std::unordered_map<const MatchExprAST*, Lifetime> sun::borrow_checker::BorrowChecker::matchResultLifetimes_No documentation comment.
Related: MatchExprAST, Lifetime
moveLocations_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, sun::support::Position> sun::borrow_checker::BorrowChecker::moveLocations_No documentation comment.
Related: sun::support::Position
movedVariables_
private · variable · Source (opens in a new tab)
std::unordered_set<std::string> sun::borrow_checker::BorrowChecker::movedVariables_No documentation comment.
nextLifetimeId_
private · variable · Source (opens in a new tab)
uint32_t sun::borrow_checker::BorrowChecker::nextLifetimeId_ = 0No documentation comment.
paramEnvNames_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, std::string> sun::borrow_checker::BorrowChecker::paramEnvNames_No documentation comment.
paramLifetimes_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, Lifetime> sun::borrow_checker::BorrowChecker::paramLifetimes_No documentation comment.
Related: Lifetime
rawPointerLocals_
private · variable · Source (opens in a new tab)
std::unordered_set<std::string> sun::borrow_checker::BorrowChecker::rawPointerLocals_No documentation comment.
refHolderBounds_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, size_t> sun::borrow_checker::BorrowChecker::refHolderBounds_No documentation comment.
refParamClassBindings_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, std::vector<std::string> > sun::borrow_checker::BorrowChecker::refParamClassBindings_No documentation comment.
refParamNames_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, std::string> sun::borrow_checker::BorrowChecker::refParamNames_No documentation comment.
refTypedParams_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, bool> sun::borrow_checker::BorrowChecker::refTypedParams_No documentation comment.
refVariables_
private · variable · Source (opens in a new tab)
std::unordered_map<std::string, std::pair<std::string, BorrowKind> > sun::borrow_checker::BorrowChecker::refVariables_No documentation comment.
Related: BorrowKind
returnLifetimeName_
private · variable · Source (opens in a new tab)
std::string sun::borrow_checker::BorrowChecker::returnLifetimeName_No documentation comment.
state_
private · variable · Source (opens in a new tab)
BorrowState sun::borrow_checker::BorrowChecker::state_No documentation comment.
Related: BorrowState