From 71e424d6ba281015d856163c322687aeeda0e701 Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Wed, 18 Nov 2015 06:59:41 -0800 Subject: [PATCH] Use qual_name to extract class name from method decl Summary: public New qual_name exporting logic in facebook-clang-plugins handles anonymous classes in much better way. This allows us to simplify name generation for classes that don't rely on a type of the object (which could be wrong for methods from superclasses). Reviewed By: dulmarod Differential Revision: D2663810 fb-gh-sync-id: 08146b8 --- facebook-clang-plugins | 2 +- infer/src/clang/cField_decl.ml | 4 ++- infer/src/clang/cFrontend.ml | 8 ++--- infer/src/clang/cFrontend_utils.ml | 36 +++++++++++++------ infer/src/clang/cFrontend_utils.mli | 9 +++-- infer/src/clang/cMethod_decl.ml | 5 ++- infer/src/clang/cMethod_trans.ml | 23 ++++++------ infer/src/clang/cMethod_trans.mli | 4 +-- infer/src/clang/cTrans.ml | 6 ++-- infer/src/clang/cTypes_decl.ml | 18 ++++------ infer/src/clang/objcCategory_decl.ml | 6 ++-- infer/src/clang/objcInterface_decl.ml | 8 ++--- infer/src/clang/objcProperty_decl.ml | 5 ++- infer/src/clang/objcProtocol_decl.ml | 2 +- .../c/frontend/nestedoperators/union.c.dot | 4 +-- .../c/frontend/nestedoperators/union.cpp.dot | 8 ++--- .../cpp/frontend/namespace/namespace.cpp.dot | 8 ++--- 17 files changed, 87 insertions(+), 69 deletions(-) diff --git a/facebook-clang-plugins b/facebook-clang-plugins index 0c61c0a85..c85d3bc3d 160000 --- a/facebook-clang-plugins +++ b/facebook-clang-plugins @@ -1 +1 @@ -Subproject commit 0c61c0a85be411f93d66e2a1e9fb359337496777 +Subproject commit c85d3bc3da1868901c5884252194b2b77dbd54a2 diff --git a/infer/src/clang/cField_decl.ml b/infer/src/clang/cField_decl.ml index 8356cb012..f01a1a313 100644 --- a/infer/src/clang/cField_decl.ml +++ b/infer/src/clang/cField_decl.ml @@ -30,7 +30,9 @@ let fields_superclass tenv interface_decl_info = match interface_decl_info.Clang_ast_t.otdi_super with | Some dr -> (match dr.Clang_ast_t.dr_name with - | Some sc -> get_fields_super_classes tenv (CTypes.mk_classname sc.Clang_ast_t.ni_name) + | Some sc -> + let classname = CTypes.mk_classname (Ast_utils.get_qualified_name sc) in + get_fields_super_classes tenv classname | _ -> []) | _ -> [] diff --git a/infer/src/clang/cFrontend.ml b/infer/src/clang/cFrontend.ml index 5f6560f70..1521a8508 100644 --- a/infer/src/clang/cFrontend.ml +++ b/infer/src/clang/cFrontend.ml @@ -44,26 +44,26 @@ let rec translate_one_declaration tenv cg cfg namespace parent_dec dec = IList.iter tranlate_method method_decls | ObjCInterfaceDecl(decl_info, name_info, decl_list, decl_context_info, oi_decl_info) -> - let name = name_info.Clang_ast_t.ni_name in + let name = Ast_utils.get_qualified_name name_info in let curr_class = ObjcInterface_decl.get_curr_class name oi_decl_info in ignore (ObjcInterface_decl.interface_declaration CTypes_decl.type_ptr_to_sil_type tenv dec); CMethod_declImpl.process_methods tenv cg cfg curr_class namespace decl_list | ObjCProtocolDecl(decl_info, name_info, decl_list, decl_context_info, _) -> - let name = name_info.Clang_ast_t.ni_name in + let name = Ast_utils.get_qualified_name name_info in let curr_class = CContext.ContextProtocol name in ignore (ObjcProtocol_decl.protocol_decl CTypes_decl.type_ptr_to_sil_type tenv dec); CMethod_declImpl.process_methods tenv cg cfg curr_class namespace decl_list | ObjCCategoryDecl(decl_info, name_info, decl_list, decl_context_info, ocdi) -> - let name = name_info.Clang_ast_t.ni_name in + let name = Ast_utils.get_qualified_name name_info in let curr_class = ObjcCategory_decl.get_curr_class_from_category_decl name ocdi in ignore (ObjcCategory_decl.category_decl CTypes_decl.type_ptr_to_sil_type tenv dec); CMethod_declImpl.process_methods tenv cg cfg curr_class namespace decl_list | ObjCCategoryImplDecl(decl_info, name_info, decl_list, decl_context_info, ocidi) -> - let name = name_info.Clang_ast_t.ni_name in + let name = Ast_utils.get_qualified_name name_info in let curr_class = ObjcCategory_decl.get_curr_class_from_category_impl name ocidi in ignore (ObjcCategory_decl.category_impl_decl CTypes_decl.type_ptr_to_sil_type tenv dec); CMethod_declImpl.process_methods tenv cg cfg curr_class namespace decl_list diff --git a/infer/src/clang/cFrontend_utils.ml b/infer/src/clang/cFrontend_utils.ml index 30f142815..6fc8f9a81 100644 --- a/infer/src/clang/cFrontend_utils.ml +++ b/infer/src/clang/cFrontend_utils.ml @@ -148,20 +148,30 @@ struct | Some ns when ns ="" -> "" | Some ns -> ns^"::" - let get_qualifier_string name_info = - match name_info.Clang_ast_t.ni_qual_name with + let fold_qual_name qual_name_list = + match qual_name_list with | [] -> "" - | name :: qualifiers -> - IList.fold_right (fun el res -> res ^ el ^ "::") qualifiers "" + | name :: quals -> + let s = (IList.fold_right (fun el res -> res ^ el ^ "::") quals "") ^ name in + let no_slash = Str.global_replace (Str.regexp "/") "_" s in + no_slash + + let get_qualified_name name_info = + fold_qual_name name_info.Clang_ast_t.ni_qual_name + + let get_class_name_from_member member_name_info = + match member_name_info.Clang_ast_t.ni_qual_name with + | _ :: class_qual_list -> fold_qual_name class_qual_list + | [] -> assert false let make_name_decl name = { Clang_ast_t.ni_name = name; ni_qual_name = [name]; } - let make_qual_name_decl class_name name = { + let make_qual_name_decl class_name_quals name = { Clang_ast_t.ni_name = name; - ni_qual_name = [name; class_name]; + ni_qual_name = name :: class_name_quals; } let property_name property_impl_decl_info = @@ -239,7 +249,7 @@ struct let name_opt_of_name_info_opt name_info_opt = match name_info_opt with - | Some name_info -> Some name_info.Clang_ast_t.ni_name + | Some name_info -> Some (get_qualified_name name_info) | None -> None let rec getter_attribute_opt attributes = @@ -274,7 +284,12 @@ struct let is_generated name_info = match name_info.Clang_ast_t.ni_qual_name with - | generated:: rest -> generated = CFrontend_config.generated_suffix + | name :: quals -> + (try + let rexp = Str.regexp CFrontend_config.generated_suffix in + let _ = Str.search_forward rexp name 0 in + true + with Not_found -> false) | _ -> false let get_decl decl_ptr = @@ -487,9 +502,8 @@ struct let mk_class_field_name field_qual_name = let field_name = field_qual_name.Clang_ast_t.ni_name in - let prefix = Ast_utils.get_qualifier_string field_qual_name in - Ident.create_fieldname (Mangled.mangled field_name prefix) 0 - + let class_name = Ast_utils.get_class_name_from_member field_qual_name in + Ident.create_fieldname (Mangled.mangled field_name class_name) 0 let get_rel_file_path file_opt = match file_opt with diff --git a/infer/src/clang/cFrontend_utils.mli b/infer/src/clang/cFrontend_utils.mli index 33f294449..d2e87fd25 100644 --- a/infer/src/clang/cFrontend_utils.mli +++ b/infer/src/clang/cFrontend_utils.mli @@ -87,8 +87,11 @@ sig val get_enum_constant_exp : Clang_ast_t.pointer -> Clang_ast_t.pointer option * Sil.exp option - (** creates a string to append to a name from a list of qualifiers to a name *) - val get_qualifier_string : Clang_ast_t.named_decl_info -> string + (** returns fully qualified name given name info *) + val get_qualified_name : Clang_ast_t.named_decl_info -> string + + (** returns qualified class name given member name info *) + val get_class_name_from_member : Clang_ast_t.named_decl_info -> string (** looks up clang pointer to type and returns c_type. It requires type_ptr to be `TPtr. *) val get_type : Clang_ast_t.type_ptr -> Clang_ast_t.c_type option @@ -105,7 +108,7 @@ sig val make_name_decl : string -> Clang_ast_t.named_decl_info - val make_qual_name_decl : string -> string -> Clang_ast_t.named_decl_info + val make_qual_name_decl : string list -> string -> Clang_ast_t.named_decl_info type type_ptr_to_sil_type = Sil.tenv -> Clang_ast_t.type_ptr -> Sil.typ diff --git a/infer/src/clang/cMethod_decl.ml b/infer/src/clang/cMethod_decl.ml index a2b4ad58d..0c8767083 100644 --- a/infer/src/clang/cMethod_decl.ml +++ b/infer/src/clang/cMethod_decl.ml @@ -72,7 +72,7 @@ struct | Some (outer_context, _, _, captured_vars) -> captured_vars, Some outer_context | None -> [], None in let ms, body_opt, extra_instrs = - CMethod_trans.method_signature_of_decl None func_decl block_data_opt in + CMethod_trans.method_signature_of_decl func_decl block_data_opt in match body_opt with | Some body -> (* Only in the case the function declaration has a defined body we create a procdesc *) let procname = CMethod_signature.ms_get_name ms in @@ -82,9 +82,8 @@ struct | None -> () let process_method_decl tenv cg cfg namespace curr_class meth_decl ~is_objc = - let class_name = Some (CContext.get_curr_class_name curr_class) in let ms, body_opt, extra_instrs = - CMethod_trans.method_signature_of_decl class_name meth_decl None in + CMethod_trans.method_signature_of_decl meth_decl None in match body_opt with | Some body -> let is_instance = CMethod_signature.ms_is_instance ms in diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index 056c5099c..c4ce2f9d9 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -108,10 +108,10 @@ let get_init_list_instrs method_decl_info = let create_custom_instr construct_instr = `CXXConstructorInit construct_instr in IList.map create_custom_instr method_decl_info.Clang_ast_t.xmdi_cxx_ctor_initializers -let method_signature_of_decl class_name_opt meth_decl block_data_opt = +let method_signature_of_decl meth_decl block_data_opt = let open Clang_ast_t in - match meth_decl, block_data_opt, class_name_opt with - | FunctionDecl (decl_info, name_info, tp, fdi), _, _ -> + match meth_decl, block_data_opt with + | FunctionDecl (decl_info, name_info, tp, fdi), _ -> let name = name_info.ni_name in let language = !CFrontend_config.language in let func_decl = Func_decl_info (fdi, tp, language) in @@ -120,17 +120,19 @@ let method_signature_of_decl class_name_opt meth_decl block_data_opt = let ms = build_method_signature decl_info procname func_decl false false in let extra_instrs = get_assume_not_null_calls ms fdi.Clang_ast_t.fdi_parameters in ms, fdi.Clang_ast_t.fdi_body, extra_instrs - | CXXMethodDecl (decl_info, name_info, tp, fdi, mdi), _, Some class_name - | CXXConstructorDecl (decl_info, name_info, tp, fdi, mdi), _, Some class_name -> + | CXXMethodDecl (decl_info, name_info, tp, fdi, mdi), _ + | CXXConstructorDecl (decl_info, name_info, tp, fdi, mdi), _ -> let method_name = name_info.Clang_ast_t.ni_name in + let class_name = Ast_utils.get_class_name_from_member name_info in let procname = General_utils.mk_procname_from_cpp_method class_name method_name tp in let method_decl = Cpp_Meth_decl_info (fdi, class_name, tp) in let ms = build_method_signature decl_info procname method_decl false false in let non_null_instrs = get_assume_not_null_calls ms fdi.Clang_ast_t.fdi_parameters in let init_list_instrs = get_init_list_instrs mdi in (* it will be empty for methods *) ms, fdi.Clang_ast_t.fdi_body, (init_list_instrs @ non_null_instrs) - | ObjCMethodDecl (decl_info, name_info, mdi), _, Some class_name -> + | ObjCMethodDecl (decl_info, name_info, mdi), _ -> let method_name = name_info.ni_name in + let class_name = Ast_utils.get_class_name_from_member name_info in let is_instance = mdi.omdi_is_instance_method in let method_kind = Procname.objc_method_kind_of_bool is_instance in let procname = General_utils.mk_procname_from_objc_method class_name method_name method_kind in @@ -139,19 +141,18 @@ let method_signature_of_decl class_name_opt meth_decl block_data_opt = let ms = build_method_signature decl_info procname method_decl false is_generated in let extra_instrs = get_assume_not_null_calls ms mdi.omdi_parameters in ms, mdi.omdi_body, extra_instrs - | BlockDecl (decl_info, bdi), - Some (outer_context, tp, procname, _), _ -> + | BlockDecl (decl_info, bdi), Some (outer_context, tp, procname, _) -> let func_decl = Block_decl_info (bdi, tp, outer_context) in let ms = build_method_signature decl_info procname func_decl true false in let extra_instrs = get_assume_not_null_calls ms bdi.bdi_parameters in ms, bdi.bdi_body, extra_instrs | _ -> raise Invalid_declaration -let method_signature_of_pointer class_name_opt pointer = +let method_signature_of_pointer pointer = try match Ast_utils.get_decl pointer with | Some meth_decl -> - let ms, _, _ = method_signature_of_decl class_name_opt meth_decl None in + let ms, _, _ = method_signature_of_decl meth_decl None in Some ms | None -> None with Invalid_declaration -> None @@ -320,7 +321,7 @@ let create_external_procdesc cfg proc_name is_objc_inst_method type_opt = let create_procdesc_with_pointer context pointer class_name_opt name tp = let open CContext in - match method_signature_of_pointer class_name_opt pointer with + match method_signature_of_pointer pointer with | Some callee_ms -> ignore (create_local_procdesc context.cfg context.tenv callee_ms [] [] false); CMethod_signature.ms_get_name callee_ms diff --git a/infer/src/clang/cMethod_trans.mli b/infer/src/clang/cMethod_trans.mli index d02e829f0..968fd25af 100644 --- a/infer/src/clang/cMethod_trans.mli +++ b/infer/src/clang/cMethod_trans.mli @@ -30,10 +30,10 @@ val get_class_selector_instance : CContext.t -> Clang_ast_t.obj_c_message_expr_i val should_create_procdesc : Cfg.cfg -> Procname.t -> bool -> bool -> bool -val method_signature_of_decl : string option -> Clang_ast_t.decl -> CModule_type.block_data option -> +val method_signature_of_decl : Clang_ast_t.decl -> CModule_type.block_data option -> CMethod_signature.method_signature * Clang_ast_t.stmt option * CModule_type.instr_type list -val method_signature_of_pointer : string option -> Clang_ast_t.pointer -> CMethod_signature.method_signature option +val method_signature_of_pointer : Clang_ast_t.pointer -> CMethod_signature.method_signature option val create_procdesc_with_pointer : CContext.t -> Clang_ast_t.pointer -> string option -> string -> Clang_ast_t.type_ptr -> Procname.t diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 4bd8e7727..e1dcf243e 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -48,7 +48,7 @@ struct let found_method = match method_pointer_opt with | Some pointer -> - (match CMethod_trans.method_signature_of_pointer (Some class_name) pointer with + (match CMethod_trans.method_signature_of_pointer pointer with | Some callee_ms -> if not (M.process_getter_setter context callee_pn) then (ignore (CMethod_trans.create_local_procdesc context.cfg context.tenv callee_ms [] [] is_instance)); @@ -96,7 +96,7 @@ struct let procname = Cfg.Procdesc.get_proc_name procdesc in let mk_field_from_captured_var (var, typ) = let vname = Sil.pvar_get_name var in - let qual_name = Ast_utils.make_qual_name_decl block_name (Mangled.to_string vname) in + let qual_name = Ast_utils.make_qual_name_decl [block_name] (Mangled.to_string vname) in let fname = General_utils.mk_class_field_name qual_name in let item_annot = Sil.item_annotation_empty in fname, typ, item_annot in @@ -377,6 +377,7 @@ struct let context = trans_state.context in let name_info, decl_ptr, type_ptr = get_info_from_decl_ref decl_ref in let method_name = name_info.Clang_ast_t.ni_name in + let class_name = Ast_utils.get_class_name_from_member name_info in Printing.log_out "!!!!! Dealing with method '%s' @." method_name; let method_typ = CTypes_decl.type_ptr_to_sil_type context.tenv type_ptr in (* we don't handle C++ static methods yet - when they are called, this might cause a crash *) @@ -385,7 +386,6 @@ struct "WARNING: in Method call we expect to know the object\n" in (* consider using context.CContext.is_callee_expression to deal with pointers to methods? *) (* unlike field access, for method calls there is no need to expand class type *) - let class_name = match class_typ with Sil.Tptr (t, _) | t -> CTypes.classname_of_type t in let pname = CMethod_trans.create_procdesc_with_pointer context decl_ptr (Some class_name) method_name type_ptr in let method_exp = (Sil.Const (Sil.Cfun pname), method_typ) in diff --git a/infer/src/clang/cTypes_decl.ml b/infer/src/clang/cTypes_decl.ml index fb13c50fb..b3dbdfb6e 100644 --- a/infer/src/clang/cTypes_decl.ml +++ b/infer/src/clang/cTypes_decl.ml @@ -73,13 +73,12 @@ let add_predefined_types tenv = let create_csu opt_type = match opt_type with | `Type s -> - (let no_slash = Str.global_replace (Str.regexp "/") "_" s in - let buf = Str.split (Str.regexp "[ \t]+") no_slash in + (let buf = Str.split (Str.regexp "[ \t]+") s in match buf with - | "struct":: l ->Sil.Struct, General_utils.string_from_list l - | "class":: l -> Sil.Class, General_utils.string_from_list l - | "union":: l -> Sil.Union, General_utils.string_from_list l - | _ -> Sil.Struct, s) + | "struct":: l ->Sil.Struct + | "class":: l -> Sil.Class + | "union":: l -> Sil.Union + | _ -> Sil.Struct) | _ -> assert false (* We need to take the name out of the type as the struct can be anonymous*) @@ -92,12 +91,9 @@ let get_record_name_csu decl = (* types that have methods. And in C++ struct/class/union can have methods *) name_info, opt_type, not cxx_record_info.xrdi_is_c_like | _-> assert false in - let name_str = name_info.ni_name in - let csu, type_name = create_csu opt_type in + let csu = create_csu opt_type in let csu' = if should_be_class then Sil.Class else csu in - let prefix = Ast_utils.get_qualifier_string name_info in - let name = - if (String.length name_str = 0) then prefix ^ type_name else prefix ^ name_str in + let name = Ast_utils.get_qualified_name name_info in csu', name let get_record_name decl = snd (get_record_name_csu decl) diff --git a/infer/src/clang/objcCategory_decl.ml b/infer/src/clang/objcCategory_decl.ml index 37626e90c..a9050443f 100644 --- a/infer/src/clang/objcCategory_decl.ml +++ b/infer/src/clang/objcCategory_decl.ml @@ -21,7 +21,7 @@ let noname_category class_name = let cat_class_decl dr = match dr.Clang_ast_t.dr_name with - | Some n -> n.Clang_ast_t.ni_name + | Some n -> Ast_utils.get_qualified_name n | _ -> assert false let get_curr_class_from_category name decl_ref_opt = @@ -77,7 +77,7 @@ let category_decl type_ptr_to_sil_type tenv decl = let open Clang_ast_t in match decl with | ObjCCategoryDecl (decl_info, name_info, decl_list, decl_context_info, cdi) -> - let name = name_info.Clang_ast_t.ni_name in + let name = Ast_utils.get_qualified_name name_info in let curr_class = get_curr_class_from_category_decl name cdi in Printing.log_out "ADDING: ObjCCategoryDecl for '%s'\n" name; let _ = add_class_decl type_ptr_to_sil_type tenv cdi in @@ -90,7 +90,7 @@ let category_impl_decl type_ptr_to_sil_type tenv decl = let open Clang_ast_t in match decl with | ObjCCategoryImplDecl (decl_info, name_info, decl_list, decl_context_info, cii) -> - let name = name_info.Clang_ast_t.ni_name in + let name = Ast_utils.get_qualified_name name_info in let curr_class = get_curr_class_from_category_impl name cii in Printing.log_out "ADDING: ObjCCategoryImplDecl for '%s'\n" name; let _ = add_category_decl type_ptr_to_sil_type tenv cii in diff --git a/infer/src/clang/objcInterface_decl.ml b/infer/src/clang/objcInterface_decl.ml index 5620ff8e1..205c79292 100644 --- a/infer/src/clang/objcInterface_decl.ml +++ b/infer/src/clang/objcInterface_decl.ml @@ -47,7 +47,7 @@ let get_super_interface_decl otdi_super = let get_protocols protocols = let protocol_names = IList.map ( fun decl -> match decl.Clang_ast_t.dr_name with - | Some name -> name.Clang_ast_t.ni_name + | Some name_info -> Ast_utils.get_qualified_name name_info | None -> assert false ) protocols in protocol_names @@ -63,7 +63,7 @@ let get_curr_class_impl oi = | Some decl_ref -> (match Ast_utils.get_decl decl_ref.Clang_ast_t.dr_decl_pointer with | Some ObjCInterfaceDecl (_, name_info, _, _, obj_c_interface_decl_info) -> - let class_name = name_info.Clang_ast_t.ni_name in + let class_name = Ast_utils.get_qualified_name name_info in get_curr_class class_name obj_c_interface_decl_info | _ -> assert false) | _ -> assert false @@ -166,7 +166,7 @@ let interface_declaration type_ptr_to_sil_type tenv decl = let open Clang_ast_t in match decl with | ObjCInterfaceDecl (decl_info, name_info, decl_list, _, ocidi) -> - let name = name_info.Clang_ast_t.ni_name in + let name = Ast_utils.get_qualified_name name_info in let curr_class = get_curr_class name ocidi in let typ = add_class_to_tenv type_ptr_to_sil_type tenv curr_class decl_info name decl_list ocidi in @@ -183,7 +183,7 @@ let interface_impl_declaration type_ptr_to_sil_type tenv decl = let open Clang_ast_t in match decl with | ObjCImplementationDecl (decl_info, name_info, decl_list, decl_context_info, idi) -> - let class_name = name_info.Clang_ast_t.ni_name in + let class_name = Ast_utils.get_qualified_name name_info in Printing.log_out "ADDING: ObjCImplementationDecl for class '%s'\n" class_name; let _ = add_class_decl type_ptr_to_sil_type tenv idi in let curr_class = get_curr_class_impl idi in diff --git a/infer/src/clang/objcProperty_decl.ml b/infer/src/clang/objcProperty_decl.ml index e695d4d1b..9e999a34b 100644 --- a/infer/src/clang/objcProperty_decl.ml +++ b/infer/src/clang/objcProperty_decl.ml @@ -272,8 +272,11 @@ let get_memory_management_attribute attributes = with Not_found -> None let create_generated_method_name name_info = + let qual_name = match name_info.Clang_ast_t.ni_qual_name with + | [] -> [] + | name :: quals -> (name ^ CFrontend_config.generated_suffix) :: quals in { Clang_ast_t.ni_name = name_info.Clang_ast_t.ni_name; - ni_qual_name = CFrontend_config.generated_suffix:: name_info.Clang_ast_t.ni_qual_name; + ni_qual_name = qual_name; } let get_ivar_name prop_name ivar_opt = diff --git a/infer/src/clang/objcProtocol_decl.ml b/infer/src/clang/objcProtocol_decl.ml index f2c9a26a1..f510ee991 100644 --- a/infer/src/clang/objcProtocol_decl.ml +++ b/infer/src/clang/objcProtocol_decl.ml @@ -20,7 +20,7 @@ let protocol_decl type_ptr_to_sil_type tenv decl = let open Clang_ast_t in match decl with | ObjCProtocolDecl(decl_info, name_info, decl_list, _, obj_c_protocol_decl_info) -> - let name = name_info.Clang_ast_t.ni_name in + let name = Ast_utils.get_qualified_name name_info in let curr_class = CContext.ContextProtocol name in (* Adds pairs (protocol name, protocol_type_info) to the global environment. *) (* Protocol_type_info contains the methods composing the protocol. *) diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c.dot b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c.dot index 7009e551f..9187c9b30 100644 --- a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c.dot @@ -1,5 +1,5 @@ digraph iCFG { -7 [label="7: BinaryOperatorStmt: Assign \n n$3=*&#GB$x:struct (anonymous at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.c:12:1) * [line 27]\n *n$3.a:int =1 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n " shape="box"] +7 [label="7: BinaryOperatorStmt: Assign \n n$3=*&#GB$x:struct anonymous_record_in_infer_tests_codetoanalyze_c_frontend_nestedoperators_union.c:12:1 * [line 27]\n *n$3.a:int =1 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n " shape="box"] 7 -> 6 ; @@ -11,7 +11,7 @@ digraph iCFG { 5 -> 4 ; -4 [label="4: BinaryOperatorStmt: Assign \n n$0=*&#GB$x:struct (anonymous at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.c:12:1) * [line 31]\n n$1=*n$0.b:int [line 31]\n *&#GB$y.g.w:int =n$1 [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n " shape="box"] +4 [label="4: BinaryOperatorStmt: Assign \n n$0=*&#GB$x:struct anonymous_record_in_infer_tests_codetoanalyze_c_frontend_nestedoperators_union.c:12:1 * [line 31]\n n$1=*n$0.b:int [line 31]\n *&#GB$y.g.w:int =n$1 [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n " shape="box"] 4 -> 3 ; diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp.dot b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp.dot index 06f3c2948..fa3bb3f98 100644 --- a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp.dot +++ b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp.dot @@ -1,5 +1,5 @@ digraph iCFG { -9 [label="9: BinaryOperatorStmt: Assign \n n$3=*&#GB$x:struct (anonymous at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:12:1) * [line 27]\n *n$3.a:int =1 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n " shape="box"] +9 [label="9: BinaryOperatorStmt: Assign \n n$3=*&#GB$x:struct anonymous_record_in_infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:12:1 * [line 27]\n *n$3.a:int =1 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n " shape="box"] 9 -> 8 ; @@ -11,7 +11,7 @@ digraph iCFG { 7 -> 6 ; -6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&#GB$x:struct (anonymous at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:12:1) * [line 31]\n n$1=*n$0.b:int [line 31]\n *&#GB$y.g.w:int =n$1 [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n " shape="box"] +6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&#GB$x:struct anonymous_record_in_infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:12:1 * [line 31]\n n$1=*n$0.b:int [line 31]\n *&#GB$y.g.w:int =n$1 [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n " shape="box"] 6 -> 5 ; @@ -26,10 +26,10 @@ digraph iCFG { 3 -> 9 ; -2 [label="2: Exit (anonymous at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:14:1)_ \n " color=yellow style=filled] +2 [label="2: Exit anonymous_record_in_infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:14:1_ \n " color=yellow style=filled] -1 [label="1: Start (anonymous at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:14:1)_\nFormals: this:class (anonymous at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:14:1) *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n NULLIFY(&this,false); [line 14]\n " color=yellow style=filled] +1 [label="1: Start anonymous_record_in_infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:14:1_\nFormals: this:class anonymous_record_in_infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:14:1 *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n NULLIFY(&this,false); [line 14]\n " color=yellow style=filled] 1 -> 2 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp.dot index afdd4ebac..cc8ef09e9 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp.dot @@ -1,5 +1,5 @@ digraph iCFG { -24 [label="24: Call _fun_foo::foo::my_record_ \n _fun_foo::foo::my_record_(&x:struct foo::foo::my_record *) [line 45]\n " shape="box"] +24 [label="24: Call _fun_foo::my_record_ \n _fun_foo::my_record_(&x:struct foo::my_record *) [line 45]\n " shape="box"] 24 -> 23 ; @@ -42,7 +42,7 @@ digraph iCFG { 14 [label="14: Exit main \n " color=yellow style=filled] -13 [label="13: Start main\nFormals: \nLocals: rect2:class foo::Rectangle rect1:class bar::Rectangle x:struct foo::foo::my_record j:double i:int \n DECLARE_LOCALS(&return,&rect2,&rect1,&x,&j,&i); [line 40]\n NULLIFY(&i,false); [line 40]\n NULLIFY(&j,false); [line 40]\n " color=yellow style=filled] +13 [label="13: Start main\nFormals: \nLocals: rect2:class foo::Rectangle rect1:class bar::Rectangle x:struct foo::my_record j:double i:int \n DECLARE_LOCALS(&return,&rect2,&rect1,&x,&j,&i); [line 40]\n NULLIFY(&i,false); [line 40]\n NULLIFY(&j,false); [line 40]\n " color=yellow style=filled] 13 -> 24 ; @@ -82,10 +82,10 @@ digraph iCFG { 3 -> 5 ; -2 [label="2: Exit foo::foo::my_record_ \n " color=yellow style=filled] +2 [label="2: Exit foo::my_record_ \n " color=yellow style=filled] -1 [label="1: Start foo::foo::my_record_\nFormals: this:class foo::foo::my_record *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n NULLIFY(&this,false); [line 15]\n " color=yellow style=filled] +1 [label="1: Start foo::my_record_\nFormals: this:class foo::my_record *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n NULLIFY(&this,false); [line 15]\n " color=yellow style=filled] 1 -> 2 ;