From 2f7c957008bf9e93cc27ba2adffb5efe33298395 Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Tue, 28 Jul 2015 08:43:41 -0600 Subject: [PATCH] [Infer] resolving TODO's by using java_is_static Summary: We now have the required metadata to check whether a Java method is static; used this in two places where we wanted this information before. --- infer/src/backend/interproc.ml | 2 +- infer/src/harness/inhabit.ml | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index fb9fdfd7f..99fbc9734 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -996,8 +996,8 @@ let report_runtime_exceptions tenv cfg pdesc summary = (Specs.get_attributes summary).Sil.access = Sil.Public in let is_main = is_public_method - (* TODO (#4559939): add check for static method *) && Procname.is_java pname + && Procname.java_is_static pname && (Procname.java_get_method pname) = "main" in let is_annotated = let annotated_signature = diff --git a/infer/src/harness/inhabit.ml b/infer/src/harness/inhabit.ml index 22de58aeb..951a919f9 100644 --- a/infer/src/harness/inhabit.ml +++ b/infer/src/harness/inhabit.ml @@ -39,10 +39,6 @@ let env_add_instr instr tmp_vars env = (** call flags for an allocation or call to a constructor *) let cf_alloc = Sil.cf_default -(** returns true if the procedure description is a Java static method *) -(* TODO (t4559939): this information isn't in Procdesc, so we can't implement this method *) -let is_static procdesc = false - let fun_exp_from_name proc_name = Sil.Const (Sil.Cfun (proc_name)) let source_dir_from_name proc_name proc_file_map = @@ -182,7 +178,9 @@ let inhabit_call_with_args procname procdesc args env = if is_void then [] else [Ident.create_fresh Ident.knormal] in let call_instr = let fun_exp = fun_exp_from_name procname in - let flags = { Sil.cf_virtual = not (is_static procdesc); Sil.cf_noreturn = false; Sil.cf_is_objc_block = false; } in + let flags = + let cf_virtual = not (Procname.java_is_static procname) in + { Sil.cf_virtual = cf_virtual; Sil.cf_noreturn = false; Sil.cf_is_objc_block = false; } in Sil.Call (retval, fun_exp, args, env.pc, flags) in env_add_instr call_instr retval env