diff --git a/infer/src/backend/sil.ml b/infer/src/backend/sil.ml index b3bd22624..6b46dfa31 100644 --- a/infer/src/backend/sil.ml +++ b/infer/src/backend/sil.ml @@ -3820,7 +3820,9 @@ let tenv_lookup tenv name = (** Add a (name,type) pair to the global type environment. *) let tenv_add tenv name typ = - TypenameHash.replace tenv name typ + match typ with + | Tvar _ -> assert false + | _ -> TypenameHash.replace tenv name typ (** expand a type if it is a typename by looking it up in the type environment *) let rec expand_type tenv typ = diff --git a/infer/src/clang/cTypes_decl.ml b/infer/src/clang/cTypes_decl.ml index 4f3e0a278..e8dd9d737 100644 --- a/infer/src/clang/cTypes_decl.ml +++ b/infer/src/clang/cTypes_decl.ml @@ -16,8 +16,7 @@ module L = Logging exception Typename_not_found let add_predefined_objc_types tenv = - let objc_class_mangled = Mangled.from_string CFrontend_config.objc_class in - let objc_class_name = Typename.TN_csu (Csu.Class Csu.Objc, objc_class_mangled) in + let class_typename = CType_to_sil_type.get_builtin_objc_typename `ObjCClass in let objc_class_type_info = Sil.Tstruct { Sil.instance_fields = []; @@ -28,15 +27,8 @@ let add_predefined_objc_types tenv = def_methods = []; struct_annotations = []; } in - Sil.tenv_add tenv objc_class_name objc_class_type_info; - let class_typename = CType_to_sil_type.get_builtin_objc_typename `ObjCClass in - let class_typ = Sil.Tvar (Typename.TN_csu (Csu.Struct, objc_class_mangled)) in - Sil.tenv_add tenv class_typename class_typ; - let typename_objc_object = - Typename.TN_csu (Csu.Struct, Mangled.from_string CFrontend_config.objc_object) in - let id_typedef = Sil.Tvar (typename_objc_object) in + Sil.tenv_add tenv class_typename objc_class_type_info; let id_typename = CType_to_sil_type.get_builtin_objc_typename `ObjCId in - Sil.tenv_add tenv id_typename id_typedef; let objc_object_type_info = Sil.Tstruct { Sil.instance_fields = []; @@ -47,7 +39,7 @@ let add_predefined_objc_types tenv = def_methods = []; struct_annotations = []; } in - Sil.tenv_add tenv typename_objc_object objc_object_type_info + Sil.tenv_add tenv id_typename objc_object_type_info (* Whenever new type are added manually to the translation in ast_expressions, *) (* they should be added here too!! *)