Module PointsTo

Part of the combined points-to, call-graph and type-inference library. The main relation points_to(node, context, object, cls, origin) relates a control flow node to the possible objects it points-to the inferred types of those objects and the ‘origin’ of those objects. The ‘origin’ is the point in source code that the object can be traced back to.

The predicates provided are not intended to be used directly (although they are available to the advanced user), but are exposed in the user API as methods on key classes.

For example, the most important predicate in the points-to relation is:

predicate PointsTo::points_to(ControlFlowNode f, PointsToContext ctx, Object value, ClassObject cls, ControlFlowNode origin)

Where f is the control flow node representing something that might hold a value. ctx is the context in which f “points-to” value and may be “general” or from a specific call-site. value is a static approximation to a value, such as a number, a class, or an object instantiation. cls is the class of this value if known, or theUnknownType() which is an internal ClassObject and should not be exposed to the general QL user. origin is the point in the source from where value originates and is useful when presenting query results.

The PointsTo::points_to relation is exposed at the user API level as

ControlFlowNode.refersTo(Context context, Object value, ClassObject cls, ControlFlowNode origin)

Import path

semmle.python.pointsto.PointsTo

Imports

SSA

Library for SSA representation (Static Single Assignment form).

python

Classes

Modules