[clang] remove is_generic_model boolean from procnames

Reviewed By: jvillard

Differential Revision: D7814296

fbshipit-source-id: f871889
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent 6c806d39c8
commit fe610330bf

@ -24,9 +24,7 @@ let create_objc_class_method class_name method_name =
let method_kind = Typ.Procname.ObjC_Cpp.ObjCClassMethod in let method_kind = Typ.Procname.ObjC_Cpp.ObjCClassMethod in
let tname = Typ.Name.Objc.from_string class_name in let tname = Typ.Name.Objc.from_string class_name in
let pname = let pname =
Typ.Procname.ObjC_Cpp Typ.Procname.ObjC_Cpp (Typ.Procname.ObjC_Cpp.make tname method_name method_kind Typ.NoTemplate)
(Typ.Procname.ObjC_Cpp.make tname method_name method_kind Typ.NoTemplate
~is_generic_model:false)
in in
register pname ; pname register pname ; pname

@ -255,9 +255,7 @@ let get_initializer_pname {pv_name; pv_kind} =
| Some file -> | Some file ->
let mangled = SourceFile.to_string file |> Utils.string_crc_hex32 in let mangled = SourceFile.to_string file |> Utils.string_crc_hex32 in
Typ.Procname.C Typ.Procname.C
(Typ.Procname.c (Typ.Procname.c (QualifiedCppName.of_qual_string name) mangled Typ.NoTemplate)
(QualifiedCppName.of_qual_string name)
mangled Typ.NoTemplate ~is_generic_model:false)
|> Option.return |> Option.return
| None -> | None ->
None None

@ -733,15 +733,11 @@ module Procname = struct
[@@deriving compare] [@@deriving compare]
type t = type t =
{ method_name: string {method_name: string; class_name: Name.t; kind: kind; template_args: template_spec_info}
; class_name: Name.t
; kind: kind
; template_args: template_spec_info
; is_generic_model: bool }
[@@deriving compare] [@@deriving compare]
let make class_name method_name kind template_args ~is_generic_model = let make class_name method_name kind template_args =
{class_name; method_name; kind; template_args; is_generic_model} {class_name; method_name; kind; template_args}
let get_class_name objc_cpp = Name.name objc_cpp.class_name let get_class_name objc_cpp = Name.name objc_cpp.class_name
@ -813,11 +809,7 @@ module Procname = struct
end end
(** Type of c procedure names. *) (** Type of c procedure names. *)
type c = type c = {name: QualifiedCppName.t; mangled: string option; template_args: template_spec_info}
{ name: QualifiedCppName.t
; mangled: string option
; template_args: template_spec_info
; is_generic_model: bool }
[@@deriving compare] [@@deriving compare]
(** Type of Objective C block names. *) (** Type of Objective C block names. *)
@ -847,16 +839,10 @@ module Procname = struct
let empty_block = Block "" let empty_block = Block ""
let c name mangled template_args ~is_generic_model = let c name mangled template_args = {name; mangled= Some mangled; template_args}
{name; mangled= Some mangled; template_args; is_generic_model}
let from_string_c_fun (name: string) = let from_string_c_fun (name: string) =
C C {name= QualifiedCppName.of_qual_string name; mangled= None; template_args= NoTemplate}
{ name= QualifiedCppName.of_qual_string name
; mangled= None
; template_args= NoTemplate
; is_generic_model= false }
let with_block_parameters base blocks = WithBlockParameters (base, blocks) let with_block_parameters base blocks = WithBlockParameters (base, blocks)
@ -1111,21 +1097,7 @@ module Procname = struct
Escape.escape_filename @@ DB.append_crc_cutoff ?crc_only proc_id Escape.escape_filename @@ DB.append_crc_cutoff ?crc_only proc_id
let to_generic_filename ?crc_only pname = let to_filename ?crc_only pname = to_concrete_filename ?crc_only pname
let proc_id =
get_qualifiers pname |> QualifiedCppName.strip_template_args |> QualifiedCppName.to_rev_list
|> String.concat ~sep:"#"
in
Escape.escape_filename @@ DB.append_crc_cutoff ?crc_only proc_id
let to_filename ?crc_only pname =
match pname with
| (C {is_generic_model} | ObjC_Cpp {is_generic_model}) when Bool.equal is_generic_model true ->
to_generic_filename ?crc_only pname
| _ ->
to_concrete_filename ?crc_only pname
module SQLite = struct module SQLite = struct
let pname_to_key = let pname_to_key =

@ -370,14 +370,10 @@ module Procname : sig
(** Type of Objective C and C++ procedure names: method signatures. *) (** Type of Objective C and C++ procedure names: method signatures. *)
type t = type t =
{ method_name: string {method_name: string; class_name: Name.t; kind: kind; template_args: template_spec_info}
; class_name: Name.t
; kind: kind
; template_args: template_spec_info
; is_generic_model: bool }
[@@deriving compare] [@@deriving compare]
val make : Name.t -> string -> kind -> template_spec_info -> is_generic_model:bool -> t val make : Name.t -> string -> kind -> template_spec_info -> t
(** Create an objc procedure name from a class_name and method_name. *) (** Create an objc procedure name from a class_name and method_name. *)
val get_class_name : t -> string val get_class_name : t -> string
@ -413,10 +409,7 @@ module Procname : sig
(** Type of c procedure names. *) (** Type of c procedure names. *)
type c = private type c = private
{ name: QualifiedCppName.t {name: QualifiedCppName.t; mangled: string option; template_args: template_spec_info}
; mangled: string option
; template_args: template_spec_info
; is_generic_model: bool }
(** Type of Objective C block names. *) (** Type of Objective C block names. *)
type block_name type block_name
@ -459,7 +452,7 @@ module Procname : sig
module SQLiteList : SqliteUtils.Data with type t = t list module SQLiteList : SqliteUtils.Data with type t = t list
val c : QualifiedCppName.t -> string -> template_spec_info -> is_generic_model:bool -> c val c : QualifiedCppName.t -> string -> template_spec_info -> c
(** Create a C procedure name from plain and mangled name. *) (** Create a C procedure name from plain and mangled name. *)
val empty_block : t val empty_block : t

@ -182,17 +182,6 @@ let get_record_definition decl =
decl decl
let is_decl_info_generic_model {Clang_ast_t.di_attributes} =
let f = function
| Clang_ast_t.AnnotateAttr {ai_parameters= [_; name; _]}
when String.equal name "__infer_generic_model" ->
true
| _ ->
false
in
List.exists ~f di_attributes
(** Global counter for anonymous block*) (** Global counter for anonymous block*)
let block_counter = ref 0 let block_counter = ref 0
@ -203,8 +192,7 @@ let get_fresh_block_index () =
let mk_objc_method class_typename method_name method_kind = let mk_objc_method class_typename method_name method_kind =
Typ.Procname.ObjC_Cpp Typ.Procname.ObjC_Cpp
(Typ.Procname.ObjC_Cpp.make class_typename method_name method_kind Typ.NoTemplate (Typ.Procname.ObjC_Cpp.make class_typename method_name method_kind Typ.NoTemplate)
~is_generic_model:false)
let rec get_mangled_method_name function_decl_info method_decl_info = let rec get_mangled_method_name function_decl_info method_decl_info =
@ -421,17 +409,17 @@ and mk_c_function ?tenv ~is_cpp name function_decl_info_opt =
None None
in in
let mangled_name = match mangled_opt with Some m when is_cpp -> m | _ -> "" in let mangled_name = match mangled_opt with Some m when is_cpp -> m | _ -> "" in
let template_info, is_generic_model = let template_info =
match (function_decl_info_opt, tenv) with match (function_decl_info_opt, tenv) with
| Some (decl_info, function_decl_info), Some t -> | Some (_, function_decl_info), Some t ->
(get_template_info t function_decl_info, is_decl_info_generic_model decl_info) get_template_info t function_decl_info
| _ -> | _ ->
(Typ.NoTemplate, false) Typ.NoTemplate
in in
let mangled = file ^ mangled_name in let mangled = file ^ mangled_name in
if String.is_empty mangled then if String.is_empty mangled then
Typ.Procname.from_string_c_fun (QualifiedCppName.to_qual_string name) Typ.Procname.from_string_c_fun (QualifiedCppName.to_qual_string name)
else Typ.Procname.C (Typ.Procname.c name mangled template_info ~is_generic_model) else Typ.Procname.C (Typ.Procname.c name mangled template_info)
and mk_cpp_method ?tenv class_name method_name ?meth_decl mangled = and mk_cpp_method ?tenv class_name method_name ?meth_decl mangled =
@ -445,28 +433,19 @@ and mk_cpp_method ?tenv class_name method_name ?meth_decl mangled =
| _ -> | _ ->
Typ.Procname.ObjC_Cpp.CPPMethod {mangled} Typ.Procname.ObjC_Cpp.CPPMethod {mangled}
in in
let template_info, is_generic_model = let template_info =
match meth_decl with match meth_decl with
| Some (CXXMethodDecl (di, _, _, fdi, _)) | Some
| Some (CXXConstructorDecl (di, _, _, fdi, _)) ( CXXMethodDecl (_, _, _, fdi, _)
| Some (CXXConversionDecl (di, _, _, fdi, _)) | CXXConstructorDecl (_, _, _, fdi, _)
| Some (CXXDestructorDecl (di, _, _, fdi, _)) -> | CXXConversionDecl (_, _, _, fdi, _)
let templ_info = | CXXDestructorDecl (_, _, _, fdi, _) ) -> (
match tenv with Some t -> get_template_info t fdi | None -> Typ.NoTemplate match tenv with Some t -> get_template_info t fdi | None -> Typ.NoTemplate )
in
let is_gen_model =
is_decl_info_generic_model di
|| (* read whether parent class is annoatated as generic model *)
di.di_parent_pointer |> Option.value_map ~f:CAst_utils.get_decl ~default:None
|> Option.map ~f:Clang_ast_proj.get_decl_tuple
|> Option.value_map ~f:is_decl_info_generic_model ~default:false
in
(templ_info, is_gen_model)
| _ -> | _ ->
(Typ.NoTemplate, false) Typ.NoTemplate
in in
Typ.Procname.ObjC_Cpp Typ.Procname.ObjC_Cpp
(Typ.Procname.ObjC_Cpp.make class_name method_name method_kind template_info ~is_generic_model) (Typ.Procname.ObjC_Cpp.make class_name method_name method_kind template_info)
and get_class_typename ?tenv method_decl_info = and get_class_typename ?tenv method_decl_info =

Loading…
Cancel
Save