Skip to main content

Module analysis

Module analysis 

Source
Expand description

Shared, side-effect-free HIR probes reused by Solidity lints.

ModulesΒ§

access_control πŸ”’
Access-control guard detection: whether a function dominates its body with a check comparing the caller against contract state, and which state that check depends on.
exprs πŸ”’
Expression-shape probes over Solar HIR (and a few AST-level ones).
helper_cache πŸ”’
modifier_outcome πŸ”’
Control-flow summary of modifier bodies with respect to the _ placeholder.
stmts πŸ”’
Statement-shape probes over Solar HIR.
types πŸ”’
Type probes using Solar’s type-checker results.

StructsΒ§

HelperAnalysisCache
Bounded memo table for lint analyses that inline internal helper calls.
Outcome
Summary of how control flow can leave a statement or block without having executed the placeholder (_) or reverted.

ConstantsΒ§

DEFAULT_HELPER_ANALYSIS_CACHE_LIMIT
OPENZEPPELIN_ROOTS
Package-root directory names of the OpenZeppelin distributions (npm scope and git submodules).

FunctionsΒ§

access_check_polarity
Some(true) when expr holding means the caller is authorized, Some(false) when it means the caller is not authorized, None when expr is not an access check. An access check reads msg.sender/tx.origin (directly, through aliases or through a helper) and state (directly or through a helper).
address_call_receiver
Receiver of <expr>.{call,delegatecall,transfer,send} (value-bearing sinks), including the .call{value: x}(...) option form.
any_subexpr
True if pred holds for expr or any of its sub-expressions.
arg_for_param
The argument bound to param of function_id in args, positional or named.
ast_bool_literal
AST-level boolean literal, through parens.
block_outcome
branch_always_exits
True when executing stmt provably prevents control from continuing past it: return, revert, selfdestruct, require(false, ..) / assert(false), a block containing any such statement, an if whose both arms exit, a try whose every clause exits, or a do-while whose body exits without break/continue.
callee_no_arg_returns
True when callee names a zero-parameter function whose body returns an expression matching pred.
cast_type
The elementary type an explicit cast head T(...) converts to.
count_placeholders
Number of _ placeholders in stmts, recursing into nested control flow.
dispatched_function
The function an internal call made from within contract_id dispatches to: a virtual call resolves to the most derived override, super.f to the next base implementation, and a qualified Base.f to that declaration exactly. None for external and unresolved callees.
do_while_user_stmts
Strips the trailing if (cond) break; that lowers do { ... } while (cond);.
expr_is_address
True when expr’s type-checked static type is address / address payable.
expr_reads_sender
Whether expr reads msg.sender/tx.origin, one of aliases, or calls a user function that reads the sender.
expr_state_vars
State variables read by expr, following calls into user functions.
for_each_child
Calls f on every direct sub-expression of expr, in evaluation order.
for_each_lhs_var
Calls f for each resolved variable at the root of an lvalue, peeling index/slice/member/payable/unary/delete wrappers and tuple destructuring.
function_no_arg_returns
True when fid takes no parameters and its body is return e; or namedRet = e; (optionally followed by a bare return;) with pred(e).
function_reads_sender
Whether the body of func_id reads msg.sender/tx.origin, following calls.
function_state_vars
State variables read by the body of func_id, following calls into user functions.
guard_vars
State variables the access checks of func_id and its modifiers (up to _) depend on.
has_access_guard
Whether func_id checks the caller before its _ placeholder (anywhere for functions): a guarding if, a require/assert on an access check, or a call into a function that does. Bodyless declarations (interface functions, virtual modifiers) fall back to a name heuristic.
has_side_effect
True if evaluating expr performs an assignment, delete or increment/decrement.
is_address_cast
address(...) / address payable(...) cast head.
is_address_like_cast
address(...) or IFoo(...) cast head.
is_address_self
address(this), payable(this), IFoo(this), IFoo(address(this)), or bare this.
is_address_type
True if vid is typed as address/address payable.
is_break_stmt
break, possibly wrapped in single-statement blocks.
is_builtin
True if expr resolves to the given builtin name.
is_call_with_gas_limit
True if a HIR call carries an explicit gas: option.
is_contract_cast
IFoo(...) contract / interface cast head.
is_elementary
True if id’s elementary type matches the given ABI string.
is_exit_call
revert(...), selfdestruct(...), require(false, ...) or assert(false).
is_literal_false
The boolean literal false.
is_literal_zero
The integer literal 0.
is_loop_termination_if
if (...) break; as synthesized by the do-while lowering.
is_low_level_call
AST-level: target.call(...), .delegatecall(...), .staticcall(...), with or without {value: x} options.
is_msg_sender
msg.sender.
is_protected
True when the function or one of its modifiers contains a dominating access check.
is_require_or_assert
True if callee resolves to the builtin require or assert.
is_revert_call
revert(...), revert Err(...)-style builtin revert call (any form).
is_sender_member
msg.sender or tx.origin.
is_zero_value
A literal zero/false or an elementary cast or arithmetic negation of one.
lhs_local_var
The local (non-state) variable a bare identifier refers to.
looks_like_access_control
A function whose name marks it as an access check (auth, onlyOwner, _checkRole, …) and that returns nothing, so calling it for its effect is meaningful.
loop_stmts
The statements of one loop iteration: the body followed by the for update, if any.
loop_update
The for update statement of a loop, which runs after every iteration.
modifier_prefix
The statements a modifier runs before its unique _;, when that placeholder is reached unconditionally. None for non-modifiers, bodiless modifiers and conditional placeholders.
modifiers_and_self
The modifiers of func_id that resolve to functions, followed by func_id itself.
receiver_contract_id
Static contract type of a method-call receiver or direct contract/library reference.
referenced_item
The item a bare identifier refers to, if any.
runtime_entry_points
The functions reachable through the runtime dispatch of a most-derived contract: its interface functions plus the inherited fallback/receive, if any.
source_in_package
True if the source file of source_id lives under one of the given package-root directory names (matched as whole, case-insensitive path components).
state_lhs_vars
State variables written by an lvalue: peels index/slice/member/payable/unary/delete wrappers and tuple destructuring. Duplicates are removed.
stmt_expr
The expression directly owned by stmt (nested statements excluded).
stmts_before_placeholder
Collects the statements executed before the first placeholder of a modifier body, following nested blocks. Returns None when the placeholder is not reached unconditionally (e.g. it is inside an if, loop or try).
stmts_break_or_continue
break/continue targeting the current loop (nested loops shadow them).
tuple_elems
The elements of a tuple expression (through parens).
ty_contract_id
The contract a type denotes, through references and type(C).
ty_is_address
address / address payable after peeling references.
underlying_var
The variable a bare identifier refers to, looking through parens, payable(...) and address-like casts (address(x), IFoo(x)).
unique
The only element of iter, or None when it has zero or several.
var_is_address_like
address / address payable or a contract/interface type.
visit_stmts
Runs f on every statement of stmts and their nested statements (pre-order) until it breaks.
write_target
The lvalue written by an assignment, delete or increment/decrement expression.