From fe610330bf44446852cc745696c8399fff30f115 Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Tue, 1 May 2018 06:02:31 -0700 Subject: [PATCH] [clang] remove is_generic_model boolean from procnames Reviewed By: jvillard Differential Revision: D7814296 fbshipit-source-id: f871889 --- infer/src/IR/BuiltinDecl.ml | 4 +-- infer/src/IR/Pvar.ml | 4 +-- infer/src/IR/Typ.ml | 42 +++++------------------------ infer/src/IR/Typ.mli | 15 +++-------- infer/src/clang/CType_decl.ml | 51 +++++++++++------------------------ 5 files changed, 28 insertions(+), 88 deletions(-) diff --git a/infer/src/IR/BuiltinDecl.ml b/infer/src/IR/BuiltinDecl.ml index 4eb18c416..2661eafb0 100644 --- a/infer/src/IR/BuiltinDecl.ml +++ b/infer/src/IR/BuiltinDecl.ml @@ -24,9 +24,7 @@ let create_objc_class_method class_name method_name = let method_kind = Typ.Procname.ObjC_Cpp.ObjCClassMethod in let tname = Typ.Name.Objc.from_string class_name in let pname = - Typ.Procname.ObjC_Cpp - (Typ.Procname.ObjC_Cpp.make tname method_name method_kind Typ.NoTemplate - ~is_generic_model:false) + Typ.Procname.ObjC_Cpp (Typ.Procname.ObjC_Cpp.make tname method_name method_kind Typ.NoTemplate) in register pname ; pname diff --git a/infer/src/IR/Pvar.ml b/infer/src/IR/Pvar.ml index c3596e1e4..cbb98d8ae 100644 --- a/infer/src/IR/Pvar.ml +++ b/infer/src/IR/Pvar.ml @@ -255,9 +255,7 @@ let get_initializer_pname {pv_name; pv_kind} = | Some file -> let mangled = SourceFile.to_string file |> Utils.string_crc_hex32 in Typ.Procname.C - (Typ.Procname.c - (QualifiedCppName.of_qual_string name) - mangled Typ.NoTemplate ~is_generic_model:false) + (Typ.Procname.c (QualifiedCppName.of_qual_string name) mangled Typ.NoTemplate) |> Option.return | None -> None diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index 2bc7bd65e..06ef5904a 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -733,15 +733,11 @@ module Procname = struct [@@deriving compare] type t = - { method_name: string - ; class_name: Name.t - ; kind: kind - ; template_args: template_spec_info - ; is_generic_model: bool } + {method_name: string; class_name: Name.t; kind: kind; template_args: template_spec_info} [@@deriving compare] - let make class_name method_name kind template_args ~is_generic_model = - {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} let get_class_name objc_cpp = Name.name objc_cpp.class_name @@ -813,11 +809,7 @@ module Procname = struct end (** Type of c procedure names. *) - type c = - { name: QualifiedCppName.t - ; mangled: string option - ; template_args: template_spec_info - ; is_generic_model: bool } + type c = {name: QualifiedCppName.t; mangled: string option; template_args: template_spec_info} [@@deriving compare] (** Type of Objective C block names. *) @@ -847,16 +839,10 @@ module Procname = struct let empty_block = Block "" - let c name mangled template_args ~is_generic_model = - {name; mangled= Some mangled; template_args; is_generic_model} - + let c name mangled template_args = {name; mangled= Some mangled; template_args} let from_string_c_fun (name: string) = - C - { name= QualifiedCppName.of_qual_string name - ; mangled= None - ; template_args= NoTemplate - ; is_generic_model= false } + C {name= QualifiedCppName.of_qual_string name; mangled= None; template_args= NoTemplate} 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 - let to_generic_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 - + let to_filename ?crc_only pname = to_concrete_filename ?crc_only pname module SQLite = struct let pname_to_key = diff --git a/infer/src/IR/Typ.mli b/infer/src/IR/Typ.mli index f83b6fe2c..943e9aa1e 100644 --- a/infer/src/IR/Typ.mli +++ b/infer/src/IR/Typ.mli @@ -370,14 +370,10 @@ module Procname : sig (** Type of Objective C and C++ procedure names: method signatures. *) type t = - { method_name: string - ; class_name: Name.t - ; kind: kind - ; template_args: template_spec_info - ; is_generic_model: bool } + {method_name: string; class_name: Name.t; kind: kind; template_args: template_spec_info} [@@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. *) val get_class_name : t -> string @@ -413,10 +409,7 @@ module Procname : sig (** Type of c procedure names. *) type c = private - { name: QualifiedCppName.t - ; mangled: string option - ; template_args: template_spec_info - ; is_generic_model: bool } + {name: QualifiedCppName.t; mangled: string option; template_args: template_spec_info} (** Type of Objective C block names. *) type block_name @@ -459,7 +452,7 @@ module Procname : sig 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. *) val empty_block : t diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index ac06d606b..398563eef 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -182,17 +182,6 @@ let get_record_definition 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*) let block_counter = ref 0 @@ -203,8 +192,7 @@ let get_fresh_block_index () = let mk_objc_method class_typename method_name method_kind = Typ.Procname.ObjC_Cpp - (Typ.Procname.ObjC_Cpp.make class_typename method_name method_kind Typ.NoTemplate - ~is_generic_model:false) + (Typ.Procname.ObjC_Cpp.make class_typename method_name method_kind Typ.NoTemplate) 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 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 - | Some (decl_info, function_decl_info), Some t -> - (get_template_info t function_decl_info, is_decl_info_generic_model decl_info) + | Some (_, function_decl_info), Some t -> + get_template_info t function_decl_info | _ -> - (Typ.NoTemplate, false) + Typ.NoTemplate in let mangled = file ^ mangled_name in if String.is_empty mangled then 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 = @@ -445,28 +433,19 @@ and mk_cpp_method ?tenv class_name method_name ?meth_decl mangled = | _ -> Typ.Procname.ObjC_Cpp.CPPMethod {mangled} in - let template_info, is_generic_model = + let template_info = match meth_decl with - | Some (CXXMethodDecl (di, _, _, fdi, _)) - | Some (CXXConstructorDecl (di, _, _, fdi, _)) - | Some (CXXConversionDecl (di, _, _, fdi, _)) - | Some (CXXDestructorDecl (di, _, _, fdi, _)) -> - let templ_info = - 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) + | Some + ( CXXMethodDecl (_, _, _, fdi, _) + | CXXConstructorDecl (_, _, _, fdi, _) + | CXXConversionDecl (_, _, _, fdi, _) + | CXXDestructorDecl (_, _, _, fdi, _) ) -> ( + match tenv with Some t -> get_template_info t fdi | None -> Typ.NoTemplate ) | _ -> - (Typ.NoTemplate, false) + Typ.NoTemplate in 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 =