View definition


Defined in


ValueForExpr returns the SSA Value that corresponds to non-constant expression e.

It returns nil if no value was found, e.g.

- the expression is not lexically contained within f;
- f was not built with debug information; or
- e is a constant expression.  (For efficiency, no debug
  information is stored for constants. Use
  go/types.Info.Types[e].Value instead.)
- e is a reference to nil or a built-in function.
- the value was optimised away.

If e is an addressable expression used in an lvalue context, value is the address denoted by e, and isAddr is true.

The types of e (or &e, if isAddr) and the result are equal (modulo "untyped" bools resulting from comparisons).

(Tip: to find the ssa.Value given a source position, use importer.PathEnclosingInterval to locate the ast.Node, then EnclosingFunction to locate the Function, then ValueForExpr to find the ssa.Value.)

ValueForExpr is referenced in 10 repositories