proc: save location expr and decl line for escaped variables (#1553)

Copy the location expression and declaration line of escaped variables
when auto-dereferencing them.
This commit is contained in:
Alessandro Arzilli
2019-05-23 22:07:13 +02:00
committed by Derek Parker
parent c30a333f7b
commit 04834a781a

View File

@ -2287,12 +2287,16 @@ func (scope *EvalScope) Locals() ([]*Variable, error) {
for i, v := range vars {
if name := v.Name; len(name) > 1 && name[0] == '&' {
locationExpr := v.LocationExpr
declLine := v.DeclLine
v = v.maybeDereference()
if v.Addr == 0 {
v.Unreadable = fmt.Errorf("no address for escaped variable")
}
v.Name = name[1:]
v.Flags |= VariableEscaped
v.LocationExpr = locationExpr + " (escaped)"
v.DeclLine = declLine
vars[i] = v
}
if hasScopes {