[java] get type name directly from procname

Summary: Instead of converting the class type name of a java procedure to a string and then back to a type name, just get it directly.

Reviewed By: jvillard

Differential Revision: D19950528

fbshipit-source-id: dadf6d130
master
Nikos Gorogiannis 5 years ago committed by Facebook Github Bot
parent 8e3f9dd32e
commit a85dfe6af4

@ -372,7 +372,7 @@ let override_find ?(check_current_type = true) f tenv proc_name =
else else
match proc_name with match proc_name with
| Procname.Java proc_name_java -> | Procname.Java proc_name_java ->
find_super_type (Typ.Name.Java.from_string (Procname.Java.get_class_name proc_name_java)) find_super_type (Procname.Java.get_class_type_name proc_name_java)
| Procname.ObjC_Cpp proc_name_cpp -> | Procname.ObjC_Cpp proc_name_cpp ->
find_super_type (Procname.ObjC_Cpp.get_class_type_name proc_name_cpp) find_super_type (Procname.ObjC_Cpp.get_class_type_name proc_name_cpp)
| _ -> | _ ->

@ -26,7 +26,7 @@ let is_modeled_expensive tenv = function
(not (BuiltinDecl.is_declared proc_name)) (not (BuiltinDecl.is_declared proc_name))
&& &&
let is_subclass = let is_subclass =
let classname = Typ.Name.Java.from_string (Procname.Java.get_class_name proc_name_java) in let classname = Procname.Java.get_class_type_name proc_name_java in
PatternMatch.is_subtype_of_str tenv classname PatternMatch.is_subtype_of_str tenv classname
in in
Inferconfig.modeled_expensive_matcher is_subclass proc_name Inferconfig.modeled_expensive_matcher is_subclass proc_name
@ -38,7 +38,7 @@ let is_allocator tenv pname =
match pname with match pname with
| Procname.Java pname_java -> | Procname.Java pname_java ->
let is_throwable () = let is_throwable () =
let class_name = Typ.Name.Java.from_string (Procname.Java.get_class_name pname_java) in let class_name = Procname.Java.get_class_type_name pname_java in
PatternMatch.is_throwable tenv class_name PatternMatch.is_throwable tenv class_name
in in
Procname.is_constructor pname Procname.is_constructor pname

@ -64,7 +64,7 @@ let callback_fragment_retains_view_java java_pname {Callbacks.summary; exe_env}
Typ.Name.equal fld_classname class_typename && fld_typ_is_view fld_typ Typ.Name.equal fld_classname class_typename && fld_typ_is_view fld_typ
in in
if is_on_destroy_view then if is_on_destroy_view then
let class_name = Typ.Name.Java.from_string (Procname.Java.get_class_name java_pname) in let class_name = Procname.Java.get_class_type_name java_pname in
match Tenv.lookup tenv class_name with match Tenv.lookup tenv class_name with
| Some {fields} when AndroidFramework.is_fragment tenv class_name -> | Some {fields} when AndroidFramework.is_fragment tenv class_name ->
let declared_view_fields = List.filter ~f:(is_declared_view_typ class_name) fields in let declared_view_fields = List.filter ~f:(is_declared_view_typ class_name) fields in

@ -36,8 +36,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let is_closeable_procname tenv procname = let is_closeable_procname tenv procname =
match procname with match procname with
| Procname.Java java_procname -> | Procname.Java java_procname ->
is_closeable_typename tenv is_closeable_typename tenv (Procname.Java.get_class_type_name java_procname)
(Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname))
| _ -> | _ ->
false false

@ -36,8 +36,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let is_closeable_procname tenv procname = let is_closeable_procname tenv procname =
match procname with match procname with
| Procname.Java java_procname -> | Procname.Java java_procname ->
is_closeable_typename tenv is_closeable_typename tenv (Procname.Java.get_class_type_name java_procname)
(Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname))
| _ -> | _ ->
false false

@ -36,8 +36,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let is_closeable_procname tenv procname = let is_closeable_procname tenv procname =
match procname with match procname with
| Procname.Java java_procname -> | Procname.Java java_procname ->
is_closeable_typename tenv is_closeable_typename tenv (Procname.Java.get_class_type_name java_procname)
(Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname))
| _ -> | _ ->
false false

@ -36,8 +36,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let is_closeable_procname tenv procname = let is_closeable_procname tenv procname =
match procname with match procname with
| Procname.Java java_procname -> | Procname.Java java_procname ->
is_closeable_typename tenv is_closeable_typename tenv (Procname.Java.get_class_type_name java_procname)
(Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname))
| _ -> | _ ->
false false

@ -36,8 +36,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let is_closeable_procname tenv procname = let is_closeable_procname tenv procname =
match procname with match procname with
| Procname.Java java_procname -> | Procname.Java java_procname ->
is_closeable_typename tenv is_closeable_typename tenv (Procname.Java.get_class_type_name java_procname)
(Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname))
| _ -> | _ ->
false false

@ -36,8 +36,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let is_closeable_procname tenv procname = let is_closeable_procname tenv procname =
match procname with match procname with
| Procname.Java java_procname -> | Procname.Java java_procname ->
is_closeable_typename tenv is_closeable_typename tenv (Procname.Java.get_class_type_name java_procname)
(Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname))
| _ -> | _ ->
false false

@ -36,8 +36,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let is_closeable_procname tenv procname = let is_closeable_procname tenv procname =
match procname with match procname with
| Procname.Java java_procname -> | Procname.Java java_procname ->
is_closeable_typename tenv is_closeable_typename tenv (Procname.Java.get_class_type_name java_procname)
(Typ.Name.Java.from_string (Procname.Java.get_class_name java_procname))
| _ -> | _ ->
false false

@ -136,7 +136,7 @@ module SourceKind = struct
get_external_source class_name method_name get_external_source class_name method_name
in in
PatternMatch.supertype_find_map_opt tenv taint_matching_supertype PatternMatch.supertype_find_map_opt tenv taint_matching_supertype
(Typ.Name.Java.from_string (Procname.Java.get_class_name pname)) (Procname.Java.get_class_type_name pname)
|> Option.value ~default:[] |> Option.value ~default:[]
| Procname.C _ when Procname.equal pname BuiltinDecl.__global_access -> ( | Procname.C _ when Procname.equal pname BuiltinDecl.__global_access -> (
(* accessed global will be passed to us as the only parameter *) (* accessed global will be passed to us as the only parameter *)
@ -249,7 +249,7 @@ module SourceKind = struct
in in
match match
PatternMatch.supertype_find_map_opt tenv taint_matching_supertype PatternMatch.supertype_find_map_opt tenv taint_matching_supertype
(Typ.Name.Java.from_string (Procname.Java.get_class_name java_pname)) (Procname.Java.get_class_type_name java_pname)
with with
| Some tainted_formals -> | Some tainted_formals ->
tainted_formals tainted_formals
@ -480,7 +480,7 @@ module SinkKind = struct
get_external_sink class_name method_name get_external_sink class_name method_name
in in
PatternMatch.supertype_find_map_opt tenv taint_matching_supertype PatternMatch.supertype_find_map_opt tenv taint_matching_supertype
(Typ.Name.Java.from_string (Procname.Java.get_class_name java_pname)) (Procname.Java.get_class_type_name java_pname)
|> Option.value ~default:[] |> Option.value ~default:[]
| pname when BuiltinDecl.is_declared pname -> | pname when BuiltinDecl.is_declared pname ->
[] []
@ -557,7 +557,7 @@ module JavaSanitizer = struct
get_external_sanitizer class_name method_name get_external_sanitizer class_name method_name
in in
PatternMatch.supertype_find_map_opt tenv sanitizer_matching_supertype PatternMatch.supertype_find_map_opt tenv sanitizer_matching_supertype
(Typ.Name.Java.from_string (Procname.Java.get_class_name java_pname)) (Procname.Java.get_class_type_name java_pname)
| _ -> | _ ->
None None

Loading…
Cancel
Save