[infer][java] compute the start and exit node location from the bytecode instead of from the JBir representation

Summary: depends on D6609425

Reviewed By: sblackshear

Differential Revision: D6609860

fbshipit-source-id: 64f5c8b
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent 3fb25e2a74
commit 5ce859c774

@ -59,6 +59,21 @@ let get_location source_file impl pc =
{Location.line= line_number; col= -1; file= source_file} {Location.line= line_number; col= -1; file= source_file}
let get_start_location source_file bytecode =
let line_number = Option.value (JCode.get_source_line_number 0 bytecode) ~default:(-1) in
{Location.line= line_number; col= -1; file= source_file}
let get_exit_location source_file bytecode =
let last_line_number =
let cmp (_, ln1) (_, ln2) = Int.compare ln1 ln2 in
Option.value_map ~default:(-1)
~f:(fun l -> Option.value_map ~f:snd ~default:(-1) (List.max_elt ~cmp l))
bytecode.JCode.c_line_number_table
in
{Location.line= last_line_number; col= -1; file= source_file}
let retrieve_fieldname fieldname = let retrieve_fieldname fieldname =
try try
let subs = Str.split (Str.regexp (Str.quote ".")) (Typ.Fieldname.to_string fieldname) in let subs = Str.split (Str.regexp (Str.quote ".")) (Typ.Fieldname.to_string fieldname) in
@ -348,10 +363,9 @@ let create_cm_procdesc source_file program linereader icfg cm proc_name skip_imp
({name; typ; attributes= []} : ProcAttributes.var_data) ) ({name; typ; attributes= []} : ProcAttributes.var_data) )
in in
let loc_start = let loc_start =
let loc = get_location source_file jbir_code 0 in get_start_location source_file bytecode |> fix_method_definition_line linereader proc_name
fix_method_definition_line linereader proc_name loc
in in
let loc_exit = get_location source_file jbir_code (Array.length (JBir.code jbir_code) - 1) in let loc_exit = get_exit_location source_file bytecode in
let method_annotation = JAnnotation.translate_method cm.Javalib.cm_annotations in let method_annotation = JAnnotation.translate_method cm.Javalib.cm_annotations in
let proc_attributes = let proc_attributes =
{ (ProcAttributes.default proc_name) with { (ProcAttributes.default proc_name) with

Loading…
Cancel
Save