Skip to content

Commit

Permalink
[inferpython][capture] short_name is useless in Function
Browse files Browse the repository at this point in the history
Summary: this is never used

Reviewed By: thizanne

Differential Revision:
D67858533

Privacy Context Container: L1208441

fbshipit-source-id: d793cde50838b89aa35aec2a94637538fd4861c7
  • Loading branch information
davidpichardie authored and facebook-github-bot committed Jan 7, 2025
1 parent 15f8b09 commit f19a56c
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 208 deletions.
14 changes: 4 additions & 10 deletions infer/src/python/PyIR.ml
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ module Exp = struct
| Const of Const.t
| Function of
{ qual_name: QualName.t
; short_name: Ident.t
; default_values: t
; default_values_kw: t
; annotations: t
Expand Down Expand Up @@ -516,12 +515,9 @@ module Exp = struct
F.fprintf fmt "$LoadDeref(%d,\"%a\")" slot Ident.pp name
| LoadClassDeref {name; slot} ->
F.fprintf fmt "$LoadClassDeref(%d,\"%a\")" slot Ident.pp name
| Function
{qual_name; short_name; default_values; default_values_kw; annotations; cells_for_closure}
->
F.fprintf fmt "$MakeFunction[\"%a\", \"%a\", %a, %a, %a, %a]" Ident.pp short_name
QualName.pp qual_name pp default_values pp default_values_kw pp annotations pp
cells_for_closure
| Function {qual_name; default_values; default_values_kw; annotations; cells_for_closure} ->
F.fprintf fmt "$MakeFunction[\"%a\", %a, %a, %a, %a]" QualName.pp qual_name pp
default_values pp default_values_kw pp annotations pp cells_for_closure
| Yield exp ->
F.fprintf fmt "$Yield(%a)" pp exp

Expand Down Expand Up @@ -1267,7 +1263,6 @@ let make_function st flags =
internal_error st (Error.MakeFunction ("a code object", codeobj))
in
let* qual_name = read_code_qual_name st code in
let short_name = Ident.mk code.FFI.Code.co_name in
let* cells_for_closure, st =
if flags land 0x08 <> 0 then State.pop_and_cast st else Ok (Exp.none, st)
in
Expand All @@ -1282,8 +1277,7 @@ let make_function st flags =
in
let lhs, st = State.fresh_id st in
let rhs =
Exp.Function
{short_name; qual_name; default_values; default_values_kw; annotations; cells_for_closure}
Exp.Function {qual_name; default_values; default_values_kw; annotations; cells_for_closure}
in
let stmt = Stmt.Let {lhs; rhs} in
let st = State.push_stmt st stmt in
Expand Down
1 change: 0 additions & 1 deletion infer/src/python/PyIR.mli
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ module Exp : sig
| Const of Const.t
| Function of
{ qual_name: QualName.t
; short_name: Ident.t
; default_values: t
; default_values_kw: t
; annotations: t
Expand Down
4 changes: 1 addition & 3 deletions infer/src/python/PyIR2Textual.ml
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ let rec of_exp exp : Textual.Exp.t =
| GetAttr {exp; attr} ->
let attr = exp_of_ident_str attr in
call_builtin "py_get_attr" [of_exp exp; attr]
| Function
{qual_name; short_name= _; default_values; default_values_kw; annotations; cells_for_closure}
->
| Function {qual_name; default_values; default_values_kw; annotations; cells_for_closure} ->
let proc = mk_qualified_proc_name (RegularFunction qual_name) in
let closure =
Textual.Exp.Closure {proc; captured= [exp_globals]; params= [Parameter.locals]}
Expand Down
16 changes: 8 additions & 8 deletions infer/src/python/unit/PyExecTest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ print("fst(x, y) =", fst(x, y))
function toplevel():
b0:
n0 <- None
n3 <- $MakeFunction["fst", "dummy.fst", n0, n0, n0, n0]
n3 <- $MakeFunction["dummy.fst", n0, n0, n0, n0]
TOPLEVEL[fst] <- n3
TOPLEVEL[x] <- "x"
TOPLEVEL[y] <- "y"
Expand Down Expand Up @@ -119,9 +119,9 @@ print('n =', n)
function toplevel():
b0:
n0 <- None
n3 <- $MakeFunction["incr", "dummy.incr", n0, n0, n0, n0]
n3 <- $MakeFunction["dummy.incr", n0, n0, n0, n0]
TOPLEVEL[incr] <- n3
n4 <- $MakeFunction["no_effect", "dummy.no_effect", n0, n0, n0, n0]
n4 <- $MakeFunction["dummy.no_effect", n0, n0, n0, n0]
TOPLEVEL[no_effect] <- n4
GLOBAL[n] <- 0
n5 <- TOPLEVEL[incr]
Expand Down Expand Up @@ -181,7 +181,7 @@ print('fact(5) =', fact(5))
function toplevel():
b0:
n0 <- None
n3 <- $MakeFunction["fact", "dummy.fact", n0, n0, n0, n0]
n3 <- $MakeFunction["dummy.fact", n0, n0, n0, n0]
TOPLEVEL[fact] <- n3
n4 <- TOPLEVEL[print]
n5 <- TOPLEVEL[fact]
Expand Down Expand Up @@ -289,7 +289,7 @@ print('saved x is', C.saved_x)
b0:
n0 <- None
TOPLEVEL[x] <- "global"
n3 <- $MakeFunction["C", "dummy.C", n0, n0, n0, n0]
n3 <- $MakeFunction["dummy.C", n0, n0, n0, n0]
n4 <- $BuildClass(n3, "C", n0)
TOPLEVEL[C] <- n4
n5 <- TOPLEVEL[print]
Expand Down Expand Up @@ -323,9 +323,9 @@ print('saved x is', C.saved_x)
n4 <- TOPLEVEL[x]
TOPLEVEL[saved_x] <- n4
TOPLEVEL[x] <- "local to class body"
n5 <- $MakeFunction["get_x", "dummy.C.get_x", n0, n0, n0, n0]
n5 <- $MakeFunction["dummy.C.get_x", n0, n0, n0, n0]
TOPLEVEL[get_x] <- n5
n6 <- $MakeFunction["get_C_x", "dummy.C.get_C_x", n0, n0, n0, n0]
n6 <- $MakeFunction["dummy.C.get_C_x", n0, n0, n0, n0]
TOPLEVEL[get_C_x] <- n6
return n0

Expand Down Expand Up @@ -392,7 +392,7 @@ print(d)
n8 <- TOPLEVEL[d]
n9 <- $Call(n7, n8, n0)
TOPLEVEL[key1] <- "k1"
n10 <- $MakeFunction["key2", "dummy.key2", n0, n0, n0, n0]
n10 <- $MakeFunction["dummy.key2", n0, n0, n0, n0]
TOPLEVEL[key2] <- n10
n11 <- TOPLEVEL[key1]
n12 <- TOPLEVEL[key2]
Expand Down
Loading

0 comments on commit f19a56c

Please sign in to comment.