[infer] make deadcode is back

Reviewed By: jvillard

Differential Revision: D18957045

fbshipit-source-id: a6db07309
master
Sungkeun Cho 5 years ago committed by Facebook Github Bot
parent 6fb2a94f57
commit bc5f740945

@ -418,7 +418,6 @@ OPTIONS
Failure_exe (enabled by default), Failure_exe (enabled by default),
GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL
(disabled by default), (disabled by default),
GRAPHQL_FIELD_ACCESS (enabled by default),
GUARDEDBY_VIOLATION (enabled by default), GUARDEDBY_VIOLATION (enabled by default),
IMPURE_FUNCTION (enabled by default), IMPURE_FUNCTION (enabled by default),
INEFFICIENT_KEYSET_ITERATOR (enabled by default), INEFFICIENT_KEYSET_ITERATOR (enabled by default),

@ -160,7 +160,6 @@ OPTIONS
Failure_exe (enabled by default), Failure_exe (enabled by default),
GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL
(disabled by default), (disabled by default),
GRAPHQL_FIELD_ACCESS (enabled by default),
GUARDEDBY_VIOLATION (enabled by default), GUARDEDBY_VIOLATION (enabled by default),
IMPURE_FUNCTION (enabled by default), IMPURE_FUNCTION (enabled by default),
INEFFICIENT_KEYSET_ITERATOR (enabled by default), INEFFICIENT_KEYSET_ITERATOR (enabled by default),

@ -418,7 +418,6 @@ OPTIONS
Failure_exe (enabled by default), Failure_exe (enabled by default),
GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL
(disabled by default), (disabled by default),
GRAPHQL_FIELD_ACCESS (enabled by default),
GUARDEDBY_VIOLATION (enabled by default), GUARDEDBY_VIOLATION (enabled by default),
IMPURE_FUNCTION (enabled by default), IMPURE_FUNCTION (enabled by default),
INEFFICIENT_KEYSET_ITERATOR (enabled by default), INEFFICIENT_KEYSET_ITERATOR (enabled by default),

@ -904,8 +904,6 @@ module Procname = struct
let is_cpp_lambda {method_name} = String.is_substring ~substring:"operator()" method_name let is_cpp_lambda {method_name} = String.is_substring ~substring:"operator()" method_name
let is_operator_equal {method_name} = String.is_substring ~substring:"operator=" method_name
let pp_verbose_kind fmt = function let pp_verbose_kind fmt = function
| CPPMethod {mangled} | CPPDestructor {mangled} -> | CPPMethod {mangled} | CPPDestructor {mangled} ->
F.fprintf fmt "(%s)" (Option.value ~default:"" mangled) F.fprintf fmt "(%s)" (Option.value ~default:"" mangled)

@ -478,9 +478,6 @@ being the name of the struct, [None] means the parameter is of some other type.
val is_cpp_lambda : t -> bool val is_cpp_lambda : t -> bool
(** Return whether the procname is a cpp lambda. *) (** Return whether the procname is a cpp lambda. *)
val is_operator_equal : t -> bool
(** Return true if the procname is operator= *)
end end
module C : sig module C : sig

@ -240,8 +240,6 @@ let get_vararg_type_names tenv (call_node : Procdesc.Node.t) (ivar : Pvar.t) : s
type_names [] call_node type_names [] call_node
let is_getter pname_java = String.is_prefix ~prefix:"get" (Typ.Procname.Java.get_method pname_java)
let type_is_class typ = let type_is_class typ =
match typ.Typ.desc with match typ.Typ.desc with
| Tptr ({desc= Tstruct _}, _) -> | Tptr ({desc= Tstruct _}, _) ->

@ -22,9 +22,6 @@ val get_vararg_type_names : Tenv.t -> Procdesc.Node.t -> Pvar.t -> string list
val method_is_initializer : Tenv.t -> ProcAttributes.t -> bool val method_is_initializer : Tenv.t -> ProcAttributes.t -> bool
(** Check if the method is one of the known initializer methods. *) (** Check if the method is one of the known initializer methods. *)
val is_getter : Typ.Procname.Java.t -> bool
(** Is this a getter proc name? *)
val is_subtype : Tenv.t -> Typ.Name.t -> Typ.Name.t -> bool val is_subtype : Tenv.t -> Typ.Name.t -> Typ.Name.t -> bool
(** Is the type a transitive subtype of the typename? *) (** Is the type a transitive subtype of the typename? *)

@ -42,11 +42,3 @@ val expand_checkers : macros_map -> paths_map -> CTL.ctl_checker list -> CTL.ctl
val create_parsed_linters : string -> CTL.ctl_checker list -> linter list val create_parsed_linters : string -> CTL.ctl_checker list -> linter list
val remove_new_lines_and_whitespace : string -> string val remove_new_lines_and_whitespace : string -> string
val fill_issue_desc_info_and_log :
CLintersContext.context
-> witness:Ctl_parser_types.ast_node
-> current_node:Ctl_parser_types.ast_node
-> CIssue.issue_desc
-> Location.t
-> unit

@ -70,8 +70,6 @@ type t =
| InObjCClass of t * t | InObjCClass of t * t
[@@deriving compare] [@@deriving compare]
let equal = [%compare.equal: t]
let has_transition phi = let has_transition phi =
match phi with match phi with
| True | True

@ -68,8 +68,6 @@ val is_transition_to_successor : transitions -> bool
val has_transition : t -> bool val has_transition : t -> bool
val equal : t -> t -> bool
val pp_transition : Format.formatter -> transitions option -> unit val pp_transition : Format.formatter -> transitions option -> unit
val pp_formula : Format.formatter -> t -> unit val pp_formula : Format.formatter -> t -> unit

@ -21,8 +21,6 @@ val ast_node_type : ast_node -> string
val ast_node_kind : ast_node -> string val ast_node_kind : ast_node -> string
val ast_node_pointer : ast_node -> int
val ast_node_has_kind : ALVar.alexp list -> ast_node -> bool val ast_node_has_kind : ALVar.alexp list -> ast_node -> bool
val ast_node_unique_string_id : ast_node -> string val ast_node_unique_string_id : ast_node -> string

@ -298,8 +298,6 @@ let _global_variable_initialized_with_function_or_method_call =
register_from_string ~enabled:false "GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL" register_from_string ~enabled:false "GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL"
let graphql_field_access = register_from_string "GRAPHQL_FIELD_ACCESS"
let guardedby_violation_racerd = let guardedby_violation_racerd =
register_from_string "GUARDEDBY_VIOLATION" ~hum:"GuardedBy Violation" register_from_string "GUARDEDBY_VIOLATION" ~hum:"GuardedBy Violation"

@ -173,8 +173,6 @@ val failure_exe : t
val field_not_null_checked : t val field_not_null_checked : t
val graphql_field_access : t
val guardedby_violation_racerd : t val guardedby_violation_racerd : t
val impure_function : t val impure_function : t

@ -39,8 +39,6 @@ module Allocsite : sig
val literal_string : string -> t val literal_string : string -> t
val get_literal_string : t -> string option
val get_param_path : t -> Symb.SymbolPath.partial option val get_param_path : t -> Symb.SymbolPath.partial option
val eq : t -> t -> Boolean.t val eq : t -> t -> Boolean.t

@ -16,11 +16,6 @@ module Sem = BufferOverrunSemantics
module Relation = BufferOverrunDomainRelation module Relation = BufferOverrunDomainRelation
module Trace = BufferOverrunTrace module Trace = BufferOverrunTrace
open BoUtils.ModelEnv open BoUtils.ModelEnv
module Val = struct
type t = unit
end
open ProcnameDispatcher.Call.FuncArg open ProcnameDispatcher.Call.FuncArg
type exec_fun = model_env -> ret:Ident.t * Typ.t -> Dom.Mem.t -> Dom.Mem.t type exec_fun = model_env -> ret:Ident.t * Typ.t -> Dom.Mem.t -> Dom.Mem.t

@ -662,8 +662,6 @@ let of_big_int : Z.t -> t = fun n -> NonBottom (ItvPure.of_big_int n)
let of_int_lit : IntLit.t -> t = fun n -> NonBottom (ItvPure.of_int_lit n) let of_int_lit : IntLit.t -> t = fun n -> NonBottom (ItvPure.of_int_lit n)
let of_pulse_value : PulseAbstractValue.t -> t = fun v -> NonBottom (ItvPure.of_pulse_value v)
let is_false : t -> bool = function NonBottom x -> ItvPure.is_false x | Bottom -> false let is_false : t -> bool = function NonBottom x -> ItvPure.is_false x | Bottom -> false
let le : lhs:t -> rhs:t -> bool = leq let le : lhs:t -> rhs:t -> bool = leq
@ -681,14 +679,6 @@ let lift1 : (ItvPure.t -> ItvPure.t) -> t -> t =
fun f -> function Bottom -> Bottom | NonBottom x -> NonBottom (f x) fun f -> function Bottom -> Bottom | NonBottom x -> NonBottom (f x)
let lift1opt : (ItvPure.t -> ItvPure.t option) -> t -> t option =
fun f -> function
| Bottom ->
Some Bottom
| NonBottom x ->
f x |> Option.map ~f:(fun v -> NonBottom v)
let bind1_gen : bot:'a -> (ItvPure.t -> 'a) -> t -> 'a = let bind1_gen : bot:'a -> (ItvPure.t -> 'a) -> t -> 'a =
fun ~bot f x -> match x with Bottom -> bot | NonBottom x -> f x fun ~bot f x -> match x with Bottom -> bot | NonBottom x -> f x
@ -787,10 +777,6 @@ let max_sem : ?use_minmax_bound:bool -> t -> t -> t =
fun ?use_minmax_bound -> lift2 (ItvPure.max_sem ?use_minmax_bound) fun ?use_minmax_bound -> lift2 (ItvPure.max_sem ?use_minmax_bound)
let arith_binop : Binop.t -> t -> t -> t = fun bop -> lift2 (ItvPure.arith_binop bop)
let arith_unop : Unop.t -> t -> t option = fun unop -> lift1opt (ItvPure.arith_unop unop)
let prune_eq_zero : t -> t = bind1 ItvPure.prune_eq_zero let prune_eq_zero : t -> t = bind1 ItvPure.prune_eq_zero
let prune_ne_zero : t -> t = bind1 ItvPure.prune_ne_zero let prune_ne_zero : t -> t = bind1 ItvPure.prune_ne_zero

@ -159,8 +159,6 @@ val of_big_int : Z.t -> t
val of_int_lit : IntLit.t -> t val of_int_lit : IntLit.t -> t
val of_pulse_value : PulseAbstractValue.t -> t
val get_const : t -> Z.t option val get_const : t -> Z.t option
val is_zero : t -> bool val is_zero : t -> bool
@ -237,10 +235,6 @@ val mod_sem : t -> t -> t
val ne_sem : t -> t -> Boolean.t val ne_sem : t -> t -> Boolean.t
val arith_binop : Binop.t -> t -> t -> t
val arith_unop : Unop.t -> t -> t option
val prune_eq_zero : t -> t val prune_eq_zero : t -> t
val prune_ne_zero : t -> t val prune_ne_zero : t -> t

@ -359,13 +359,6 @@ module Symbol = struct
SymbolPath.is_global path SymbolPath.is_global path
let is_pulse_value : t -> bool = function
| PulseValue _ ->
true
| OneValue _ | BoundEnd _ ->
false
let get_pulse_value_exn : t -> PulseAbstractValue.t = function let get_pulse_value_exn : t -> PulseAbstractValue.t = function
| PulseValue v -> | PulseValue v ->
v v

@ -120,8 +120,6 @@ module Symbol : sig
val exists_str : f:(string -> bool) -> t -> bool val exists_str : f:(string -> bool) -> t -> bool
val is_pulse_value : t -> bool
val get_pulse_value_exn : t -> PulseAbstractValue.t val get_pulse_value_exn : t -> PulseAbstractValue.t
end end

@ -453,8 +453,6 @@ module NewDomain = struct
; return_called= Mem.widen ~prev:prev.return_called ~next:next.return_called ~num_iters } ; return_called= Mem.widen ~prev:prev.return_called ~next:next.return_called ~num_iters }
let empty = {no_return_called= Mem.empty; return_called= Mem.empty}
let init tenv pname formals = let init tenv pname formals =
{no_return_called= Mem.init tenv pname formals; return_called= Mem.empty} {no_return_called= Mem.init tenv pname formals; return_called= Mem.empty}
@ -493,8 +491,6 @@ include struct
let map_new f (o, n) = (o, f n) let map_new f (o, n) = (o, f n)
let empty = (OldDomain.empty, NewDomain.empty)
let init tenv pname formals = (OldDomain.empty, NewDomain.init tenv pname formals) let init tenv pname formals = (OldDomain.empty, NewDomain.init tenv pname formals)
let add k v = map_old (OldDomain.add k v) let add k v = map_old (OldDomain.add k v)

@ -16,8 +16,6 @@ module LocalAccessPath : sig
val make_from_access_expression : HilExp.AccessExpression.t -> Typ.Procname.t -> t val make_from_access_expression : HilExp.AccessExpression.t -> Typ.Procname.t -> t
val make_from_pvar : Pvar.t -> Typ.t -> Typ.Procname.t -> t
val to_formal_option : t -> FormalMap.t -> t option val to_formal_option : t -> FormalMap.t -> t option
val pp : F.formatter -> t -> unit val pp : F.formatter -> t -> unit
@ -42,10 +40,6 @@ module MethodCallPrefix : sig
val make : LocalAccessPath.t -> Typ.Procname.t -> Location.t -> t val make : LocalAccessPath.t -> Typ.Procname.t -> Location.t -> t
val pp : F.formatter -> t -> unit
val procname_to_string : t -> string
val to_method_call : t -> MethodCall.t val to_method_call : t -> MethodCall.t
end end
@ -76,8 +70,6 @@ include module type of AbstractDomain.Pair (OldDomain) (NewDomain)
(** type for saving in summary payload *) (** type for saving in summary payload *)
type summary = OldDomain.t * NewDomain.Mem.t type summary = OldDomain.t * NewDomain.Mem.t
val empty : t
val init : Tenv.t -> Typ.Procname.t -> (Pvar.t * Typ.t) list -> t val init : Tenv.t -> Typ.Procname.t -> (Pvar.t * Typ.t) list -> t
val add : LocalAccessPath.t -> CallSet.t -> t -> t val add : LocalAccessPath.t -> CallSet.t -> t -> t

@ -53,13 +53,6 @@ let is_component_create_method procname tenv =
match Typ.Procname.get_method procname with "create" -> is_component procname tenv | _ -> false match Typ.Procname.get_method procname with "create" -> is_component procname tenv | _ -> false
let is_on_create_layout = function
| Typ.Procname.Java java_pname -> (
match Typ.Procname.Java.get_method java_pname with "onCreateLayout" -> true | _ -> false )
| _ ->
false
let get_component_create_typ_opt procname tenv = let get_component_create_typ_opt procname tenv =
match procname with match procname with
| Typ.Procname.Java java_pname when is_component_create_method procname tenv -> | Typ.Procname.Java java_pname when is_component_create_method procname tenv ->

@ -7,7 +7,6 @@
open! IStd open! IStd
module F = Format module F = Format
module L = Logging
module D = UninitDomain.Domain module D = UninitDomain.Domain
(** Forward analysis to compute uninitialized variables at each program point *) (** Forward analysis to compute uninitialized variables at each program point *)

@ -139,8 +139,6 @@ module OwnershipAbstractValue : sig
val owned : t val owned : t
val unowned : t
val make_owned_if : int -> t val make_owned_if : int -> t
end end

@ -504,10 +504,6 @@ module AttributeDomain = struct
find_opt acc_exp t |> Option.exists ~f:(function Attribute.ThreadGuard -> true | _ -> false) find_opt acc_exp t |> Option.exists ~f:(function Attribute.ThreadGuard -> true | _ -> false)
let get_scheduler_constraint acc_exp t =
find_opt acc_exp t |> Option.bind ~f:(function Attribute.WorkScheduler c -> Some c | _ -> None)
let is_future_done_guard acc_exp t = let is_future_done_guard acc_exp t =
find_opt acc_exp t find_opt acc_exp t
|> Option.exists ~f:(function Attribute.FutureDoneGuard _ -> true | _ -> false) |> Option.exists ~f:(function Attribute.FutureDoneGuard _ -> true | _ -> false)

@ -128,9 +128,6 @@ module AttributeDomain : sig
val is_thread_guard : HilExp.AccessExpression.t -> t -> bool val is_thread_guard : HilExp.AccessExpression.t -> t -> bool
val get_scheduler_constraint :
HilExp.AccessExpression.t -> t -> StarvationModels.scheduler_thread_constraint option
val is_future_done_guard : HilExp.AccessExpression.t -> t -> bool val is_future_done_guard : HilExp.AccessExpression.t -> t -> bool
(** does the given expr has attribute [FutureDone x] return [Some x] else [None] *) (** does the given expr has attribute [FutureDone x] return [Some x] else [None] *)

@ -36,9 +36,11 @@ default: detect_dead_code
ml_src_files_from_mlly:=$(shell find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\.\./[a-zA-Z].*\.ml[ly]') ml_src_files_from_mlly:=$(shell find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\.\./[a-zA-Z].*\.ml[ly]')
ml_src_files:=$(shell find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\.\./[a-zA-Z].*\.mli') ml_src_files:=$(shell for i in $$(find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\.\./[a-zA-Z].*\.ml'); do echo $${i\#"../"}; done)
ml_src_files_without_mli:=$(shell cd .. && for i in $$(find . -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\./[a-zA-Z].*\.ml'); do [ -f $${i}i ] || echo $$i; done) mli_src_files:=$(shell for i in $$(find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\.\./[a-zA-Z].*\.mli'); do echo $${i\#"../"}; done)
ml_src_files_without_mli:=$(shell for i in $$(find .. -not -path "../*clang_stubs/*" -not -path "../*java_stubs/*" -not -path "../_build/*" -regex '\.\./[a-zA-Z].*\.ml'); do [ -f $${i}i ] || echo $${i\#"../"}; done)
.PHONY: depend .PHONY: depend
depend: depend:
@ -48,7 +50,7 @@ depend:
-I c_stubs -I checkers -I clang -I concurrency -I facebook -I integration -I istd -I java \ -I c_stubs -I checkers -I clang -I concurrency -I facebook -I integration -I istd -I java \
-I labs -I nullsafe -I pulse -I scuba -I quandary -I topl -I unit -I unit/clang -I unit/nullsafe -I deadcode \ -I labs -I nullsafe -I pulse -I scuba -I quandary -I topl -I unit -I unit/clang -I unit/nullsafe -I deadcode \
-I test_determinator \ -I test_determinator \
$(ml_src_files) > deadcode/.depend $(ml_src_files) $(mli_src_files) > deadcode/.depend
# circular dependency... not sure how to fix properly # circular dependency... not sure how to fix properly
%.cmi: %.cmx %.cmi: %.cmx

@ -21,5 +21,5 @@ Format.sprintf
|} |}
(String.concat " " common_cflags) (String.concat " " common_cflags)
(String.concat " " common_optflags) (String.concat " " common_optflags)
(String.concat " " common_libraries) (String.concat " " ("InferCStubs" :: common_libraries))
|> Jbuild_plugin.V1.send |> Jbuild_plugin.V1.send

@ -128,8 +128,6 @@ let find_opt addr memory =
let fold_attrs f memory init = Graph.fold f (snd memory) init let fold_attrs f memory init = Graph.fold f (snd memory) init
let set_attrs addr attrs memory = (fst memory, Graph.add addr attrs (snd memory))
let set_edges addr edges memory = (Graph.add addr edges (fst memory), snd memory) let set_edges addr edges memory = (Graph.add addr edges (fst memory), snd memory)
let set_cell addr (edges, attrs) memory = let set_cell addr (edges, attrs) memory =

@ -32,8 +32,6 @@ val find_opt : AbstractValue.t -> t -> cell option
val fold_attrs : (AbstractValue.t -> Attributes.t -> 'acc -> 'acc) -> t -> 'acc -> 'acc val fold_attrs : (AbstractValue.t -> Attributes.t -> 'acc -> 'acc) -> t -> 'acc -> 'acc
val set_attrs : AbstractValue.t -> Attributes.t -> t -> t
val set_edges : AbstractValue.t -> edges -> t -> t val set_edges : AbstractValue.t -> edges -> t -> t
val set_cell : AbstractValue.t -> cell -> t -> t val set_cell : AbstractValue.t -> cell -> t -> t

@ -365,10 +365,6 @@ let write_field location addr_trace_ref field addr_trace_obj astate =
write_access location addr_trace_ref (FieldAccess field) addr_trace_obj astate write_access location addr_trace_ref (FieldAccess field) addr_trace_obj astate
let havoc_deref location addr_trace trace_obj astate =
write_deref location ~ref:addr_trace ~obj:(AbstractValue.mk_fresh (), trace_obj) astate
let havoc_field location addr_trace field trace_obj astate = let havoc_field location addr_trace field trace_obj astate =
write_field location addr_trace field (AbstractValue.mk_fresh (), trace_obj) astate write_field location addr_trace field (AbstractValue.mk_fresh (), trace_obj) astate

@ -58,9 +58,6 @@ val eval_binop :
val havoc_id : Ident.t -> ValueHistory.t -> t -> t val havoc_id : Ident.t -> ValueHistory.t -> t -> t
val havoc_deref :
Location.t -> AbstractValue.t * ValueHistory.t -> ValueHistory.t -> t -> t access_result
val havoc_field : val havoc_field :
Location.t Location.t
-> AbstractValue.t * ValueHistory.t -> AbstractValue.t * ValueHistory.t

Loading…
Cancel
Save