Skip to content

Commit

Permalink
silenced warnings from ours deprecations (#885)
Browse files Browse the repository at this point in the history
* silenced warnings from ours deprecations

This PR silences warnings from bap code during compilation of
bap itself. Also, it turned out that few modules in `bap.mli`
were deprecated in a way that doesn't emit warnings at all:

Just for the record, the next doesn't deprecate `module A`,
because according to the documentation for attributes of level 3:
> They are not attached to any specific node in the syntax tree

```
module A = struct
  [@@@deprecated "[since ...]"]
  ...
end
```

And the next works as expected, although in this case we have
do the deprecation in the end of module, which makes it less
readable. But anyway, looks like we don't have any other choice.

```
module A = struct
  ...
end [@@deprecated "[since ...]"]
```

* fixed the documentation
  • Loading branch information
gitoleg committed Oct 6, 2018
1 parent 1e9ac45 commit c080b91
Show file tree
Hide file tree
Showing 23 changed files with 88 additions and 41 deletions.
82 changes: 46 additions & 36 deletions lib/bap/bap.mli
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ open Graphlib.Std
open Bap_future.Std open Bap_future.Std


module Std : sig module Std : sig
[@@@warning "-D"]

(** {2 Overview} (** {2 Overview}
{3 Layered Architecture} {3 Layered Architecture}
Expand Down Expand Up @@ -616,12 +618,11 @@ module Std : sig
module Make(T : Base) : S with type t = T.t module Make(T : Base) : S with type t = T.t
end end


(**/**) (** Legacy
@deprecated Definitions in this module are deprecated
**)
module Legacy : sig module Legacy : sig
[@@@deprecated "[since 2018-03] Definitions in this module are deprecated"]
module Monad : sig module Monad : sig
[@@@deprecated
"[since 2018-03] The module is deprecated in favor of new monads library"]
open Core_kernel.Std open Core_kernel.Std
module type Basic = Monad.Basic module type Basic = Monad.Basic
module type Basic2 = Monad.Basic2 module type Basic2 = Monad.Basic2
Expand Down Expand Up @@ -665,7 +666,10 @@ module Std : sig
end end
end end
end end
[@@deprecated
"[since 2018-03] The module is deprecated in favor of new monads library"]
end end
[@@deprecated "[since 2018-03] Definitions in this module are deprecated"]


(**/**) (**/**)


Expand Down Expand Up @@ -2240,7 +2244,7 @@ module Std : sig
end end


(** Result of a computation. (** Result of a computation.
@deprecated Use the Primus Framework. @deprecated Use the Primus Framework.
*) *)
type result type result
[@@deprecated "[since 2018-03] in favor of the Primus Framework"] [@@deprecated "[since 2018-03] in favor of the Primus Framework"]
Expand All @@ -2256,7 +2260,6 @@ module Std : sig
Bili. Bili.
@deprecated Use the Primus Framework. @deprecated Use the Primus Framework.
*) *)
class type storage = object('s) class type storage = object('s)


Expand All @@ -2268,10 +2271,10 @@ module Std : sig
end end
[@@deprecated "[since 2018-03] in favor of the Primus Framework"] [@@deprecated "[since 2018-03] in favor of the Primus Framework"]


(** Predefined storage classes *) (** Predefined storage classes
@deprecated Use the Primus Framework
*)
module Storage : sig module Storage : sig
[@@@deprecated "[since 2018-03] in favor of the Primus Framework"]
[@@@warning "-D"]


(** linear storage literally implements operational (** linear storage literally implements operational
semantics, but has O(N) lookup and uses space semantics, but has O(N) lookup and uses space
Expand All @@ -2285,6 +2288,8 @@ module Std : sig
update method. *) update method. *)
class sparse : storage class sparse : storage
end end
[@@deprecated "[since 2018-03] in favor of the Primus Framework"]



(** Value of a result. (** Value of a result.
We slightly diverge from an operational semantics by allowing We slightly diverge from an operational semantics by allowing
Expand Down Expand Up @@ -2342,8 +2347,6 @@ module Std : sig
@deprecated Use the Primus Framework @deprecated Use the Primus Framework
*) *)
module Result : sig module Result : sig
[@@@deprecated "[since 2018-03] in favor of the Primus Framework"]
[@@@warning "-D"]


(** result identifier *) (** result identifier *)
type id type id
Expand Down Expand Up @@ -2389,6 +2392,7 @@ module Std : sig
module Value : Printable.S with type t = value module Value : Printable.S with type t = value
include Printable.S with type t := t include Printable.S with type t := t
end end
[@@deprecated "[since 2018-03] in favor of the Primus Framework"]


(** Tries on BIL. (** Tries on BIL.
Expand Down Expand Up @@ -2694,8 +2698,6 @@ module Std : sig
@deprecated Use the Primus Framework @deprecated Use the Primus Framework
*) *)
module Context : sig module Context : sig
[@@@deprecated "[since 2018-03] in favor of the Primus Framework"]
[@@@warning "-D"]


class t : object('s) class t : object('s)


Expand All @@ -2711,7 +2713,7 @@ module Std : sig
for debugging and introspection. *) for debugging and introspection. *)
method bindings : (var * Bil.result) seq method bindings : (var * Bil.result) seq
end end
end end [@@deprecated "[since 2018-03] in favor of the Primus Framework"]


module Type_error : module type of Type.Error with type t = Type.Error.t module Type_error : module type of Type.Error with type t = Type.Error.t


Expand Down Expand Up @@ -2862,8 +2864,6 @@ module Std : sig
@deprecated Use the Primus Framework @deprecated Use the Primus Framework
*) *)
module Expi : sig module Expi : sig
[@@@deprecated "[since 2018-03] in favor of the Primus Framework"]
[@@@warning "-D"]


open Bil.Result open Bil.Result
(** (**
Expand Down Expand Up @@ -3064,9 +3064,11 @@ module Std : sig
with type ('a,'e) state = ('a,'e) M.t with type ('a,'e) state = ('a,'e) M.t


include S with type ('a,'e) state = ('a,'e) Monad.State.t include S with type ('a,'e) state = ('a,'e) Monad.State.t
end end [@@deprecated "[since 2018-03] in favor of the Primus Framework"]


(** Expression {{!Expi}interpreter} *) (** Expression {{!Expi}interpreter}
@deprecated Use the Primus Framework
*)
class ['a] expi : ['a] Expi.t class ['a] expi : ['a] Expi.t
[@@deprecated "[since 2018-03] in favor of the Primus Framework"] [@@deprecated "[since 2018-03] in favor of the Primus Framework"]


Expand All @@ -3089,10 +3091,10 @@ module Std : sig
ctxt#bindings |> Seq.to_list;; ctxt#bindings |> Seq.to_list;;
- : (var * Bil.result) list = [(x, [0x1] false)] - : (var * Bil.result) list = [(x, [0x1] false)]
v} v}
@deprecated Use the Primus Framework
*) *)
module Bili : sig module Bili : sig
[@@@deprecated "[since 2018-03] in favor of the Primus Framework"]
[@@@warning "-D"]


open Bil.Result open Bil.Result


Expand Down Expand Up @@ -3128,9 +3130,12 @@ module Std : sig


module Make(M : Monad.State.S2) : S with type ('a,'e) state = ('a,'e) M.t module Make(M : Monad.State.S2) : S with type ('a,'e) state = ('a,'e) M.t
include S with type ('a,'e) state = ('a,'e) Monad.State.t include S with type ('a,'e) state = ('a,'e) Monad.State.t
end end [@@deprecated "[since 2018-03] in favor of the Primus Framework"]



(** BIL {{!Bili}interpreter} *) (** BIL {{!Bili}interpreter}
@deprecated Use the Primus Framework
*)
class ['a] bili : ['a] Bili.t class ['a] bili : ['a] Bili.t
[@@deprecated "[since 2018-03] in favor of the Primus Framework"] [@@deprecated "[since 2018-03] in favor of the Primus Framework"]


Expand Down Expand Up @@ -3507,7 +3512,6 @@ module Std : sig


(** [eval x] evaluate expression [x] to a value. *) (** [eval x] evaluate expression [x] to a value. *)
val eval : t -> Bil.value val eval : t -> Bil.value
[@@warning "-D"]


include Regular.S with type t := t include Regular.S with type t := t
val pp_adt : t printer val pp_adt : t printer
Expand Down Expand Up @@ -4377,9 +4381,6 @@ module Std : sig
@deprecated Use the Primus Framework. @deprecated Use the Primus Framework.
*) *)
module Biri : sig module Biri : sig
[@@@deprecated "[since 2018-03] in favor of the Primus Framework"]
[@@@warning "-D"]

open Bil.Result open Bil.Result


(** Biri evaluates terms in the context of a whole program (since (** Biri evaluates terms in the context of a whole program (since
Expand Down Expand Up @@ -4507,10 +4508,14 @@ module Std : sig
S with type ('a,'e) state = ('a,'e) M.t S with type ('a,'e) state = ('a,'e) M.t


include S with type ('a,'e) state = ('a,'e) Monad.State.t include S with type ('a,'e) state = ('a,'e) Monad.State.t
end end [@@deprecated "[since 2018-03] in favor of the Primus Framework"]



(** BIR {{!Biri}interpreter} *) (** BIR {{!Biri}interpreter}
@deprecated Use the Primus Framework
*)
class ['a] biri : ['a] Biri.t class ['a] biri : ['a] Biri.t
[@@deprecated "[since 2018-03] in favor of the Primus Framework"]


(** {3 Some predefined tags} *) (** {3 Some predefined tags} *)


Expand Down Expand Up @@ -5104,10 +5109,11 @@ module Std : sig
This interface must be implemented by a backend plugin, and This interface must be implemented by a backend plugin, and
registered with [Image.register] function in order to be registered with [Image.register] function in order to be
accessible for loading images.*) accessible for loading images.
@deprecated Use new Ogre-powered loader interface
*)
module Backend : sig module Backend : sig
[@@@deprecated "[since 2017-08] Use new loader Ogre-powered loader interface"]


(** memory access permissions *) (** memory access permissions *)
type perm = R | W | X | Or of perm * perm type perm = R | W | X | Or of perm * perm
Expand Down Expand Up @@ -5156,7 +5162,7 @@ module Std : sig


(** the actual interface to be implemented *) (** the actual interface to be implemented *)
type t = Bigstring.t -> Img.t option type t = Bigstring.t -> Img.t option
end end [@@deprecated "[since 2017-08] Use new Ogre-powered loader interface"]


(** Binary Image. *) (** Binary Image. *)
module Image : sig module Image : sig
Expand Down Expand Up @@ -5331,7 +5337,9 @@ module Std : sig
val available_backends : unit -> string list val available_backends : unit -> string list


(** [register_backend ~name backend] tries to register [backend] under (** [register_backend ~name backend] tries to register [backend] under
the specified [name]. *) the specified [name].
@deprecated use register_loader instead
*)
val register_backend : name:string -> Backend.t -> [ `Ok | `Duplicate ] val register_backend : name:string -> Backend.t -> [ `Ok | `Duplicate ]
[@@deprecated "[since 2017-07] use register_loader instead"] [@@deprecated "[since 2017-07] use register_loader instead"]


Expand Down Expand Up @@ -7713,10 +7721,12 @@ module Std : sig
We represent a taint with a term identifier, to designate that a We represent a taint with a term identifier, to designate that a
taint was produced by a term with the given id. A taint set is taint was produced by a term with the given id. A taint set is
usually associated with each variable of a given term. This set usually associated with each variable of a given term. This set
defines a set of taints with which a variable is tainted.*) defines a set of taints with which a variable is tainted.
@deprecated use the Bap Taint Framework
*)
module Taint : sig module Taint : sig
[@@@deprecated "[since 2018-03] use the Bap Taint Framework instead"]
[@@@warning "-D"]
type t = tid type t = tid


type set = Tid.Set.t [@@deriving bin_io, compare, sexp] type set = Tid.Set.t [@@deriving bin_io, compare, sexp]
Expand Down Expand Up @@ -7843,7 +7853,7 @@ module Std : sig
val pp_map : map printer val pp_map : map printer


module Map : Regular.S with type t = map module Map : Regular.S with type t = map
end end [@@deprecated "[since 2018-03] use the Bap Taint Framework instead"]


type 'a source = 'a Source.t type 'a source = 'a Source.t


Expand Down
1 change: 1 addition & 0 deletions lib/bap_bml/bap_bml.ml
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
open Core_kernel.Std open Core_kernel.Std
open Bap.Std open Bap.Std


[@@@warning "-D"]


exception Parse_error of string exception Parse_error of string


Expand Down
3 changes: 2 additions & 1 deletion lib/bap_llvm/bap_llvm_loader.ml
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,10 @@
open Core_kernel.Std open Core_kernel.Std
open Bap.Std open Bap.Std
open Monads.Std open Monads.Std

open Bap_llvm_binary open Bap_llvm_binary


[@@@warning "-D"]

let make_addr arch addr = let make_addr arch addr =
match Arch.addr_size arch with match Arch.addr_size arch with
| `r32 -> Addr.of_int64 ~width:32 addr | `r32 -> Addr.of_int64 ~width:32 addr
Expand Down
3 changes: 2 additions & 1 deletion lib/bap_primus/bap_primus.mli
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ open Bap_future.Std
open Bap_strings.Std open Bap_strings.Std


module Std : sig module Std : sig

(** Primus - The Microexecution Framework. (** Primus - The Microexecution Framework.
Expand Down Expand Up @@ -57,6 +56,8 @@ module Std : sig
it can modify other components (depending on their interface). it can modify other components (depending on their interface).
*) *)
[@@@warning "-D"]

module Primus : sig module Primus : sig
(** Machine Exception. (** Machine Exception.
Expand Down
4 changes: 4 additions & 0 deletions lib/microx/microx_concretizer.ml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ open Monads.Std
module SM = Monad.State module SM = Monad.State
open SM.Monad_infix open SM.Monad_infix


[@@@warning "-D"]

type policy = [`Random | `Fixed of int64 | `Interval of int64 * int64 ] type policy = [`Random | `Fixed of int64 | `Interval of int64 * int64 ]
[@@deriving sexp_of] [@@deriving sexp_of]


Expand All @@ -22,8 +24,10 @@ class ['a] main
?random_seed ?random_seed
?(reg_policy=`Random) ?(reg_policy=`Random)
?(mem_policy=`Random) () = ?(mem_policy=`Random) () =

object(self) object(self)
inherit ['a] expi as super inherit ['a] expi as super

initializer Option.iter random_seed ~f:Random.init initializer Option.iter random_seed ~f:Random.init


method! eval_unknown _ t = self#emit reg_policy t method! eval_unknown _ t = self#emit reg_policy t
Expand Down
2 changes: 2 additions & 0 deletions lib/microx/microx_concretizer.mli
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,7 @@
open Bap.Std open Bap.Std


[@@@warning "-D"]

type policy = [ type policy = [
| `Random | `Random
| `Fixed of int64 | `Interval of int64 * int64 ] | `Fixed of int64 | `Interval of int64 * int64 ]
Expand Down
3 changes: 3 additions & 0 deletions lib/microx/microx_conqueror.ml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ let merge_visited = Map.merge ~f:(fun ~key -> function
class context class context
?(max_steps=Int.max_value) ?(max_steps=Int.max_value)
?(max_loop= min 10 (max_steps / 10)) p = object(self : 's) ?(max_loop= min 10 (max_steps / 10)) p = object(self : 's)
[@@@warning "-D"]

inherit Biri.context p inherit Biri.context p


val blk : blk term option = None val blk : blk term option = None
Expand Down Expand Up @@ -117,6 +119,7 @@ end
class ['a] main ?(deterministic=false) p = class ['a] main ?(deterministic=false) p =
object(self) object(self)
constraint 'a = #context constraint 'a = #context
[@@@warning "-D"]
inherit ['a] Biri.t as super inherit ['a] Biri.t as super


method! enter_term cls t = method! enter_term cls t =
Expand Down
1 change: 1 addition & 0 deletions lib/microx/microx_conqueror.mli
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class context :
?max_steps:int -> ?max_steps:int ->
?max_loop:int -> ?max_loop:int ->
program term -> object('s) program term -> object('s)
[@@@warning "-D"]
inherit Biri.context inherit Biri.context


method visited : int Tid.Map.t method visited : int Tid.Map.t
Expand Down
4 changes: 3 additions & 1 deletion lib_test/bap_image/test_image.ml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ open Core_kernel.Std
open OUnit2 open OUnit2
open Or_error open Or_error
open Word_size open Word_size

open Bap.Std open Bap.Std

[@@@warning "-D"]
open Backend open Backend


let ident = Int64.of_int let ident = Int64.of_int
Expand Down Expand Up @@ -90,6 +91,7 @@ let () = List.iter ~f:(fun (name,backend) ->
| `Ok -> () | `Ok -> ()
| `Duplicate -> failwith name) | `Duplicate -> failwith name)
backends backends
[@@warning "-D"]


let print_list r = let print_list r =
let sexp_of_addr_list = sexp_of_list sexp_of_addr in let sexp_of_addr_list = sexp_of_list sexp_of_addr in
Expand Down
3 changes: 2 additions & 1 deletion lib_test/bap_types/test_bili.ml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ let printer = function
let assert_exp value exp ctxt = let assert_exp value exp ctxt =
assert_equal ~ctxt ~printer value (Exp.eval exp) assert_equal ~ctxt ~printer value (Exp.eval exp)


let assert_prg value prg ctxt = let assert_prg value prg ctxt =
let open Monad.State.Monad_infix in let open Monad.State.Monad_infix in
let bili = new bili in let bili = new bili in
assert_equal ~ctxt ~printer value @@ assert_equal ~ctxt ~printer value @@
let res = bili#eval prg >>= fun () -> bili#lookup r >>| Bil.Result.value in let res = bili#eval prg >>= fun () -> bili#lookup r >>| Bil.Result.value in
Monad.State.eval res (new Bili.context) Monad.State.eval res (new Bili.context)
[@@warning "-D"]


let suite () = let suite () =
"Bili" >::: [ "Bili" >::: [
Expand Down
2 changes: 2 additions & 0 deletions lib_test/bap_types/test_optimizations.ml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ open Core_kernel
open OUnit2 open OUnit2
open Bap.Std open Bap.Std


[@@@warning "-D"]

let width = 8 let width = 8
let typ = Type.imm width let typ = Type.imm width
let int x = Bil.int (Word.of_int ~width x) let int x = Bil.int (Word.of_int ~width x)
Expand Down
2 changes: 2 additions & 0 deletions lib_test/powerpc/powerpc_tests_helpers.ml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ open Core_kernel.Std
open Bap.Std open Bap.Std
open OUnit2 open OUnit2


[@@@warning "-D"]

module Dis = Disasm_expert.Basic module Dis = Disasm_expert.Basic


module type Bitwidth = sig module type Bitwidth = sig
Expand Down
Loading

0 comments on commit c080b91

Please sign in to comment.