[easy] Java nits

Reviewed By: sblackshear

Differential Revision: D7290400

fbshipit-source-id: 42945c8
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent 0d5e9d0934
commit 2916c97e0a

@ -593,11 +593,11 @@ module Procname = struct
let get_method j = j.method_name
let replace_method j mname = {j with method_name= mname}
let replace_method_name method_name j = {j with method_name}
let replace_return_type j ret_type = {j with return_type= Some ret_type}
let replace_parameters parameters j = {j with parameters}
let replace_parameters j parameters = {j with parameters}
let replace_return_type ret_type j = {j with return_type= Some ret_type}
let get_return_type j = return_type_to_string j Verbose

@ -286,10 +286,13 @@ module Procname : sig
(** Create a Java procedure name from its
class_name method_name args_type_name return_type_name method_kind. *)
val replace_parameters : t -> java_type list -> t
val replace_method_name : string -> t -> t
(** Replace the method name of an existing java procname. *)
val replace_parameters : java_type list -> t -> t
(** Replace the parameters of a java procname. *)
val replace_return_type : t -> java_type -> t
val replace_return_type : java_type -> t -> t
(** Replace the method of a java procname. *)
val get_class_name : t -> string
@ -310,9 +313,6 @@ module Procname : sig
val get_parameters : t -> java_type list
(** Return the parameters of a java procedure name. *)
val replace_method : t -> string -> t
(** Replace the method name of an existing java procname. *)
val get_return_typ : t -> typ
(** Return the return type of [pname_java]. return Tvoid if there's no return type *)

@ -620,7 +620,7 @@ let resolve_java_pname tenv prop args pname_java call_flags : Typ.Procname.Java.
(Typ.Procname.Java.get_parameters resolved_pname_java)
|> List.rev
in
Typ.Procname.Java.replace_parameters resolved_pname_java resolved_params
Typ.Procname.Java.replace_parameters resolved_params resolved_pname_java
in
let resolved_pname_java, other_args =
let pname = Typ.Procname.Java pname_java

@ -709,11 +709,9 @@ let typecheck_instr tenv ext calls_this checks (node: Procdesc.Node.t) idenv get
let pname_get_from_pname_put pname_put =
let object_t = (Some "java.lang", "Object") in
let parameters = [object_t] in
Typ.Procname.Java.replace_parameters
(Typ.Procname.Java.replace_return_type
(Typ.Procname.Java.replace_method pname_put "get")
object_t)
parameters
pname_put |> Typ.Procname.Java.replace_method_name "get"
|> Typ.Procname.Java.replace_return_type object_t
|> Typ.Procname.Java.replace_parameters parameters
in
match call_params with
| ((_, Exp.Lvar pv_map), _) :: ((_, exp_key), _) :: ((_, exp_value), typ_value) :: _
@ -917,9 +915,8 @@ let typecheck_instr tenv ext calls_this checks (node: Procdesc.Node.t) idenv get
(DExp.Dconst Const.Cfun Typ.Procname.Java pname_java, args, loc, call_flags) ->
let pname_java' =
let object_t = (Some "java.lang", "Object") in
Typ.Procname.Java.replace_return_type
(Typ.Procname.Java.replace_method pname_java "get")
object_t
pname_java |> Typ.Procname.Java.replace_method_name "get"
|> Typ.Procname.Java.replace_return_type object_t
in
let fun_dexp = DExp.Dconst (Const.Cfun (Typ.Procname.Java pname_java')) in
Some (DExp.Dretcall (fun_dexp, args, loc, call_flags))

@ -180,10 +180,7 @@ let rec string_of_type vt =
JBasics.cn_name cn
let package_to_string p =
let rec aux p = match p with [] -> "" | [p] -> p | p :: rest -> p ^ "." ^ aux rest in
match p with [] -> None | _ -> Some (aux p)
let package_to_string = function [] -> None | p -> Some (String.concat ~sep:"." p)
let cn_to_java_type cn = (package_to_string (JBasics.cn_package cn), JBasics.cn_simple_name cn)

@ -542,12 +542,8 @@ module Make (TaintSpecification : TaintSpec.S) = struct
let handle_model callee_pname access_tree model =
let is_variadic =
match callee_pname with
| Typ.Procname.Java pname -> (
match List.rev (Typ.Procname.Java.get_parameters pname) with
| (_, "java.lang.Object[]") :: _ ->
true
| _ ->
false )
| Typ.Procname.Java pname ->
Typ.Procname.Java.is_vararg pname
| _ ->
false
in

Loading…
Cancel
Save