diff --git a/infer/src/clang/cFrontend.ml b/infer/src/clang/cFrontend.ml index 7845c658c..3d5f9c492 100644 --- a/infer/src/clang/cFrontend.ml +++ b/infer/src/clang/cFrontend.ml @@ -96,14 +96,17 @@ let rec translate_one_declaration tenv cg cfg parent_dec dec = | dec -> ()); match dec with (* Currently C/C++ record decl treated in the same way *) - | ClassTemplateSpecializationDecl (_, _, _, _, decl_list, _, _, _) - | CXXRecordDecl (_, _, _, _, decl_list, _, _, _) - | RecordDecl (_, _, _, _, decl_list, _, _) -> + | ClassTemplateSpecializationDecl (decl_info, _, _, _, decl_list, _, _, _) + | CXXRecordDecl (decl_info, _, _, _, decl_list, _, _, _) + | RecordDecl (decl_info, _, _, _, decl_list, _, _) when not decl_info.di_is_implicit -> + let is_method_decl decl = match decl with + | CXXMethodDecl _ | CXXConstructorDecl _ | CXXDestructorDecl _ | FunctionTemplateDecl _ -> + true + | _ -> false in + let method_decls, no_method_decls = IList.partition is_method_decl decl_list in + IList.iter (translate_one_declaration tenv cg cfg dec) no_method_decls; ignore (CTypes_decl.add_types_from_decl_to_tenv tenv dec); - let method_decls = CTypes_decl.get_method_decls dec decl_list in - let tranlate_method (parent, decl) = - translate_one_declaration tenv cg cfg parent decl in - IList.iter tranlate_method method_decls + IList.iter (translate_one_declaration tenv cg cfg dec) method_decls | EnumDecl _ -> ignore (CEnum_decl.enum_decl dec) | LinkageSpecDecl (decl_info, decl_list, decl_context_info) -> Printing.log_out "ADDING: LinkageSpecDecl decl list\n"; diff --git a/infer/src/clang/cType_to_sil_type.ml b/infer/src/clang/cType_to_sil_type.ml index c32f54938..393699b2b 100644 --- a/infer/src/clang/cType_to_sil_type.ml +++ b/infer/src/clang/cType_to_sil_type.ml @@ -132,6 +132,7 @@ and decl_ptr_to_sil_type translate_decl tenv decl_ptr = match Ast_utils.get_decl decl_ptr with | Some (CXXRecordDecl _ as d) | Some (RecordDecl _ as d) + | Some (ClassTemplateSpecializationDecl _ as d) | Some (ObjCInterfaceDecl _ as d) | Some (ObjCImplementationDecl _ as d) | Some (ObjCProtocolDecl _ as d) diff --git a/infer/src/clang/cTypes_decl.ml b/infer/src/clang/cTypes_decl.ml index 6bf0d3a21..bf8b7d25d 100644 --- a/infer/src/clang/cTypes_decl.ml +++ b/infer/src/clang/cTypes_decl.ml @@ -99,20 +99,6 @@ let get_record_name_csu decl = let get_record_name decl = snd (get_record_name_csu decl) -let get_method_decls parent decl_list = - let open Clang_ast_t in - let rec traverse_decl parent decl = match decl with - | CXXMethodDecl _ | CXXConstructorDecl _ | CXXDestructorDecl _ -> [(parent, decl)] - | FunctionTemplateDecl (_, _, template_decl_info) -> - let decl_list' = template_decl_info.Clang_ast_t.tdi_specializations in - traverse_decl_list parent decl_list' - | ClassTemplateSpecializationDecl (_, _, _, _, decl_list', _, _, _) - | CXXRecordDecl (_, _, _, _, decl_list', _, _, _) - | RecordDecl (_, _, _, _, decl_list', _, _) -> traverse_decl_list decl decl_list' - | _ -> [] - and traverse_decl_list parent decl_list = IList.flatten (IList.map (traverse_decl parent) decl_list) in - traverse_decl_list parent decl_list - let get_class_methods tenv class_name decl_list = let process_method_decl = function | Clang_ast_t.CXXMethodDecl (decl_info, name_info, tp, function_decl_info, _) @@ -167,12 +153,6 @@ let rec get_struct_fields tenv decl = let typ = type_ptr_to_sil_type tenv type_ptr in let annotation_items = [] in (* For the moment we don't use them*) [(id, typ, annotation_items)] - | ClassTemplateSpecializationDecl (decl_info, _, _, _, _, _, _, _) - | CXXRecordDecl (decl_info, _, _, _, _, _, _, _) - | RecordDecl (decl_info, _, _, _, _, _, _) -> - (* C++/C Records treated in the same way*) - if not decl_info.Clang_ast_t.di_is_implicit then - ignore (add_types_from_decl_to_tenv tenv decl); [] | _ -> [] in let base_decls = get_superclass_decls decl in let base_class_fields = IList.map (get_struct_fields tenv) base_decls in diff --git a/infer/src/clang/cTypes_decl.mli b/infer/src/clang/cTypes_decl.mli index 686b0dcc2..5f720facd 100644 --- a/infer/src/clang/cTypes_decl.mli +++ b/infer/src/clang/cTypes_decl.mli @@ -13,8 +13,6 @@ val add_struct_to_tenv : Sil.tenv -> Sil.typ -> unit val get_record_name : Clang_ast_t.decl -> string -val get_method_decls : Clang_ast_t.decl -> Clang_ast_t.decl list -> (Clang_ast_t.decl * Clang_ast_t.decl) list - val add_types_from_decl_to_tenv : Sil.tenv -> Clang_ast_t.decl -> Sil.typ (* Adds the predefined types objc_class which is a struct, *)