[cleanup] remove language from ProcAttributes

Summary: This information is already available in the procedure name.

Reviewed By: jeremydubreil, jvillard

Differential Revision: D6119459

fbshipit-source-id: f07bfde
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent dbfbf9cf01
commit 33450ab58b

@ -57,7 +57,6 @@ type t =
; is_model: bool (** the procedure is a model *) ; is_model: bool (** the procedure is a model *)
; is_specialized: bool (** the procedure is a clone specialized for dynamic dispatch handling *) ; is_specialized: bool (** the procedure is a clone specialized for dynamic dispatch handling *)
; is_synthetic_method: bool (** the procedure is a synthetic method *) ; is_synthetic_method: bool (** the procedure is a synthetic method *)
; language: Config.language (** language of the procedure *)
; loc: Location.t (** location of this procedure in the source code *) ; loc: Location.t (** location of this procedure in the source code *)
; translation_unit: SourceFile.t option (** translation unit to which the procedure belongs *) ; translation_unit: SourceFile.t option (** translation unit to which the procedure belongs *)
; mutable locals: (Mangled.t * Typ.t) list (** name and type of local variables *) ; mutable locals: (Mangled.t * Typ.t) list (** name and type of local variables *)
@ -69,7 +68,7 @@ type t =
; source_file_captured: SourceFile.t (** source file where the procedure was captured *) } ; source_file_captured: SourceFile.t (** source file where the procedure was captured *) }
[@@deriving compare] [@@deriving compare]
let default proc_name language = let default proc_name =
{ access= PredSymb.Default { access= PredSymb.Default
; captured= [] ; captured= []
; changed= true ; changed= true
@ -90,7 +89,6 @@ let default proc_name language =
; is_model= false ; is_model= false
; is_specialized= false ; is_specialized= false
; is_synthetic_method= false ; is_synthetic_method= false
; language
; loc= Location.dummy ; loc= Location.dummy
; translation_unit= None ; translation_unit= None
; locals= [] ; locals= []
@ -100,4 +98,3 @@ let default proc_name language =
; proc_name ; proc_name
; ret_type= Typ.mk Typ.Tvoid ; ret_type= Typ.mk Typ.Tvoid
; source_file_captured= SourceFile.invalid __FILE__ } ; source_file_captured= SourceFile.invalid __FILE__ }

@ -54,7 +54,6 @@ type t =
; is_model: bool (** the procedure is a model *) ; is_model: bool (** the procedure is a model *)
; is_specialized: bool (** the procedure is a clone specialized for dynamic dispatch handling *) ; is_specialized: bool (** the procedure is a clone specialized for dynamic dispatch handling *)
; is_synthetic_method: bool (** the procedure is a synthetic method *) ; is_synthetic_method: bool (** the procedure is a synthetic method *)
; language: Config.language (** language of the procedure *)
; loc: Location.t (** location of this procedure in the source code *) ; loc: Location.t (** location of this procedure in the source code *)
; translation_unit: SourceFile.t option (** translation unit to which the procedure belongs *) ; translation_unit: SourceFile.t option (** translation unit to which the procedure belongs *)
; mutable locals: (Mangled.t * Typ.t) list (** name and type of local variables *) ; mutable locals: (Mangled.t * Typ.t) list (** name and type of local variables *)
@ -66,5 +65,5 @@ type t =
; source_file_captured: SourceFile.t (** source file where the procedure was captured *) } ; source_file_captured: SourceFile.t (** source file where the procedure was captured *) }
[@@deriving compare] [@@deriving compare]
val default : Typ.Procname.t -> Config.language -> t val default : Typ.Procname.t -> t
(** Create a proc_attributes with default values. *) (** Create a proc_attributes with default values. *)

@ -1047,7 +1047,7 @@ let perform_analysis_phase tenv (summary: Specs.summary) (proc_cfg: ProcCfg.Exce
let set_current_language proc_desc = let set_current_language proc_desc =
let language = (Procdesc.get_attributes proc_desc).ProcAttributes.language in let language = Typ.Procname.get_language (Procdesc.get_proc_name proc_desc) in
Config.curr_language := language Config.curr_language := language

@ -1005,18 +1005,16 @@ let check_inconsistency_base tenv prop =
false false
| Some (_, _, pdesc) -> | Some (_, _, pdesc) ->
let procedure_attr = Procdesc.get_attributes pdesc in let procedure_attr = Procdesc.get_attributes pdesc in
let is_java_this pvar = let language = Typ.Procname.get_language (Procdesc.get_proc_name pdesc) in
Config.equal_language procedure_attr.ProcAttributes.language Config.Java let is_java_this pvar = Config.equal_language language Config.Java && Pvar.is_this pvar in
&& Pvar.is_this pvar
in
let is_objc_instance_self pvar = let is_objc_instance_self pvar =
Config.equal_language procedure_attr.ProcAttributes.language Config.Clang Config.equal_language language Config.Clang
&& Mangled.equal (Pvar.get_name pvar) (Mangled.from_string "self") && Mangled.equal (Pvar.get_name pvar) (Mangled.from_string "self")
&& procedure_attr.ProcAttributes.is_objc_instance_method && procedure_attr.ProcAttributes.is_objc_instance_method
in in
let is_cpp_this pvar = let is_cpp_this pvar =
Config.equal_language procedure_attr.ProcAttributes.language Config.Clang Config.equal_language language Config.Clang && Pvar.is_this pvar
&& Pvar.is_this pvar && procedure_attr.ProcAttributes.is_cpp_instance_method && procedure_attr.ProcAttributes.is_cpp_instance_method
in in
let do_hpred = function let do_hpred = function
| Sil.Hpointsto (Exp.Lvar pv, Sil.Eexp (e, _), _) -> | Sil.Hpointsto (Exp.Lvar pv, Sil.Eexp (e, _), _) ->

@ -772,7 +772,7 @@ let init_summary (nodes, calls, proc_desc) =
let dummy = let dummy =
let dummy_attributes = ProcAttributes.default Typ.Procname.empty_block Config.Java in let dummy_attributes = ProcAttributes.default Typ.Procname.empty_block in
let dummy_proc_desc = Procdesc.from_proc_attributes ~called_from_cfg:true dummy_attributes in let dummy_proc_desc = Procdesc.from_proc_attributes ~called_from_cfg:true dummy_attributes in
init_summary ([], [], dummy_proc_desc) init_summary ([], [], dummy_proc_desc)
@ -781,12 +781,3 @@ let dummy =
let reset_summary proc_desc = init_summary ([], [], proc_desc) let reset_summary proc_desc = init_summary ([], [], proc_desc)
(* =============== END of support for spec tables =============== *) (* =============== END of support for spec tables =============== *)
(*
let rec post_equal pl1 pl2 = match pl1, pl2 with
| [],[] -> true
| [], _:: _ -> false
| _:: _,[] -> false
| p1:: pl1', p2:: pl2' ->
if Prop.equal_prop p1 p2 then post_equal pl1' pl2'
else false
*)

@ -600,7 +600,7 @@ let create_local_procdesc ?(set_objc_accessor_attr= false) trans_unit_ctx cfg te
in in
let procdesc = let procdesc =
let proc_attributes = let proc_attributes =
{ (ProcAttributes.default proc_name Config.Clang) with { (ProcAttributes.default proc_name) with
ProcAttributes.captured= captured_mangled ProcAttributes.captured= captured_mangled
; formals ; formals
; const_formals ; const_formals
@ -648,7 +648,7 @@ let create_external_procdesc cfg proc_name is_objc_inst_method type_opt =
(Typ.mk Typ.Tvoid, []) (Typ.mk Typ.Tvoid, [])
in in
let proc_attributes = let proc_attributes =
{ (ProcAttributes.default proc_name Config.Clang) with { (ProcAttributes.default proc_name) with
ProcAttributes.formals; is_objc_instance_method= is_objc_inst_method; ret_type } ProcAttributes.formals; is_objc_instance_method= is_objc_inst_method; ret_type }
in in
ignore (Cfg.create_proc_desc cfg proc_attributes) ignore (Cfg.create_proc_desc cfg proc_attributes)
@ -694,4 +694,3 @@ let get_captures_from_cpp_lambda dec =
cxx_rdi.xrdi_lambda_captures cxx_rdi.xrdi_lambda_captures
| _ -> | _ ->
assert false assert false

@ -555,8 +555,7 @@ let typecheck_instr tenv ext calls_this checks (node: Procdesc.Node.t) idenv get
in in
let ret_type = Typ.java_proc_return_typ callee_pname_java in let ret_type = Typ.java_proc_return_typ callee_pname_java in
let proc_attributes = let proc_attributes =
{ (ProcAttributes.default callee_pname Config.Java) with {(ProcAttributes.default callee_pname) with ProcAttributes.formals; ret_type}
ProcAttributes.formals; ret_type }
in in
proc_attributes proc_attributes
in in

@ -306,7 +306,7 @@ let create_am_procdesc source_file program icfg am proc_name : Procdesc.t =
let method_annotation = JAnnotation.translate_method am.Javalib.am_annotations in let method_annotation = JAnnotation.translate_method am.Javalib.am_annotations in
let procdesc = let procdesc =
let proc_attributes = let proc_attributes =
{ (ProcAttributes.default proc_name Config.Java) with { (ProcAttributes.default proc_name) with
ProcAttributes.access= trans_access am.Javalib.am_access ProcAttributes.access= trans_access am.Javalib.am_access
; exceptions= List.map ~f:JBasics.cn_name am.Javalib.am_exceptions ; exceptions= List.map ~f:JBasics.cn_name am.Javalib.am_exceptions
; formals ; formals
@ -332,7 +332,7 @@ let create_native_procdesc source_file program icfg cm proc_name =
let method_annotation = JAnnotation.translate_method cm.Javalib.cm_annotations in let method_annotation = JAnnotation.translate_method cm.Javalib.cm_annotations in
let procdesc = let procdesc =
let proc_attributes = let proc_attributes =
{ (ProcAttributes.default proc_name Config.Java) with { (ProcAttributes.default proc_name) with
ProcAttributes.access= trans_access cm.Javalib.cm_access ProcAttributes.access= trans_access cm.Javalib.cm_access
; exceptions= List.map ~f:JBasics.cn_name cm.Javalib.cm_exceptions ; exceptions= List.map ~f:JBasics.cn_name cm.Javalib.cm_exceptions
; formals ; formals
@ -368,7 +368,7 @@ let create_cm_procdesc source_file program linereader icfg cm proc_name skip_imp
update_constr_loc cn ms loc_start ; update_constr_loc cn ms loc_start ;
update_init_loc cn ms loc_exit ; update_init_loc cn ms loc_exit ;
let proc_attributes = let proc_attributes =
{ (ProcAttributes.default proc_name Config.Java) with { (ProcAttributes.default proc_name) with
ProcAttributes.access= trans_access cm.Javalib.cm_access ProcAttributes.access= trans_access cm.Javalib.cm_access
; exceptions= List.map ~f:JBasics.cn_name cm.Javalib.cm_exceptions ; exceptions= List.map ~f:JBasics.cn_name cm.Javalib.cm_exceptions
; formals ; formals
@ -1124,4 +1124,3 @@ let instruction (context: JContext.t) pc instr : translation =
with Frontend_error s -> with Frontend_error s ->
L.internal_error "Skipping because of: %s@." s ; L.internal_error "Skipping because of: %s@." s ;
Skip Skip

@ -171,9 +171,7 @@ struct
let structured_program_to_cfg program test_pname = let structured_program_to_cfg program test_pname =
let cfg = Cfg.create_cfg () in let cfg = Cfg.create_cfg () in
let pdesc = let pdesc = Cfg.create_proc_desc cfg (ProcAttributes.default test_pname) in
Cfg.create_proc_desc cfg (ProcAttributes.default test_pname !Config.curr_language)
in
let pname = Procdesc.get_proc_name pdesc in let pname = Procdesc.get_proc_name pdesc in
let create_node kind cmds = Procdesc.create_node pdesc dummy_loc kind cmds in let create_node kind cmds = Procdesc.create_node pdesc dummy_loc kind cmds in
let set_succs cur_node succs ~exn_handlers = let set_succs cur_node succs ~exn_handlers =

@ -15,10 +15,7 @@ module BackwardInstrCfg = ProcCfg.Backward (InstrCfg)
let tests = let tests =
let cfg = Cfg.create_cfg () in let cfg = Cfg.create_cfg () in
let test_pdesc = let test_pdesc = Cfg.create_proc_desc cfg (ProcAttributes.default Typ.Procname.empty_block) in
Cfg.create_proc_desc cfg
(ProcAttributes.default Typ.Procname.empty_block !Config.curr_language)
in
let dummy_instr1 = Sil.Remove_temps ([], Location.dummy) in let dummy_instr1 = Sil.Remove_temps ([], Location.dummy) in
let dummy_instr2 = Sil.Abstract Location.dummy in let dummy_instr2 = Sil.Abstract Location.dummy in
let dummy_instr3 = Sil.Remove_temps ([Ident.create_fresh Ident.knormal], Location.dummy) in let dummy_instr3 = Sil.Remove_temps ([Ident.create_fresh Ident.knormal], Location.dummy) in

Loading…
Cancel
Save