class fold_typ f acc = object inherit Visitor.frama_c_inplace val mutable known_types = Cil_datatype.Typ.Set.empty method vtype ty = if Cil_datatype.Typ.Set.mem ty known_types then Cil.DoChildren else begin known_types <- Cil_datatype.Typ.Set.add ty known_types; acc:= f ty !acc; Cil.DoChildren end end let fold_typ f init = let racc = ref init in let vis = new fold_typ f racc in Visitor.visitFramacFileSameGlobals vis (Ast.get()); !racc let test () = let f ty (maxty,maxsize as acc) = try let size = Cil.sizeOf_int ty in if size > maxsize then (ty,size) else acc with Cil.SizeOfError _ -> acc in let (ty,size) = fold_typ f (Cil.voidType,0) in Format.printf "Biggest type is %a,@ with size %d@." !Ast_printer.d_type ty size let () = Db.Main.extend test