@@ -142,15 +142,11 @@ struct
142142 | TPtr (t ,_ ), `Index (i ,o ) -> type_of ~base: t o
143143 | TComp (ci ,_ ), `Field (f ,o ) ->
144144 let fi = try getCompField ci f.fname
145- with Not_found ->
146- let s = GobPretty. sprintf " Addr.type_offset: field %s not found in type %a" f.fname d_plaintype t in
147- raise (Type_of_error (t, s))
145+ with Not_found -> raise (Type_of_error (t, show o))
148146 in type_of ~base: fi.ftype o
149147 (* TODO: Why? Imprecise on zstd-thread-pool regression tests. *)
150148 (* | TComp _, `Index (_,o) -> type_of ~base:t o (* this happens (hmmer, perlbench). safe? *) *)
151- | t ,o ->
152- let s = GobPretty. sprintf " Addr.type_offset: could not follow offset in type. type: %a, offset: %a" d_plaintype t pretty o in
153- raise (Type_of_error (t, s))
149+ | t , o -> raise (Type_of_error (t, show o))
154150
155151 let rec prefix (x : t ) (y : t ): t option = match x,y with
156152 | `Index (x , xs ), `Index (y , ys ) when Idx. equal x y -> prefix xs ys
@@ -261,3 +257,9 @@ struct
261257 | `Index (i ,o ) -> Index (i, to_cil o)
262258 | `Field (f ,o ) -> Field (f, to_cil o)
263259end
260+
261+
262+ let () = Printexc. register_printer (function
263+ | Type_of_error (t , o ) -> Some (GobPretty. sprintf " Offset.Type_of_error(%a, %s)" d_plaintype t o)
264+ | _ -> None (* for other exceptions *)
265+ )
0 commit comments