| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | type status = Disabled | Enabled | AsError |
| 12 | |
| 13 | type category |
| 14 | (** Categories and warnings form a DAG with a common root [all] and warnings as the leaves. *) |
| 15 | |
| 16 | val all : category |
| 17 | |
| 18 | type warning |
| 19 | (** Each warning belongs to some categories maybe including ["default"]. |
| 20 | It is possible to query the status of a [warning] (unlike categories). |
| 21 | XXX we should probably have ["default-error"] too. *) |
| 22 | |
| 23 | type 'a msg |
| 24 | (** A [msg] belongs to a [warning]. *) |
| 25 | |
| 26 | val warn : 'a msg -> ?loc:Loc.t -> 'a -> unit |
| 27 | (** Emit a message in some warning. *) |
| 28 | |
| 29 | (** Creation functions |
| 30 | |
| 31 | Note that names are in a combined namespace including the special name ["none"]. |
| 32 | *) |
| 33 | |
| 34 | val create_category : ?from:category list -> name:string -> unit -> category |
| 35 | (** When [from] is not specified it defaults to [[all]]. Empty list |
| 36 | [from] is not allowed. "default" is not allowed in [from]. *) |
| 37 | |
| 38 | val create_warning : ?from:category list -> ?default:status -> name:string -> unit -> warning |
| 39 | (** [from] works the same as with [create_category]. In particular |
| 40 | default status is specified through the [default] argument not by |
| 41 | using the "default" category. *) |
| 42 | |
| 43 | val create_hybrid : ?from:category list -> ?default:status -> name:string -> unit -> category * warning |
| 44 | (** As [create_warning], but the warning can also be used as a category i.e. have sub-warnings. *) |
| 45 | |
| 46 | val create_msg : warning -> unit -> 'a msg |
| 47 | (** A message with data ['a] in the given warning. *) |
| 48 | |
| 49 | type 'a quickfix = loc:Loc.t -> 'a -> Quickfix.t list |
| 50 | (** Type of quickfix generator from ['a]. *) |
| 51 | |
| 52 | val create_in : warning -> ?quickfix:'a quickfix -> |
| 53 | ('a -> Pp.t) -> ?loc:Loc.t -> 'a -> unit |
| 54 | (** Create a msg with registered printer and optional quickfix. *) |
| 55 | |
| 56 | val register_printer : 'a msg -> ('a -> Pp.t) -> unit |
| 57 | (** Register the printer for a given message. If a printer is already registered it is replaced. *) |
| 58 | |
| 59 | val register_quickfix : 'a msg -> 'a quickfix -> unit |
| 60 | (** Register a quickfix generator for a given message. If a quickfix |
| 61 | generator is already registered it is combined with the new |
| 62 | generator. *) |
| 63 | |
| 64 | val create : name:string -> ?category:category -> ?default:status -> |
| 65 | ?quickfix:'a quickfix -> ('a -> Pp.t) -> ?loc:Loc.t -> 'a -> unit |
| 66 | (** Combined creation function. [name] must be a fresh name. *) |
| 67 | |
| 68 | (** Misc APIs *) |
| 69 | |
| 70 | val get_flags : unit -> string |
| 71 | val set_flags : string -> unit |
| 72 | |
| 73 | type 'a elt = |
| 74 | | There of 'a |
| 75 | | NotThere |
| 76 | | OtherType |
| 77 | |
| 78 | val get_category : string -> category elt |
| 79 | (** Get preexisting category by name. *) |
| 80 | |
| 81 | val get_warning : string -> warning elt |
| 82 | (** Get preexisting warning by name. *) |
| 83 | |
| 84 | val warning_status : warning -> status |
| 85 | (** Current status of the warning. *) |
| 86 | |
| 87 | val normalize_flags_string : string -> string |
| 88 | (** Cleans up a user provided warnings status string, e.g. removing unknown |
| 89 | warnings (in which case a warning is emitted) or subsumed warnings . *) |
| 90 | |
| 91 | val with_warn: string -> ('b -> 'a) -> 'b -> 'a |
| 92 | (** [with_warn "-xxx,+yyy..." f x] calls [f x] after setting the |
| 93 | warnings as specified in the string (keeping other previously set |
| 94 | warnings), and restores current warnings after [f()] returns or |
| 95 | raises an exception. If both f and restoring the warnings raise |
| 96 | exceptions, the latter is raised. *) |
| 97 | |
| 98 | val check_unknown_warnings : string -> unit |
| 99 | (** Warn with "unknown-warning" if any unknown warnings are in the |
| 100 | string with non-disabled status. *) |
| 101 | |
| 102 | val override_unknown_warning : bool ref |
| 103 | [@@ocaml.deprecated "(8.18) Do not use, internal."] |
| 104 | (** For command line -w, this avoids using the warning system to avoid breaking |
| 105 | "-w -unknown-warning". *) |
| 106 | |
| 107 | module CoreCategories : sig |
| 108 | (** Categories used in rocq-runtime. Might not be exhaustive. *) |
| 109 | |
| 110 | val automation : category |
| 111 | val bytecode_compiler : category |
| 112 | val coercions : category |
| 113 | val deprecated : category |
| 114 | val extraction : category |
| 115 | val filesystem : category |
| 116 | val fixpoints : category |
| 117 | val fragile : category |
| 118 | val funind : category |
| 119 | val implicits : category |
| 120 | val ltac : category |
| 121 | val ltac2 : category |
| 122 | val native_compiler : category |
| 123 | val numbers : category |
| 124 | val parsing : category |
| 125 | val pedantic : category |
| 126 | val records : category |
| 127 | val rewrite_rules : category |
| 128 | val ssr : category |
| 129 | val syntax : category |
| 130 | val tactics : category |
| 131 | val user_warn : category |
| 132 | val vernacular : category |
| 133 | val internal : category |
| 134 | |
| 135 | end |
| 136 | |
| 137 | val warn_ignored_coqlib : unit -> unit |