Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 258 lines (188 sloc) 7.15 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 (** Manage all warning of compiler. *)
20
21 (** {6 Defined types}*)
22 (** Type of a warning.*)
23 type wclass
24
25 (**
26 Warning classes (wclass values) forms a hierarchy.
27 You can manipule both node and leaves of this hierarchy.
28 Each class describe a sub-set of warning.
29 You can then choose the default properties of all warnings in the class when creating it:
30 -enable/disable
31 -error/warning
32 and change this behaviour later
33 and you can use the class when emitting so that it follows the class common properties
34 *)
35
36 (** {6 Creating of warning classes} *)
37 (**
38 Create a new class of warning
39
40 parent : specify the ancestor class of the new class.
41 If you do not provide a parent value, the warning should be loaded for beeing part of the
42 warning table.
43 public : specify is the warning class is public or not
44 (i.e. if not public the user has no control on it,
45 and the message is an internal error (in error mode) or skipped )
46
47 doc : is the message associate to the command line option
48 err : behaviour of a warning of the class (true => error, false => warning)
49 enable : true => warning class enable, false => disable
50
51 *)
52
53 val create : ?parent:wclass -> ?public:bool -> name:string -> doc:string -> err:bool -> enable:bool -> unit -> wclass
54
55 (** {6 Regrouping Warnings} *)
56
57 (** Imperatives Set of wclasses *)
58 module Set :
59 sig
60 type t
61
62 (** Create a new empty set *)
63 val create : unit -> t
64
65 (**
66 Add a warning class and alls its children into the set.
67 Beware, you should add the parent warning given an hieararchy.
68 You cannot add a child, or a sub-branch alone, without adding the parent.
69 *)
70 val add : t -> wclass -> unit
71
72 val add_all : t -> wclass list -> unit
73
74 (**
75 [Set.add_set t t'] add in [t] all wclass of [t'].
76 Usefull for regrouping several warnings for a binary.
77 *)
78 val add_set : t -> t -> unit
79
80 (**
81 Create a new warning set and initialize it with the given list
82 of warning classes
83 *)
84 val create_from_list : wclass list -> t
85 end
86
87 (** {6 Loading Warnings} *)
88 (**
89 Load all wclass of a set into the global table. Any not loaded wclass is ignored,
90 the functions [is_warn] and [is_warn_error] will return always [false].
91
92 When you load a wclass, the load also all the children of the wclass
93 *)
94
95 val load : wclass -> unit
96 val load_set : Set.t -> unit
97
98 (** {6 Set properties of warning classes}*)
99
100 (** Set the error on warning. If is set to true, warning has same
101 behavior that an error.*)
102 val set_warn_error : wclass -> bool -> unit
103
104 (** Set print on warning. If is set to true warning is printed
105 else is not printed. *)
106 val set_warn : wclass -> bool -> unit
107
108 (** {6 Get properties of warning classes}*)
109
110 (**
111 If the wclass is not loaded, these functions returns always [false].
112 *)
113
114 val is_warn_error : wclass -> bool
115 val is_warn : wclass -> bool
116
117 (** returns the full name of the warning,
118 as it is used by the Arg.options.
119 In the hierarchy, warning are separated
120 with dots. except for the root node which
121 does not appear in any name *)
122 val get_name : wclass -> string
123
124 val get_doc : wclass -> string
125
126 (** {6 Iterators}*)
127
128 val fold : ('acc -> string list -> wclass -> 'acc) -> 'acc -> 'acc
129 (**
130 Fold on all the warnings loaded in the global table.
131 @param f takes:
132 - the accumulator
133 - the path to the current warning class
134 - the current warning class
135 The warning class can be used to access other information
136 of the warning class like the documentation string
137 *)
138
139 (** {6 Options} *)
140 (** Provides a specification list for parse line command. *)
141 module Arg : sig
142 (** The specification list of options for [PassHandler]. Define :
143 - --warn
144 - --no-warn
145 - --warn-error
146 - --no-warn-error
147 - --warn-help
148
149 TODO:--warn-bash-completion
150
151 The unit is there so that the warning class of this module have time
152 to be loaded and registered before returning the options list
153 *)
ee9137a [cleanup] options: removed useless () argument to cmdline options
Mathieu Baudet authored
154 val options : (Base.Arg.key * Base.Arg.spec * Base.Arg.doc) list
fccc685 Initial open-source release
MLstate authored
155
156 end
157
158 (** {6 Warning classes} *)
159
160 val get_from_path : string list -> wclass option
161 (**
162 Get a class from a name, searching in loaded wclass.
163 @param path The path in the warning hierarchy
164 Note that [\[\]] is a valid path that designates all the warnings
165 @raise Invalid_argument if the path doesn't exist
166 *)
167
168 val root_warning : wclass
169
170 (* GUIDELINES : ALPHABETIC ORDER OF PARENTS !!! *)
171 (* Define a parent in each part, use prefix for names hierarchy *)
172
173 (** {6 BSL Warnings} *)
174
175 (** The root of all bsl related warnings *)
176 val bsl : wclass
177
178 (** Warnings related to backend restriction *)
179 val bsl_backend_restriction : wclass
180
181 (** Warnings related to loading (essentially, plugins) *)
182 val bsl_loading : wclass
183
184 (** Warnings related to registering bypass *)
185 val bsl_projection : wclass
186
187 (** Warnings related to registering bypass *)
188 val bsl_register : wclass
189
190 (** Warnings related to type checking *)
191 val bsl_type_checking : wclass
192
193 (** Unknown bypass during compilation (not supported in every mode) *)
194 val bsl_unknown_bypass : wclass
195
196 (** {6 Conditions Warnings} *)
197
198 (**
199 GUIDELINES
200
201 Hierarchical warnings, alphabetical ordering,
202 and keep coherent with names from $(Lang)Check modules.
203
204 [QmlCheck], [OpaCheck], [OcamlCheck], [JsCheck], etc..
205
206 In modules [LangCheck], checks are in module, there,
207 everything is at top level with underscore.
208
209 Example :
210 [cond_annot_unicity], [cond_bypass_expanded]
211 represents the wclass used in :
212 {[
213 OpaCheck.Annot.unicity
214 QmlCheck.Bypass.expanded
215 ]}
216 *)
217
218 (** Used for pre/post condition on passes. *)
219 val cond : wclass
220
221 (** {6 Dbgen Warnings} *)
222
223 val dbgen : wclass
224
225 val dbgen_schema : wclass
226
227 (** {6 Explicit instantiation} *)
228
229 (** The root of all warnings related to explicit instantiation. *)
230 val ei : wclass
231
232 (** Explicit instantiation generalize a non-functionnal value. (A
233 non-functionnal value is transformed on functional value.) *)
234 val ei_generalize : wclass
235
236 (** {6 Patterns} *)
237
238 (** Warn suspicious patterns *)
239 val pattern : wclass
240
241
242 (** {6 PassHandler Warnings} *)
243
244 (** Root of pass system warnings. *)
245 val phandler : wclass
246
247 (** Warn if the pass system is not consistent. *)
248 val phandler_consistency : wclass
249
250 (** {6 Common warnings}
251 Warnings that can be raise by any compiler passes
252 *)
253 (** Root of common warnings *)
254 val warn : wclass
255
256 (** Use it when an optimization level is wrong*)
257 val warn_olevel : wclass
Something went wrong with that request. Please try again.