MCPcopy Index your code
hub / github.com/python/mypy / is_pointer_arithmetic

Function is_pointer_arithmetic

mypyc/analysis/ircheck.py:227–239  ·  view source on GitHub ↗

Check if op is add/subtract targeting pointer_rprimitive and integer of the same size.

(op: IntOp)

Source from the content-addressed store, hash-verified

225
226
227def is_pointer_arithmetic(op: IntOp) -> bool:
228 """Check if op is add/subtract targeting pointer_rprimitive and integer of the same size."""
229 if op.op not in (IntOp.ADD, IntOp.SUB):
230 return False
231 if not is_pointer_rprimitive(op.type):
232 return False
233 left = op.lhs.type
234 right = op.rhs.type
235 if is_pointer_rprimitive(left):
236 return is_valid_ptr_displacement_type(right)
237 if is_pointer_rprimitive(right):
238 return is_valid_ptr_displacement_type(left)
239 return False
240
241
242class OpChecker(OpVisitor[None]):

Callers 1

visit_int_opMethod · 0.85

Calls 2

is_pointer_rprimitiveFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…