blob: 6fea20ad98285dfe50a15a2d36c8fa0be7df1ce9 [file] [log] [blame]
Marco Nelissen594375d2009-07-14 09:04:04 -07001#!/usr/bin/env python
2
3import sys
4import re
5
6if len(sys.argv) == 1:
7 print 'usage: ' + sys.argv[0] + ' <build.log>'
8 sys.exit()
9
10# if you add another level, don't forget to give it a color below
11class severity:
12 UNKNOWN=0
13 SKIP=100
14 FIXMENOW=1
15 HIGH=2
16 MEDIUM=3
17 LOW=4
18 HARMLESS=5
19
20def colorforseverity(sev):
21 if sev == severity.FIXMENOW:
22 return 'fuchsia'
23 if sev == severity.HIGH:
24 return 'red'
25 if sev == severity.MEDIUM:
26 return 'orange'
27 if sev == severity.LOW:
28 return 'yellow'
29 if sev == severity.HARMLESS:
30 return 'limegreen'
31 if sev == severity.UNKNOWN:
32 return 'blue'
33 return 'grey'
34
35warnpatterns = [
36 { 'category':'make', 'severity':severity.MEDIUM, 'members':[], 'option':'',
37 'description':'make: overriding commands/ignoring old commands',
38 'patterns':[r".*: warning: overriding commands for target .+",
39 r".*: warning: ignoring old commands for target .+"] },
40 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wimplicit-function-declaration',
41 'description':'Implicit function declaration',
42 'patterns':[r".*: warning: implicit declaration of function .+"] },
43 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
44 'description':'',
45 'patterns':[r".*: warning: conflicting types for '.+'"] },
46 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wtype-limits',
47 'description':'Expression always evaluates to true or false',
48 'patterns':[r".*: warning: comparison is always false due to limited range of data type",
49 r".*: warning: comparison of unsigned expression >= 0 is always true",
50 r".*: warning: comparison of unsigned expression < 0 is always false"] },
51 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
52 'description':'Incompatible pointer types',
53 'patterns':[r".*: warning: assignment from incompatible pointer type",
54 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
55 r".*: warning: initialization from incompatible pointer type"] },
56 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-fno-builtin',
57 'description':'Incompatible declaration of built in function',
58 'patterns':[r".*: warning: incompatible implicit declaration of built-in function .+"] },
59 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused-parameter',
60 'description':'Unused parameter',
61 'patterns':[r".*: warning: unused parameter '.*'"] },
62 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused',
63 'description':'Unused function, variable or label',
64 'patterns':[r".*: warning: '.+' defined but not used"] },
65 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused-value',
66 'description':'Statement with no effect',
67 'patterns':[r".*: warning: statement with no effect"] },
68 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-field-initializers',
69 'description':'Missing initializer',
70 'patterns':[r".*: warning: missing initializer"] },
71 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
72 'description':'',
73 'patterns':[r".*: warning: \(near initialization for '.+'\)"] },
74 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wformat',
75 'description':'Format string does not match arguments',
76 'patterns':[r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'"] },
77 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wformat-extra-args',
78 'description':'Too many arguments for format string',
79 'patterns':[r".*: warning: too many arguments for format"] },
80 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wsign-compare',
81 'description':'Comparison between signed and unsigned',
82 'patterns':[r".*: warning: comparison between signed and unsigned",
83 r".*: warning: comparison of promoted \~unsigned with unsigned",
84 r".*: warning: signed and unsigned type in conditional expression"] },
85 { 'category':'libpng', 'severity':severity.MEDIUM, 'members':[], 'option':'',
86 'description':'libpng: zero area',
87 'patterns':[r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"] },
88 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
89 'description':'aapt: no comment for public symbol',
90 'patterns':[r".*: warning: No comment for public symbol .+"] },
91 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-braces',
92 'description':'Missing braces around initializer',
93 'patterns':[r".*: warning: missing braces around initializer.*"] },
94 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
95 'description':'No newline at end of file',
96 'patterns':[r".*: warning: no newline at end of file"] },
97 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wcast-qual',
98 'description':'Qualifier discarded',
99 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
100 r".*: warning: assignment discards qualifiers from pointer target type",
101 r".*: warning: return discards qualifiers from pointer target type"] },
102 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wattributes',
103 'description':'Attribute ignored',
104 'patterns':[r".*: warning: '_*packed_*' attribute ignored"] },
105 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wattributes',
106 'description':'Visibility mismatch',
107 'patterns':[r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"] },
108 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
109 'description':'Shift count greater than width of type',
110 'patterns':[r".*: warning: (left|right) shift count >= width of type"] },
111 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
112 'description':'extern &lt;foo&gt; is initialized',
113 'patterns':[r".*: warning: '.+' initialized and declared 'extern'"] },
114 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wold-style-declaration',
115 'description':'Old style declaration',
116 'patterns':[r".*: warning: 'static' is not at beginning of declaration"] },
117 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wuninitialized',
118 'description':'Variable may be used uninitialized',
119 'patterns':[r".*: warning: '.+' may be used uninitialized in this function"] },
120 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wuninitialized',
121 'description':'Variable is used uninitialized',
122 'patterns':[r".*: warning: '.+' is used uninitialized in this function"] },
123 { 'category':'ld', 'severity':severity.MEDIUM, 'members':[], 'option':'-fshort-enums',
124 'description':'ld: possible enum size mismatch',
125 'patterns':[r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"] },
126 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wpointer-sign',
127 'description':'Pointer targets differ in signedness',
128 'patterns':[r".*: warning: pointer targets in initialization differ in signedness",
129 r".*: warning: pointer targets in assignment differ in signedness",
130 r".*: warning: pointer targets in return differ in signedness",
131 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"] },
132 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wstrict-overflow',
133 'description':'Assuming overflow does not occur',
134 'patterns':[r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"] },
135 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wempty-body',
136 'description':'Suggest adding braces around empty body',
137 'patterns':[r".*: warning: suggest braces around empty body in an 'if' statement",
138 r".*: warning: empty body in an if-statement",
139 r".*: warning: suggest braces around empty body in an 'else' statement",
140 r".*: warning: empty body in an else-statement"] },
141 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wparentheses',
142 'description':'Suggest adding parentheses',
143 'patterns':[r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
144 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
145 r".*: warning: suggest parentheses around comparison in operand of '.+'",
146 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
147 r".*: warning: suggest parentheses around assignment used as truth value"] },
148 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
149 'description':'Static variable used in non-static inline function',
150 'patterns':[r".*: warning: '.+' is static but used in inline function '.+' which is not static"] },
151 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wimplicit int',
152 'description':'No type or storage class (will default to int)',
153 'patterns':[r".*: warning: data definition has no type or storage class"] },
154 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
155 'description':'',
156 'patterns':[r".*: warning: type defaults to 'int' in declaration of '.+'"] },
157 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
158 'description':'',
159 'patterns':[r".*: warning: parameter names \(without types\) in function declaration"] },
160 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wstrict-aliasing',
161 'description':'Dereferencing &lt;foo&gt; breaks strict aliasing rules',
162 'patterns':[r".*: warning: dereferencing .* break strict-aliasing rules"] },
163 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wpointer-to-int-cast',
164 'description':'Cast from pointer to integer of different size',
165 'patterns':[r".*: warning: cast from pointer to integer of different size"] },
166 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wint-to-pointer-cast',
167 'description':'Cast to pointer from integer of different size',
168 'patterns':[r".*: warning: cast to pointer from integer of different size"] },
169 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
170 'description':'Symbol redefined',
171 'patterns':[r".*: warning: "".+"" redefined"] },
172 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
173 'description':'',
174 'patterns':[r".*: warning: this is the location of the previous definition"] },
175 { 'category':'ld', 'severity':severity.MEDIUM, 'members':[], 'option':'',
176 'description':'ld: type and size of dynamic symbol are not defined',
177 'patterns':[r".*: warning: type and size of dynamic symbol `.+' are not defined"] },
178 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
179 'description':'Pointer from integer without cast',
180 'patterns':[r".*: warning: assignment makes pointer from integer without a cast"] },
181 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
182 'description':'Pointer from integer without cast',
183 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"] },
184 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
185 'description':'Integer from pointer without cast',
186 'patterns':[r".*: warning: assignment makes integer from pointer without a cast"] },
187 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
188 'description':'Integer from pointer without cast',
189 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"] },
190 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
191 'description':'Integer from pointer without cast',
192 'patterns':[r".*: warning: return makes integer from pointer without a cast"] },
193 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunknown-pragmas',
194 'description':'Ignoring pragma',
195 'patterns':[r".*: warning: ignoring #pragma .+"] },
196 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wclobbered',
197 'description':'Variable might be clobbered by longjmp or vfork',
198 'patterns':[r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"] },
199 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wclobbered',
200 'description':'Argument might be clobbered by longjmp or vfork',
201 'patterns':[r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"] },
202 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wredundant-decls',
203 'description':'Redundant declaration',
204 'patterns':[r".*: warning: redundant redeclaration of '.+'"] },
205 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
206 'description':'',
207 'patterns':[r".*: warning: previous declaration of '.+' was here"] },
208 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wswitch-enum',
209 'description':'Enum value not handled in switch',
210 'patterns':[r".*: warning: enumeration value '.+' not handled in switch"] },
211 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'-encoding',
212 'description':'Java: Non-ascii characters used, but ascii encoding specified',
213 'patterns':[r".*: warning: unmappable character for encoding ascii"] },
214 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
215 'description':'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
216 'patterns':[r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"] },
217 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
218 'description':'aapt: String marked untranslatable, but translation exists',
219 'patterns':[r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"] },
220 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
221 'description':'aapt: empty span in string',
222 'patterns':[r".*: warning: empty '.+' span found in text '.+"] },
223 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
224 'description':'Taking address of temporary',
225 'patterns':[r".*: warning: taking address of temporary"] },
226 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
227 'description':'Possible broken line continuation',
228 'patterns':[r".*: warning: backslash and newline separated by space"] },
229 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Warray-bounds',
230 'description':'Array subscript out of bounds',
231 'patterns':[r".*: warning: array subscript is above array bounds"] },
232 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
233 'description':'Decimal constant is unsigned only in ISO C90',
234 'patterns':[r".*: warning: this decimal constant is unsigned only in ISO C90"] },
235 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmain',
236 'description':'main is usually a function',
237 'patterns':[r".*: warning: 'main' is usually a function"] },
238 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
239 'description':'Typedef ignored',
240 'patterns':[r".*: warning: 'typedef' was ignored in this declaration"] },
241 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Waddress',
242 'description':'Address always evaluates to true',
243 'patterns':[r".*: warning: the address of '.+' will always evaluate as 'true'"] },
244 { 'category':'C/C++', 'severity':severity.FIXMENOW, 'members':[], 'option':'',
245 'description':'Freeing a non-heap object',
246 'patterns':[r".*: warning: attempt to free a non-heap object '.+'"] },
247 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wchar-subscripts',
248 'description':'Array subscript has type char',
249 'patterns':[r".*: warning: array subscript has type 'char'"] },
250 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
251 'description':'Constant too large for type',
252 'patterns':[r".*: warning: integer constant is too large for '.+' type"] },
253 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Woverflow',
254 'description':'Constant too large for type, truncated',
255 'patterns':[r".*: warning: large integer implicitly truncated to unsigned type"] },
256 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Woverflow',
257 'description':'Overflow in implicit constant conversion',
258 'patterns':[r".*: warning: overflow in implicit constant conversion"] },
259 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
260 'description':'Declaration does not declare anything',
261 'patterns':[r".*: warning: declaration 'class .+' does not declare anything"] },
262 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wreorder',
263 'description':'Initialization order will be different',
264 'patterns':[r".*: warning: '.+' will be initialized after"] },
265 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
266 'description':'',
267 'patterns':[r".*: warning: '.+'"] },
268 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
269 'description':'',
270 'patterns':[r".*: warning: when initialized here"] },
271 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-parameter-type',
272 'description':'Parameter type not specified',
273 'patterns':[r".*: warning: type of '.+' defaults to 'int'"] },
274 { 'category':'gcc', 'severity':severity.MEDIUM, 'members':[], 'option':'',
275 'description':'Invalid option for C file',
276 'patterns':[r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"] },
277 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
278 'description':'User warning',
279 'patterns':[r".*: warning: #warning "".+"""] },
280 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wextra',
281 'description':'Dereferencing void*',
282 'patterns':[r".*: warning: dereferencing 'void \*' pointer"] },
283 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wextra',
284 'description':'Comparison of pointer to zero',
285 'patterns':[r".*: warning: ordered comparison of pointer with integer zero"] },
286 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wwrite-strings',
287 'description':'Conversion of string constant to non-const char*',
288 'patterns':[r".*: warning: deprecated conversion from string constant to '.+'"] },
289 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wstrict-prototypes',
290 'description':'Function declaration isn''t a prototype',
291 'patterns':[r".*: warning: function declaration isn't a prototype"] },
292 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wignored-qualifiers',
293 'description':'Type qualifiers ignored on function return value',
294 'patterns':[r".*: warning: type qualifiers ignored on function return type"] },
295 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
296 'description':'&lt;foo&gt; declared inside parameter list, scope limited to this definition',
297 'patterns':[r".*: warning: '.+' declared inside parameter list"] },
298 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
299 'description':'',
300 'patterns':[r".*: warning: its scope is only this definition or declaration, which is probably not what you want"] },
301 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wcomment',
302 'description':'Line continuation inside comment',
303 'patterns':[r".*: warning: multi-line comment"] },
304 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
305 'description':'Extra tokens after #endif',
306 'patterns':[r".*: warning: extra tokens at end of #endif directive"] },
307 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wenum-compare',
308 'description':'Comparison between different enums',
309 'patterns':[r".*: warning: comparison between 'enum .+' and 'enum .+'"] },
310 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wconversion',
311 'description':'Implicit conversion of negative number to unsigned type',
312 'patterns':[r".*: warning: converting negative value '.+' to '.+'"] },
313 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
314 'description':'Passing NULL as non-pointer argument',
Marco Nelissen5236fbd2009-07-31 08:30:34 -0700315 'patterns':[r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700316 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wctor-dtor-privacy',
317 'description':'Class seems unusable because of private ctor/dtor' ,
318 'patterns':[r".*: warning: all member functions in class '.+' are private"] },
319 # skip this next one, because it only points out some RefBase-based classes where having a private destructor is perfectly fine
320 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'-Wctor-dtor-privacy',
321 'description':'Class seems unusable because of private ctor/dtor' ,
322 'patterns':[r".*: warning: 'class .+' only defines a private destructor and has no friends"] },
323 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wctor-dtor-privacy',
324 'description':'Class seems unusable because of private ctor/dtor' ,
325 'patterns':[r".*: warning: 'class .+' only defines private constructors and has no friends"] },
326 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wpointer-arith',
327 'description':'void* used in arithmetic' ,
328 'patterns':[r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
329 r".*: warning: wrong type argument to increment"] },
330 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wsign-promo',
331 'description':'Overload resolution chose to promote from unsigned or enum to signed type' ,
332 'patterns':[r".*: warning: passing '.+' chooses 'int' over '.* int'"] },
333 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
334 'description':'',
335 'patterns':[r".*: warning: in call to '.+'"] },
Marco Nelissen5236fbd2009-07-31 08:30:34 -0700336 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wextra',
337 'description':'Base should be explicitly initialized in copy constructor',
338 'patterns':[r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"] },
339 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
340 'description':'Converting from <type> to <other type>',
341 'patterns':[r".*: warning: converting to '.+' from '.+'"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700342
343 # these next ones are to deal with formatting problems resulting from the log being mixed up by 'make -j'
344 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
345 'description':'',
346 'patterns':[r".*: warning: ,$"] },
347 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
348 'description':'',
349 'patterns':[r".*: warning: $"] },
350 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
351 'description':'',
352 'patterns':[r".*: warning: In file included from .+,"] },
353
354 # catch-all for warnings this script doesn't know about yet
355 { 'category':'C/C++', 'severity':severity.UNKNOWN, 'members':[], 'option':'',
356 'description':'Unclassified/unrecognized warnings',
357 'patterns':[r".*: warning: .+"] },
358]
359
360anchor = 0
361cur_row_color = 0
362row_colors = [ 'e0e0e0', 'd0d0d0' ]
363
364def output(text):
365 print text,
366
367def htmlbig(param):
368 return '<font size="+2">' + param + '</font>'
369
370def dumphtmlprologue(title):
371 output('<html>\n<head>\n<title>' + title + '</title>\n<body>\n')
372 output(htmlbig(title))
373 output('<p>\n')
374
375def tablerow(text):
376 global cur_row_color
377 output('<tr bgcolor="' + row_colors[cur_row_color] + '"><td colspan="2">',)
378 cur_row_color = 1 - cur_row_color
379 output(text,)
380 output('</td></tr>')
381
382def begintable(text, backgroundcolor):
383 global anchor
384 output('<table border="1" rules="cols" frame="box" width="100%" bgcolor="black"><tr bgcolor="' +
385 backgroundcolor + '"><a name="anchor' + str(anchor) + '"><td>')
386 output(htmlbig(text[0]) + '<br>')
387 for i in text[1:]:
388 output(i + '<br>')
389 output('</td>')
390 output('<td width="100" bgcolor="grey"><a align="right" href="#anchor' + str(anchor-1) +
391 '">previous</a><br><a align="right" href="#anchor' + str(anchor+1) + '">next</a>')
392 output('</td></a></tr>')
393 anchor += 1
394
395def endtable():
396 output('</table><p>')
397
398
399# dump some stats about total number of warnings and such
400def dumpstats():
401 known = 0
402 unknown = 0
403 for i in warnpatterns:
404 if i['severity'] == severity.UNKNOWN:
405 unknown += len(i['members'])
406 elif i['severity'] != severity.SKIP:
407 known += len(i['members'])
408 output('Number of classified warnings: <b>' + str(known) + '</b><br>' )
409 output('Number of unclassified warnings: <b>' + str(unknown) + '</b><br>')
410 total = unknown + known
411 output('Total number of warnings: <b>' + str(total) + '</b>')
412 if total < 1000:
413 output('(low count may indicate incremental build)')
414 output('<p>')
415
416def allpatterns(cat):
417 pats = ''
418 for i in cat['patterns']:
419 pats += i
420 pats += ' / '
421 return pats
422
423def descriptionfor(cat):
424 if cat['description'] != '':
425 return cat['description']
426 return allpatterns(cat)
427
428
429# show which warnings no longer occur
430def dumpfixed():
431 tablestarted = False
432 for i in warnpatterns:
433 if len(i['members']) == 0 and i['severity'] != severity.SKIP:
434 if tablestarted == False:
435 tablestarted = True
436 begintable(['Fixed warnings', 'No more occurences. Please consider turning these in to errors if possible, before they are reintroduced in to the build'], 'blue')
437 tablerow(i['description'] + ' (' + allpatterns(i) + ') ' + i['option'])
438 if tablestarted:
439 endtable()
440
441
442# dump a category, provided it is not marked as 'SKIP' and has more than 0 occurrences
443def dumpcategory(cat):
444 if cat['severity'] != severity.SKIP and len(cat['members']) != 0:
445 header = [descriptionfor(cat),str(len(cat['members'])) + ' occurences:']
446 if cat['option'] != '':
447 header[1:1] = [' (related option: ' + cat['option'] +')']
448 begintable(header, colorforseverity(cat['severity']))
449 for i in cat['members']:
450 tablerow(i)
451 endtable()
452
453
454# dump everything for a given severity
455def dumpseverity(sev):
456 for i in warnpatterns:
457 if i['severity'] == sev:
458 dumpcategory(i)
459
460
461def classifywarning(line):
462 for i in warnpatterns:
Marco Nelissen2bdc7ec2009-09-29 10:19:29 -0700463 for cpat in i['compiledpatterns']:
464 if cpat.match(line):
Marco Nelissen594375d2009-07-14 09:04:04 -0700465 i['members'].append(line)
466 return
467 else:
468 # If we end up here, there was a problem parsing the log
469 # probably caused by 'make -j' mixing the output from
470 # 2 or more concurrent compiles
471 pass
472
Marco Nelissen2bdc7ec2009-09-29 10:19:29 -0700473# precompiling every pattern speeds up parsing by about 30x
474def compilepatterns():
475 for i in warnpatterns:
476 i['compiledpatterns'] = []
477 for pat in i['patterns']:
478 i['compiledpatterns'].append(re.compile(pat))
Marco Nelissen594375d2009-07-14 09:04:04 -0700479
480infile = open(sys.argv[1], 'r')
481warnings = []
482
483platformversion = 'unknown'
484targetproduct = 'unknown'
485targetvariant = 'unknown'
486linecounter = 0
487
488warningpattern = re.compile('.* warning:.*')
Marco Nelissen2bdc7ec2009-09-29 10:19:29 -0700489compilepatterns()
Marco Nelissen594375d2009-07-14 09:04:04 -0700490
491# read the log file and classify all the warnings
492lastmatchedline = ''
493for line in infile:
494 if warningpattern.match(line):
495 if line != lastmatchedline:
496 classifywarning(line)
497 lastmatchedline = line
498 else:
499 # save a little bit of time by only doing this for the first few lines
500 if linecounter < 50:
501 linecounter +=1
502 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
503 if m != None:
504 platformversion = m.group(0)
505 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
506 if m != None:
507 targetproduct = m.group(0)
508 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
509 if m != None:
510 targetvariant = m.group(0)
511
512
513# dump the html output to stdout
514dumphtmlprologue('Warnings for ' + platformversion + ' - ' + targetproduct + ' - ' + targetvariant)
515dumpstats()
516dumpseverity(severity.FIXMENOW)
517dumpseverity(severity.HIGH)
518dumpseverity(severity.MEDIUM)
519dumpseverity(severity.LOW)
520dumpseverity(severity.HARMLESS)
521dumpseverity(severity.UNKNOWN)
522dumpfixed()
523