diff --git a/infer/src/clang/cFrontend_utils.ml b/infer/src/clang/cFrontend_utils.ml index b3fddfd2b..a6ece500b 100644 --- a/infer/src/clang/cFrontend_utils.ml +++ b/infer/src/clang/cFrontend_utils.ml @@ -350,13 +350,10 @@ struct let get_decl_from_typ_ptr typ_ptr = let typ_opt = get_desugared_type typ_ptr in let typ = match typ_opt with Some t -> t | _ -> assert false in - let get_decl_or_fail decl_ptr = match get_decl decl_ptr with - | Some d -> d - | None -> assert false in (* it needs extending to handle objC types *) match typ with - | Clang_ast_t.RecordType (ti, decl_ptr) -> get_decl_or_fail decl_ptr - | _ -> assert false + | Clang_ast_t.RecordType (ti, decl_ptr) -> get_decl decl_ptr + | _ -> None (*TODO take the attributes into account too. To be done after we get the attribute's arguments. *) let is_type_nonnull type_ptr = diff --git a/infer/src/clang/cFrontend_utils.mli b/infer/src/clang/cFrontend_utils.mli index d2f0bcf5f..e78e2a975 100644 --- a/infer/src/clang/cFrontend_utils.mli +++ b/infer/src/clang/cFrontend_utils.mli @@ -103,7 +103,7 @@ sig (** returns declaration of the type for certain types and crashes for others NOTE: this function needs extending to handle objC types *) - val get_decl_from_typ_ptr : Clang_ast_t.type_ptr -> Clang_ast_t.decl + val get_decl_from_typ_ptr : Clang_ast_t.type_ptr -> Clang_ast_t.decl option val string_of_type_ptr : Clang_ast_t.type_ptr -> string diff --git a/infer/src/clang/cTypes_decl.ml b/infer/src/clang/cTypes_decl.ml index 56b82fd6d..a23c463e9 100644 --- a/infer/src/clang/cTypes_decl.ml +++ b/infer/src/clang/cTypes_decl.ml @@ -133,7 +133,10 @@ let get_superclass_decls decl = | ClassTemplateSpecializationDecl (_, _, _, _, _, _, _, cxx_rec_info) -> (* there is no concept of virtual inheritance in the backend right now *) let base_ptr = cxx_rec_info.Clang_ast_t.xrdi_bases @ cxx_rec_info.Clang_ast_t.xrdi_vbases in - IList.map Ast_utils.get_decl_from_typ_ptr base_ptr + let get_decl_or_fail typ_ptr = match Ast_utils.get_decl_from_typ_ptr typ_ptr with + | Some decl -> decl + | None -> assert false in + IList.map get_decl_or_fail base_ptr | _ -> [] (** fetches list of superclasses for C++ classes *)