blob: d4b2f57c1070b4bfa155b662a428e635c7f63ea2 [file] [log] [blame]
Marco Nelissen594375d2009-07-14 09:04:04 -07001#!/usr/bin/env python
Marco Nelissen8e201962010-03-10 16:16:02 -08002# This file uses the following encoding: utf-8
Marco Nelissen594375d2009-07-14 09:04:04 -07003
4import sys
5import re
6
7if len(sys.argv) == 1:
8 print 'usage: ' + sys.argv[0] + ' <build.log>'
9 sys.exit()
10
11# if you add another level, don't forget to give it a color below
12class severity:
13 UNKNOWN=0
14 SKIP=100
15 FIXMENOW=1
16 HIGH=2
17 MEDIUM=3
18 LOW=4
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -070019 TIDY=5
20 HARMLESS=6
Marco Nelissen594375d2009-07-14 09:04:04 -070021
22def colorforseverity(sev):
23 if sev == severity.FIXMENOW:
24 return 'fuchsia'
25 if sev == severity.HIGH:
26 return 'red'
27 if sev == severity.MEDIUM:
28 return 'orange'
29 if sev == severity.LOW:
30 return 'yellow'
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -070031 if sev == severity.TIDY:
32 return 'peachpuff'
Marco Nelissen594375d2009-07-14 09:04:04 -070033 if sev == severity.HARMLESS:
34 return 'limegreen'
35 if sev == severity.UNKNOWN:
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -070036 return 'lightblue'
Marco Nelissen594375d2009-07-14 09:04:04 -070037 return 'grey'
38
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -070039def headerforseverity(sev):
40 if sev == severity.FIXMENOW:
41 return 'Critical warnings, fix me now'
42 if sev == severity.HIGH:
43 return 'High severity warnings'
44 if sev == severity.MEDIUM:
45 return 'Medium severity warnings'
46 if sev == severity.LOW:
47 return 'Low severity warnings'
48 if sev == severity.HARMLESS:
49 return 'Harmless warnings'
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -070050 if sev == severity.TIDY:
51 return 'Clang-Tidy warnings'
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -070052 if sev == severity.UNKNOWN:
53 return 'Unknown warnings'
54 return 'Unhandled warnings'
55
Marco Nelissen594375d2009-07-14 09:04:04 -070056warnpatterns = [
57 { 'category':'make', 'severity':severity.MEDIUM, 'members':[], 'option':'',
58 'description':'make: overriding commands/ignoring old commands',
59 'patterns':[r".*: warning: overriding commands for target .+",
60 r".*: warning: ignoring old commands for target .+"] },
61 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wimplicit-function-declaration',
62 'description':'Implicit function declaration',
63 'patterns':[r".*: warning: implicit declaration of function .+"] },
64 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
65 'description':'',
66 'patterns':[r".*: warning: conflicting types for '.+'"] },
67 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wtype-limits',
68 'description':'Expression always evaluates to true or false',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -070069 'patterns':[r".*: warning: comparison is always .+ due to limited range of data type",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -070070 r".*: warning: comparison of unsigned .*expression .+ is always true",
71 r".*: warning: comparison of unsigned .*expression .+ is always false"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -070072 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'',
73 'description':'Potential leak of memory, bad free, use after free',
74 'patterns':[r".*: warning: Potential leak of memory",
75 r".*: warning: Potential memory leak",
76 r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
77 r".*: warning: 'delete' applied to a pointer that was allocated",
78 r".*: warning: Use of memory after it is freed",
79 r".*: warning: Argument to .+ is the address of .+ variable",
80 r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
81 r".*: warning: Attempt to .+ released memory"] },
82 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'',
83 'description':'Return address of stack memory',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -070084 'patterns':[r".*: warning: Address of stack memory .+ returned to caller",
85 r".*: warning: Address of stack memory .+ will be a dangling reference"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -070086 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'',
87 'description':'Problem with vfork',
88 'patterns':[r".*: warning: This .+ is prohibited after a successful vfork",
89 r".*: warning: Call to function 'vfork' is insecure "] },
90 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'infinite-recursion',
91 'description':'Infinite recursion',
92 'patterns':[r".*: warning: all paths through this function will call itself"] },
93 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'',
94 'description':'Potential buffer overflow',
95 'patterns':[r".*: warning: Size argument is greater than .+ the destination buffer",
96 r".*: warning: Potential buffer overflow.",
97 r".*: warning: String copy function overflows destination buffer"] },
Marco Nelissen594375d2009-07-14 09:04:04 -070098 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
99 'description':'Incompatible pointer types',
100 'patterns':[r".*: warning: assignment from incompatible pointer type",
Marco Nelissen8e201962010-03-10 16:16:02 -0800101 r".*: warning: return from incompatible pointer type",
Marco Nelissen594375d2009-07-14 09:04:04 -0700102 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
103 r".*: warning: initialization from incompatible pointer type"] },
104 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-fno-builtin',
105 'description':'Incompatible declaration of built in function',
106 'patterns':[r".*: warning: incompatible implicit declaration of built-in function .+"] },
107 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused-parameter',
108 'description':'Unused parameter',
109 'patterns':[r".*: warning: unused parameter '.*'"] },
110 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused',
111 'description':'Unused function, variable or label',
Marco Nelissen8e201962010-03-10 16:16:02 -0800112 'patterns':[r".*: warning: '.+' defined but not used",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700113 r".*: warning: unused function '.+'",
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700114 r".*: warning: private field '.+' is not used",
Marco Nelissen8e201962010-03-10 16:16:02 -0800115 r".*: warning: unused variable '.+'"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700116 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused-value',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700117 'description':'Statement with no effect or result unused',
118 'patterns':[r".*: warning: statement with no effect",
119 r".*: warning: expression result unused"] },
120 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunused-result',
121 'description':'Ignoreing return value of function',
122 'patterns':[r".*: warning: ignoring return value of function .+Wunused-result"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700123 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-field-initializers',
124 'description':'Missing initializer',
125 'patterns':[r".*: warning: missing initializer"] },
126 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
127 'description':'',
128 'patterns':[r".*: warning: \(near initialization for '.+'\)"] },
129 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wformat',
130 'description':'Format string does not match arguments',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700131 'patterns':[r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
132 r".*: warning: more '%' conversions than data arguments",
133 r".*: warning: data argument not used by format string",
134 r".*: warning: incomplete format specifier",
135 r".*: warning: format .+ expects .+ but argument .+Wformat=",
136 r".*: warning: field precision should have .+ but argument has .+Wformat",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700137 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700138 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wformat-extra-args',
139 'description':'Too many arguments for format string',
140 'patterns':[r".*: warning: too many arguments for format"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700141 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wformat-invalid-specifier',
142 'description':'Invalid format specifier',
143 'patterns':[r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700144 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wsign-compare',
145 'description':'Comparison between signed and unsigned',
146 'patterns':[r".*: warning: comparison between signed and unsigned",
147 r".*: warning: comparison of promoted \~unsigned with unsigned",
148 r".*: warning: signed and unsigned type in conditional expression"] },
Marco Nelissen8e201962010-03-10 16:16:02 -0800149 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
150 'description':'Comparison between enum and non-enum',
151 'patterns':[r".*: warning: enumeral and non-enumeral type in conditional expression"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700152 { 'category':'libpng', 'severity':severity.MEDIUM, 'members':[], 'option':'',
153 'description':'libpng: zero area',
154 'patterns':[r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"] },
155 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
156 'description':'aapt: no comment for public symbol',
157 'patterns':[r".*: warning: No comment for public symbol .+"] },
158 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-braces',
159 'description':'Missing braces around initializer',
160 'patterns':[r".*: warning: missing braces around initializer.*"] },
161 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
162 'description':'No newline at end of file',
163 'patterns':[r".*: warning: no newline at end of file"] },
164 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wcast-qual',
165 'description':'Qualifier discarded',
166 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
167 r".*: warning: assignment discards qualifiers from pointer target type",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700168 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
169 r".*: warning: assigning to .+ from .+ discards qualifiers",
Marco Nelissen594375d2009-07-14 09:04:04 -0700170 r".*: warning: return discards qualifiers from pointer target type"] },
171 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wattributes',
172 'description':'Attribute ignored',
173 'patterns':[r".*: warning: '_*packed_*' attribute ignored"] },
174 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wattributes',
175 'description':'Visibility mismatch',
176 'patterns':[r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"] },
177 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
178 'description':'Shift count greater than width of type',
179 'patterns':[r".*: warning: (left|right) shift count >= width of type"] },
180 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
181 'description':'extern &lt;foo&gt; is initialized',
182 'patterns':[r".*: warning: '.+' initialized and declared 'extern'"] },
183 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wold-style-declaration',
184 'description':'Old style declaration',
185 'patterns':[r".*: warning: 'static' is not at beginning of declaration"] },
186 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wuninitialized',
187 'description':'Variable may be used uninitialized',
188 'patterns':[r".*: warning: '.+' may be used uninitialized in this function"] },
189 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wuninitialized',
190 'description':'Variable is used uninitialized',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700191 'patterns':[r".*: warning: '.+' is used uninitialized in this function",
192 r".*: warning: variable '.+' is uninitialized when used here"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700193 { 'category':'ld', 'severity':severity.MEDIUM, 'members':[], 'option':'-fshort-enums',
194 'description':'ld: possible enum size mismatch',
195 'patterns':[r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"] },
196 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wpointer-sign',
197 'description':'Pointer targets differ in signedness',
198 'patterns':[r".*: warning: pointer targets in initialization differ in signedness",
199 r".*: warning: pointer targets in assignment differ in signedness",
200 r".*: warning: pointer targets in return differ in signedness",
201 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"] },
202 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wstrict-overflow',
203 'description':'Assuming overflow does not occur',
204 'patterns':[r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"] },
205 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wempty-body',
206 'description':'Suggest adding braces around empty body',
207 'patterns':[r".*: warning: suggest braces around empty body in an 'if' statement",
208 r".*: warning: empty body in an if-statement",
209 r".*: warning: suggest braces around empty body in an 'else' statement",
210 r".*: warning: empty body in an else-statement"] },
211 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wparentheses',
212 'description':'Suggest adding parentheses',
213 'patterns':[r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
214 r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
215 r".*: warning: suggest parentheses around comparison in operand of '.+'",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700216 r".*: warning: logical not is only applied to the left hand side of this comparison",
217 r".*: warning: using the result of an assignment as a condition without parentheses",
218 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
Marco Nelissen594375d2009-07-14 09:04:04 -0700219 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
220 r".*: warning: suggest parentheses around assignment used as truth value"] },
221 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
222 'description':'Static variable used in non-static inline function',
223 'patterns':[r".*: warning: '.+' is static but used in inline function '.+' which is not static"] },
224 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wimplicit int',
225 'description':'No type or storage class (will default to int)',
226 'patterns':[r".*: warning: data definition has no type or storage class"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700227 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
228 'description':'Null pointer',
229 'patterns':[r".*: warning: Dereference of null pointer",
230 r".*: warning: Called .+ pointer is null",
231 r".*: warning: Forming reference to null pointer",
232 r".*: warning: Returning null reference",
233 r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
234 r".*: warning: .+ results in a null pointer dereference",
235 r".*: warning: Access to .+ results in a dereference of a null pointer",
236 r".*: warning: Null pointer argument in"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700237 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
238 'description':'',
239 'patterns':[r".*: warning: type defaults to 'int' in declaration of '.+'"] },
240 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
241 'description':'',
242 'patterns':[r".*: warning: parameter names \(without types\) in function declaration"] },
243 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wstrict-aliasing',
244 'description':'Dereferencing &lt;foo&gt; breaks strict aliasing rules',
245 'patterns':[r".*: warning: dereferencing .* break strict-aliasing rules"] },
246 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wpointer-to-int-cast',
247 'description':'Cast from pointer to integer of different size',
248 'patterns':[r".*: warning: cast from pointer to integer of different size"] },
249 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wint-to-pointer-cast',
250 'description':'Cast to pointer from integer of different size',
251 'patterns':[r".*: warning: cast to pointer from integer of different size"] },
252 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
253 'description':'Symbol redefined',
254 'patterns':[r".*: warning: "".+"" redefined"] },
255 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
256 'description':'',
257 'patterns':[r".*: warning: this is the location of the previous definition"] },
258 { 'category':'ld', 'severity':severity.MEDIUM, 'members':[], 'option':'',
259 'description':'ld: type and size of dynamic symbol are not defined',
260 'patterns':[r".*: warning: type and size of dynamic symbol `.+' are not defined"] },
261 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
262 'description':'Pointer from integer without cast',
263 'patterns':[r".*: warning: assignment makes pointer from integer without a cast"] },
264 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
265 'description':'Pointer from integer without cast',
266 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"] },
267 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
268 'description':'Integer from pointer without cast',
269 'patterns':[r".*: warning: assignment makes integer from pointer without a cast"] },
270 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
271 'description':'Integer from pointer without cast',
272 'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"] },
273 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
274 'description':'Integer from pointer without cast',
275 'patterns':[r".*: warning: return makes integer from pointer without a cast"] },
276 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wunknown-pragmas',
277 'description':'Ignoring pragma',
278 'patterns':[r".*: warning: ignoring #pragma .+"] },
279 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wclobbered',
280 'description':'Variable might be clobbered by longjmp or vfork',
281 'patterns':[r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"] },
282 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wclobbered',
283 'description':'Argument might be clobbered by longjmp or vfork',
284 'patterns':[r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"] },
285 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wredundant-decls',
286 'description':'Redundant declaration',
287 'patterns':[r".*: warning: redundant redeclaration of '.+'"] },
288 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
289 'description':'',
290 'patterns':[r".*: warning: previous declaration of '.+' was here"] },
291 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wswitch-enum',
292 'description':'Enum value not handled in switch',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700293 'patterns':[r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700294 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'-encoding',
295 'description':'Java: Non-ascii characters used, but ascii encoding specified',
296 'patterns':[r".*: warning: unmappable character for encoding ascii"] },
297 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
298 'description':'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
299 'patterns':[r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700300 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
301 'description':'Java: Unchecked method invocation',
302 'patterns':[r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"] },
303 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
304 'description':'Java: Unchecked conversion',
305 'patterns':[r".*: warning: \[unchecked\] unchecked conversion"] },
Ian Rogers32bb9bd2016-05-09 23:19:42 -0700306
307 # Warnings from error prone.
308 { 'category':'java', 'severity':severity.LOW, 'members':[], 'option':'',
309 'description':'Java: Long literal suffix',
310 'patterns':[r".*: warning: \[LongLiteralLowerCaseSuffix\] Prefer 'L' to 'l' for the suffix to long literal"] },
311 { 'category':'java', 'severity':severity.LOW, 'members':[], 'option':'',
312 'description':'Java: Missing @Deprecated',
313 'patterns':[r".*: warning: \[DepAnn\] Deprecated item is not annotated with @Deprecated"] },
314 { 'category':'java', 'severity':severity.LOW, 'members':[], 'option':'',
315 'description':'Java: Use of deprecated member',
316 'patterns':[r".*: warning: \[deprecation\] .+ in .+ has been deprecated"] },
317 { 'category':'java', 'severity':severity.LOW, 'members':[], 'option':'',
318 'description':'Java: Missing hashCode method',
319 'patterns':[r".*: warning: \[EqualsHashCode\] Classes that override equals should also override hashCode."] },
320 { 'category':'java', 'severity':severity.LOW, 'members':[], 'option':'',
321 'description':'Java: Hashtable contains is a legacy method',
322 'patterns':[r".*: warning: \[HashtableContains\] contains\(\) is a legacy method that is equivalent to containsValue\(\)"] },
323 { 'category':'java', 'severity':severity.LOW, 'members':[], 'option':'',
324 'description':'Java: Type parameter used only for return type',
325 'patterns':[r".*: warning: \[TypeParameterUnusedInFormals\] Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution."] },
326
327 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
328 'description':'Java: reference equality used on arrays',
329 'patterns':[r".*: warning: \[ArrayEquals\] Reference equality used to compare arrays"] },
330 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
331 'description':'Java: hashcode used on array',
332 'patterns':[r".*: warning: \[ArrayHashCode\] hashcode method on array does not hash array contents"] },
333 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
334 'description':'Java: toString used on an array',
335 'patterns':[r".*: warning: \[ArrayToStringConcatenation\] Implicit toString used on an array \(String \+ Array\)",
336 r".*: warning: \[ArrayToString\] Calling toString on an array does not provide useful information"] },
337 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
338 'description':'Java: Exception created but not thrown',
339 'patterns':[r".*: warning: \[DeadException\] Exception created but not thrown"] },
340 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
341 'description':'Java: Return or throw from a finally',
342 'patterns':[r".*: warning: \[Finally\] If you return or throw from a finally, then values returned or thrown from the try-catch block will be ignored. Consider using try-with-resources instead."] },
343 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
344 'description':'Java: Erroneous use of @GuardedBy',
345 'patterns':[r".*: warning: \[GuardedByChecker\] This access should be guarded by '.+'; instead found: '.+'",
346 r".*: warning: \[GuardedByChecker\] This access should be guarded by '.+', which is not currently held"] },
347 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
348 'description':'Java: Mislabeled Android string',
349 'patterns':[r".*: warning: \[MislabeledAndroidString\] .+ is not \".+\" but \".+\"; prefer .+ for clarity"] },
350 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
351 'description':'Java: Missing cases in enum switch',
352 'patterns':[r".*: warning: \[MissingCasesInEnumSwitch\] Non-exhaustive switch, expected cases for: .+"] },
353 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
354 'description':'Java: Multiple top-level classes (inhibits bug analysis)',
355 'patterns':[r".*: warning: \[MultipleTopLevelClasses\] Expected at most one top-level class declaration, instead found: .+"] },
356 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
357 'description':'Java: equals method doesn\'t override Object.equals',
358 'patterns':[r".*: warning: \[NonOverridingEquals\] equals method doesn't override Object\.equals.*"] },
359 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
360 'description':'Java: Update of a volatile variable is non-atomic',
361 'patterns':[r".*: warning: \[NonAtomicVolatileUpdate\] This update of a volatile variable is non-atomic"] },
362 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
363 'description':'Java: Return value ignored',
364 'patterns':[r".*: warning: \[ReturnValueIgnored\] Return value of this method must be used",
365 r".*: warning: \[RectIntersectReturnValueIgnored\] Return value of android.graphics.Rect.intersect\(\) must be checked"] },
366 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
367 'description':'Java: Static variable accessed from an object instance',
368 'patterns':[r".*: warning: \[StaticAccessedFromInstance\] Static (method|variable) .+ should not be accessed from an object instance; instead use .+"] },
369 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
370 'description':'Java: Static guarded by instance',
371 'patterns':[r".*: warning: \[StaticGuardedByInstance\] Write to static variable should not be guarded by instance lock '.+'"] },
372 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
373 'description':'Java: String reference equality',
374 'patterns':[r".*: warning: \[StringEquality\] String comparison using reference equality instead of value equality"] },
375 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
376 'description':'Java: Synchronization on non-final field',
377 'patterns':[r".*: warning: \[SynchronizeOnNonFinalField\] Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects."] },
378 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
379 'description':'Java: Catch masks fail or assert',
380 'patterns':[r".*: warning: \[TryFailThrowable\] Catching Throwable/Error masks failures from fail\(\) or assert\*\(\) in the try block"] },
381 { 'category':'java', 'severity':severity.MEDIUM, 'members':[], 'option':'',
382 'description':'Java: Wait not in a loop',
383 'patterns':[r".*: warning: \[WaitNotInLoop\] Because of spurious wakeups, a?wait.*\(.*\) must always be called in a loop"] },
384
385 { 'category':'java', 'severity':severity.UNKNOWN, 'members':[], 'option':'',
386 'description':'Java: Unclassified/unrecognized warnings',
387 'patterns':[r".*: warning: \[.+\] .+"] },
388
Marco Nelissen594375d2009-07-14 09:04:04 -0700389 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Marco Nelissen8e201962010-03-10 16:16:02 -0800390 'description':'aapt: No default translation',
391 'patterns':[r".*: warning: string '.+' has no default translation in .*"] },
392 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
393 'description':'aapt: Missing default or required localization',
394 'patterns':[r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"] },
395 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Marco Nelissen594375d2009-07-14 09:04:04 -0700396 'description':'aapt: String marked untranslatable, but translation exists',
397 'patterns':[r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"] },
398 { 'category':'aapt', 'severity':severity.MEDIUM, 'members':[], 'option':'',
399 'description':'aapt: empty span in string',
400 'patterns':[r".*: warning: empty '.+' span found in text '.+"] },
401 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
402 'description':'Taking address of temporary',
403 'patterns':[r".*: warning: taking address of temporary"] },
404 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
405 'description':'Possible broken line continuation',
406 'patterns':[r".*: warning: backslash and newline separated by space"] },
407 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Warray-bounds',
408 'description':'Array subscript out of bounds',
Marco Nelissen8e201962010-03-10 16:16:02 -0800409 'patterns':[r".*: warning: array subscript is above array bounds",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700410 r".*: warning: Array subscript is undefined",
Marco Nelissen8e201962010-03-10 16:16:02 -0800411 r".*: warning: array subscript is below array bounds"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700412 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700413 'description':'Excess elements in initializer',
414 'patterns':[r".*: warning: excess elements in .+ initializer"] },
415 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Marco Nelissen594375d2009-07-14 09:04:04 -0700416 'description':'Decimal constant is unsigned only in ISO C90',
417 'patterns':[r".*: warning: this decimal constant is unsigned only in ISO C90"] },
418 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmain',
419 'description':'main is usually a function',
420 'patterns':[r".*: warning: 'main' is usually a function"] },
421 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
422 'description':'Typedef ignored',
423 'patterns':[r".*: warning: 'typedef' was ignored in this declaration"] },
424 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Waddress',
425 'description':'Address always evaluates to true',
426 'patterns':[r".*: warning: the address of '.+' will always evaluate as 'true'"] },
427 { 'category':'C/C++', 'severity':severity.FIXMENOW, 'members':[], 'option':'',
428 'description':'Freeing a non-heap object',
429 'patterns':[r".*: warning: attempt to free a non-heap object '.+'"] },
430 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wchar-subscripts',
431 'description':'Array subscript has type char',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700432 'patterns':[r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700433 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
434 'description':'Constant too large for type',
435 'patterns':[r".*: warning: integer constant is too large for '.+' type"] },
436 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Woverflow',
437 'description':'Constant too large for type, truncated',
438 'patterns':[r".*: warning: large integer implicitly truncated to unsigned type"] },
439 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Woverflow',
440 'description':'Overflow in implicit constant conversion',
441 'patterns':[r".*: warning: overflow in implicit constant conversion"] },
442 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
443 'description':'Declaration does not declare anything',
444 'patterns':[r".*: warning: declaration 'class .+' does not declare anything"] },
445 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wreorder',
446 'description':'Initialization order will be different',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700447 'patterns':[r".*: warning: '.+' will be initialized after",
448 r".*: warning: field .+ will be initialized after .+Wreorder"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700449 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
450 'description':'',
451 'patterns':[r".*: warning: '.+'"] },
452 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
453 'description':'',
Marco Nelissen8e201962010-03-10 16:16:02 -0800454 'patterns':[r".*: warning: base '.+'"] },
455 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
456 'description':'',
Marco Nelissen594375d2009-07-14 09:04:04 -0700457 'patterns':[r".*: warning: when initialized here"] },
458 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wmissing-parameter-type',
459 'description':'Parameter type not specified',
460 'patterns':[r".*: warning: type of '.+' defaults to 'int'"] },
461 { 'category':'gcc', 'severity':severity.MEDIUM, 'members':[], 'option':'',
462 'description':'Invalid option for C file',
463 'patterns':[r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"] },
464 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
465 'description':'User warning',
466 'patterns':[r".*: warning: #warning "".+"""] },
467 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wextra',
468 'description':'Dereferencing void*',
469 'patterns':[r".*: warning: dereferencing 'void \*' pointer"] },
470 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wextra',
471 'description':'Comparison of pointer to zero',
472 'patterns':[r".*: warning: ordered comparison of pointer with integer zero"] },
473 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wwrite-strings',
474 'description':'Conversion of string constant to non-const char*',
475 'patterns':[r".*: warning: deprecated conversion from string constant to '.+'"] },
476 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wstrict-prototypes',
477 'description':'Function declaration isn''t a prototype',
478 'patterns':[r".*: warning: function declaration isn't a prototype"] },
479 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wignored-qualifiers',
480 'description':'Type qualifiers ignored on function return value',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700481 'patterns':[r".*: warning: type qualifiers ignored on function return type",
482 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700483 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
484 'description':'&lt;foo&gt; declared inside parameter list, scope limited to this definition',
485 'patterns':[r".*: warning: '.+' declared inside parameter list"] },
486 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
487 'description':'',
488 'patterns':[r".*: warning: its scope is only this definition or declaration, which is probably not what you want"] },
489 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wcomment',
490 'description':'Line continuation inside comment',
491 'patterns':[r".*: warning: multi-line comment"] },
Marco Nelissen8e201962010-03-10 16:16:02 -0800492 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wcomment',
493 'description':'Comment inside comment',
494 'patterns':[r".*: warning: "".+"" within comment"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700495 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'',
496 'description':'Value stored is never read',
497 'patterns':[r".*: warning: Value stored to .+ is never read"] },
498 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wdeprecated-declarations',
499 'description':'Deprecated declarations',
500 'patterns':[r".*: warning: .+ is deprecated.+deprecated-declarations"] },
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700501 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wdeprecated-register',
502 'description':'Deprecated register',
503 'patterns':[r".*: warning: 'register' storage class specifier is deprecated"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700504 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wpointer-sign',
505 'description':'Converts between pointers to integer types with different sign',
506 'patterns':[r".*: warning: .+ converts between pointers to integer types with different sign"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700507 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
508 'description':'Extra tokens after #endif',
509 'patterns':[r".*: warning: extra tokens at end of #endif directive"] },
510 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wenum-compare',
511 'description':'Comparison between different enums',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700512 'patterns':[r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700513 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wconversion',
514 'description':'Implicit conversion of negative number to unsigned type',
515 'patterns':[r".*: warning: converting negative value '.+' to '.+'"] },
516 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
517 'description':'Passing NULL as non-pointer argument',
Marco Nelissen5236fbd2009-07-31 08:30:34 -0700518 'patterns':[r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700519 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wctor-dtor-privacy',
520 'description':'Class seems unusable because of private ctor/dtor' ,
521 'patterns':[r".*: warning: all member functions in class '.+' are private"] },
522 # skip this next one, because it only points out some RefBase-based classes where having a private destructor is perfectly fine
523 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'-Wctor-dtor-privacy',
524 'description':'Class seems unusable because of private ctor/dtor' ,
525 'patterns':[r".*: warning: 'class .+' only defines a private destructor and has no friends"] },
526 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wctor-dtor-privacy',
527 'description':'Class seems unusable because of private ctor/dtor' ,
528 'patterns':[r".*: warning: 'class .+' only defines private constructors and has no friends"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700529 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wgnu-static-float-init',
530 'description':'In-class initializer for static const float/double' ,
531 'patterns':[r".*: warning: in-class initializer for static data member of .+const (float|double)"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700532 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wpointer-arith',
533 'description':'void* used in arithmetic' ,
534 'patterns':[r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700535 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
Marco Nelissen594375d2009-07-14 09:04:04 -0700536 r".*: warning: wrong type argument to increment"] },
537 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'-Wsign-promo',
538 'description':'Overload resolution chose to promote from unsigned or enum to signed type' ,
539 'patterns':[r".*: warning: passing '.+' chooses 'int' over '.* int'"] },
540 { 'category':'cont.', 'severity':severity.SKIP, 'members':[], 'option':'',
541 'description':'',
542 'patterns':[r".*: warning: in call to '.+'"] },
Marco Nelissen5236fbd2009-07-31 08:30:34 -0700543 { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wextra',
544 'description':'Base should be explicitly initialized in copy constructor',
545 'patterns':[r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"] },
546 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
547 'description':'Converting from <type> to <other type>',
548 'patterns':[r".*: warning: converting to '.+' from '.+'"] },
Marco Nelissen8e201962010-03-10 16:16:02 -0800549 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700550 'description':'VLA has zero or negative size',
551 'patterns':[r".*: warning: Declared variable-length array \(VLA\) has .+ size"] },
552 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
Marco Nelissen8e201962010-03-10 16:16:02 -0800553 'description':'Return value from void function',
554 'patterns':[r".*: warning: 'return' with a value, in function returning void"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700555 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'multichar',
556 'description':'Multi-character character constant',
557 'patterns':[r".*: warning: multi-character character constant"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700558 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'writable-strings',
559 'description':'Conversion from string literal to char*',
560 'patterns':[r".*: warning: .+ does not allow conversion from string literal to 'char \*'"] },
Marco Nelissen8e201962010-03-10 16:16:02 -0800561 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'',
562 'description':'Useless specifier',
563 'patterns':[r".*: warning: useless storage class specifier in empty declaration"] },
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700564 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Wduplicate-decl-specifier',
565 'description':'Duplicate declaration specifier',
566 'patterns':[r".*: warning: duplicate '.+' declaration specifier"] },
Marco Nelissen8e201962010-03-10 16:16:02 -0800567 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'',
568 'description':'Duplicate logtag',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700569 'patterns':[r".*: warning: tag \".+\" \(.+\) duplicated in .+"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700570 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'typedef-redefinition',
571 'description':'Typedef redefinition',
572 'patterns':[r".*: warning: redefinition of typedef '.+' is a C11 feature"] },
573 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'gnu-designator',
574 'description':'GNU old-style field designator',
575 'patterns':[r".*: warning: use of GNU old-style field designator extension"] },
576 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'missing-field-initializers',
577 'description':'Missing field initializers',
578 'patterns':[r".*: warning: missing field '.+' initializer"] },
579 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'missing-braces',
580 'description':'Missing braces',
581 'patterns':[r".*: warning: suggest braces around initialization of",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700582 r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700583 r".*: warning: braces around scalar initializer"] },
584 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'sign-compare',
585 'description':'Comparison of integers of different signs',
586 'patterns':[r".*: warning: comparison of integers of different signs.+sign-compare"] },
587 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'dangling-else',
588 'description':'Add braces to avoid dangling else',
589 'patterns':[r".*: warning: add explicit braces to avoid dangling else"] },
590 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'initializer-overrides',
591 'description':'Initializer overrides prior initialization',
592 'patterns':[r".*: warning: initializer overrides prior initialization of this subobject"] },
593 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'self-assign',
594 'description':'Assigning value to self',
595 'patterns':[r".*: warning: explicitly assigning value of .+ to itself"] },
596 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'gnu-variable-sized-type-not-at-end',
597 'description':'GNU extension, variable sized type not at end',
598 'patterns':[r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"] },
599 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'tautological-constant-out-of-range-compare',
600 'description':'Comparison of constant is always false/true',
601 'patterns':[r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"] },
602 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'overloaded-virtual',
603 'description':'Hides overloaded virtual function',
604 'patterns':[r".*: '.+' hides overloaded virtual function"] },
605 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'incompatible-pointer-types',
606 'description':'Incompatible pointer types',
607 'patterns':[r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"] },
608 { 'category':'logtags', 'severity':severity.LOW, 'members':[], 'option':'asm-operand-widths',
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700609 'description':'ASM value size does not match register size',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700610 'patterns':[r".*: warning: value size does not match register size specified by the constraint and modifier"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700611 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'literal-suffix',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700612 'description':'Needs a space between literal and string macro',
613 'patterns':[r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700614 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'#warnings',
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700615 'description':'Warnings from #warning',
616 'patterns':[r".*: warning: .+-W#warnings"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700617 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'absolute-value',
618 'description':'Using float/int absolute value function with int/float argument',
619 'patterns':[r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value"] },
620 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'',
621 'description':'Refers to implicitly defined namespace',
622 'patterns':[r".*: warning: using directive refers to implicitly-defined namespace .+"] },
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700623 { 'category':'C/C++', 'severity':severity.LOW, 'members':[], 'option':'-Winvalid-pp-token',
624 'description':'Invalid pp token',
625 'patterns':[r".*: warning: missing .+Winvalid-pp-token"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700626
Marco Nelissen8e201962010-03-10 16:16:02 -0800627 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
628 'description':'Operator new returns NULL',
629 'patterns':[r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"] },
630 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
631 'description':'NULL used in arithmetic',
632 'patterns':[r".*: warning: NULL used in arithmetic"] },
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700633 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'header-guard',
634 'description':'Misspelled header guard',
635 'patterns':[r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"] },
636 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'empty-body',
637 'description':'Empty loop body',
638 'patterns':[r".*: warning: .+ loop has empty body"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700639 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'enum-conversion',
640 'description':'Implicit conversion from enumeration type',
641 'patterns':[r".*: warning: implicit conversion from enumeration type '.+'"] },
642 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'switch',
643 'description':'case value not in enumerated type',
644 'patterns':[r".*: warning: case value not in enumerated type '.+'"] },
645 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
646 'description':'Undefined result',
647 'patterns':[r".*: warning: The result of .+ is undefined",
648 r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
649 r".*: warning: shifting a negative signed value is undefined"] },
650 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
651 'description':'Division by zero',
652 'patterns':[r".*: warning: Division by zero"] },
Marco Nelissen8e201962010-03-10 16:16:02 -0800653 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
654 'description':'Use of deprecated method',
655 'patterns':[r".*: warning: '.+' is deprecated .+"] },
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700656 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
657 'description':'Use of garbage or uninitialized value',
658 'patterns':[r".*: warning: .+ is a garbage value",
659 r".*: warning: Function call argument is an uninitialized value",
660 r".*: warning: Undefined or garbage value returned to caller",
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700661 r".*: warning: Called .+ pointer is.+uninitialized",
662 r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message
663 r".*: warning: Use of zero-allocated memory",
Chih-Hung Hsiehf8aaf602016-03-16 12:18:16 -0700664 r".*: warning: Dereference of undefined pointer value",
665 r".*: warning: Passed-by-value .+ contains uninitialized data",
666 r".*: warning: Branch condition evaluates to a garbage value",
667 r".*: warning: The .+ of .+ is an uninitialized value.",
668 r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
669 r".*: warning: Assigned value is garbage or undefined"] },
670 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
671 'description':'Result of malloc type incompatible with sizeof operand type',
672 'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
673 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
674 'description':'Return value not checked',
675 'patterns':[r".*: warning: The return value from .+ is not checked"] },
676 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
677 'description':'Possible heap pollution',
678 'patterns':[r".*: warning: .*Possible heap pollution from .+ type .+"] },
679 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
680 'description':'Allocation size of 0 byte',
681 'patterns':[r".*: warning: Call to .+ has an allocation size of 0 byte"] },
682 { 'category':'C/C++', 'severity':severity.MEDIUM, 'members':[], 'option':'',
683 'description':'Result of malloc type incompatible with sizeof operand type',
684 'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
685
686 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
687 'description':'Discarded qualifier from pointer target type',
688 'patterns':[r".*: warning: .+ discards '.+' qualifier from pointer target type"] },
689 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
690 'description':'Use snprintf instead of sprintf',
691 'patterns':[r".*: warning: .*sprintf is often misused; please use snprintf"] },
692 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
693 'description':'Unsupported optimizaton flag',
694 'patterns':[r".*: warning: optimization flag '.+' is not supported"] },
695 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'',
696 'description':'Extra or missing parentheses',
697 'patterns':[r".*: warning: equality comparison with extraneous parentheses",
698 r".*: warning: .+ within .+Wlogical-op-parentheses"] },
699 { 'category':'C/C++', 'severity':severity.HARMLESS, 'members':[], 'option':'mismatched-tags',
700 'description':'Mismatched class vs struct tags',
701 'patterns':[r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
702 r".*: warning: .+ was previously declared as a .+mismatched-tags"] },
Marco Nelissen594375d2009-07-14 09:04:04 -0700703
704 # these next ones are to deal with formatting problems resulting from the log being mixed up by 'make -j'
705 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
706 'description':'',
707 'patterns':[r".*: warning: ,$"] },
708 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
709 'description':'',
710 'patterns':[r".*: warning: $"] },
711 { 'category':'C/C++', 'severity':severity.SKIP, 'members':[], 'option':'',
712 'description':'',
713 'patterns':[r".*: warning: In file included from .+,"] },
714
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700715 # warnings from clang-tidy
716 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
717 'description':'clang-tidy readability',
718 'patterns':[r".*: .+\[readability-.+\]$"] },
719 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
720 'description':'clang-tidy c++ core guidelines',
721 'patterns':[r".*: .+\[cppcoreguidelines-.+\]$"] },
722 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
723 'description':'clang-tidy google-runtime',
724 'patterns':[r".*: .+\[google-runtime-.+\]$"] },
725 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
726 'description':'clang-tidy google-build',
727 'patterns':[r".*: .+\[google-build-.+\]$"] },
728 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
729 'description':'clang-tidy google-explicit',
730 'patterns':[r".*: .+\[google-explicit-.+\]$"] },
731 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
Chih-Hung Hsiehd742e902016-03-31 16:14:55 -0700732 'description':'clang-tidy google-readability',
733 'patterns':[r".*: .+\[google-readability-.+\]$"] },
734 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
735 'description':'clang-tidy google-global',
736 'patterns':[r".*: .+\[google-global-.+\]$"] },
737 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700738 'description':'clang-tidy modernize',
739 'patterns':[r".*: .+\[modernize-.+\]$"] },
740 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
741 'description':'clang-tidy misc',
742 'patterns':[r".*: .+\[misc-.+\]$"] },
743 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
744 'description':'clang-tidy CERT',
745 'patterns':[r".*: .+\[cert-.+\]$"] },
746 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
747 'description':'clang-tidy llvm',
748 'patterns':[r".*: .+\[llvm-.+\]$"] },
749 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
750 'description':'clang-tidy clang-diagnostic',
751 'patterns':[r".*: .+\[clang-diagnostic-.+\]$"] },
752 { 'category':'C/C++', 'severity':severity.TIDY, 'members':[], 'option':'',
753 'description':'clang-tidy clang-analyzer',
754 'patterns':[r".*: .+\[clang-analyzer-.+\]$",
755 r".*: Call Path : .+$"] },
756
Marco Nelissen594375d2009-07-14 09:04:04 -0700757 # catch-all for warnings this script doesn't know about yet
758 { 'category':'C/C++', 'severity':severity.UNKNOWN, 'members':[], 'option':'',
759 'description':'Unclassified/unrecognized warnings',
760 'patterns':[r".*: warning: .+"] },
761]
762
763anchor = 0
764cur_row_color = 0
765row_colors = [ 'e0e0e0', 'd0d0d0' ]
766
767def output(text):
768 print text,
769
770def htmlbig(param):
771 return '<font size="+2">' + param + '</font>'
772
773def dumphtmlprologue(title):
774 output('<html>\n<head>\n<title>' + title + '</title>\n<body>\n')
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700775 output('<a name="PageTop">')
Marco Nelissen594375d2009-07-14 09:04:04 -0700776 output(htmlbig(title))
777 output('<p>\n')
778
779def tablerow(text):
780 global cur_row_color
781 output('<tr bgcolor="' + row_colors[cur_row_color] + '"><td colspan="2">',)
782 cur_row_color = 1 - cur_row_color
783 output(text,)
784 output('</td></tr>')
785
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700786def begintable(text, backgroundcolor, extraanchor):
Marco Nelissen594375d2009-07-14 09:04:04 -0700787 global anchor
788 output('<table border="1" rules="cols" frame="box" width="100%" bgcolor="black"><tr bgcolor="' +
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700789 backgroundcolor + '"><a name="anchor' + str(anchor) + '">')
790 if extraanchor:
791 output('<a name="' + extraanchor + '">')
792 output('<td>')
Marco Nelissen594375d2009-07-14 09:04:04 -0700793 output(htmlbig(text[0]) + '<br>')
794 for i in text[1:]:
795 output(i + '<br>')
796 output('</td>')
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700797 output('<td width="100" bgcolor="grey">' +
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700798 '<a align="right" href="#PageTop">top</a><br>' +
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700799 '<a align="right" href="#anchor' + str(anchor-1) + '">previous</a><br>' +
800 '<a align="right" href="#anchor' + str(anchor+1) + '">next</a>')
Marco Nelissen594375d2009-07-14 09:04:04 -0700801 output('</td></a></tr>')
802 anchor += 1
803
804def endtable():
805 output('</table><p>')
806
807
808# dump some stats about total number of warnings and such
809def dumpstats():
810 known = 0
811 unknown = 0
812 for i in warnpatterns:
Chih-Hung Hsiehba0ddcd2016-03-21 11:28:30 -0700813 i['members'] = sorted(set(i['members']))
Marco Nelissen594375d2009-07-14 09:04:04 -0700814 if i['severity'] == severity.UNKNOWN:
815 unknown += len(i['members'])
816 elif i['severity'] != severity.SKIP:
817 known += len(i['members'])
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700818 output('\nNumber of classified warnings: <b>' + str(known) + '</b><br>' )
819 output('\nNumber of unclassified warnings: <b>' + str(unknown) + '</b><br>')
Marco Nelissen594375d2009-07-14 09:04:04 -0700820 total = unknown + known
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700821 output('\nTotal number of warnings: <b>' + str(total) + '</b>')
Marco Nelissen594375d2009-07-14 09:04:04 -0700822 if total < 1000:
823 output('(low count may indicate incremental build)')
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700824 output('\n<p>\n')
825
826# dump count of warnings of a given severity in TOC
827def dumpcount(sev):
828 first = True
829 for i in warnpatterns:
830 if i['severity'] == sev and len(i['members']) > 0:
831 if first:
832 output(headerforseverity(sev) + ':\n<blockquote>' +
833 '<table border="1" frame="box" width="100%">')
834 output('<tr bgcolor="' + colorforseverity(sev) + '">' +
835 '<td><a href="#' + i['anchor'] + '">' + descriptionfor(i) +
836 ' (' + str(len(i['members'])) + ')</a></td></tr>\n')
837 first = False
838 if not first:
839 output('</table></blockquote>\n')
840
841# dump table of content, list of all warning patterns
842def dumptoc():
843 n = 1
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700844 output('<blockquote>\n')
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700845 for i in warnpatterns:
846 i['anchor'] = 'Warning' + str(n)
847 n += 1
848 dumpcount(severity.FIXMENOW)
849 dumpcount(severity.HIGH)
850 dumpcount(severity.MEDIUM)
851 dumpcount(severity.LOW)
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700852 dumpcount(severity.TIDY)
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700853 dumpcount(severity.HARMLESS)
854 dumpcount(severity.UNKNOWN)
855 output('</blockquote>\n<p>\n')
Marco Nelissen594375d2009-07-14 09:04:04 -0700856
857def allpatterns(cat):
858 pats = ''
859 for i in cat['patterns']:
860 pats += i
861 pats += ' / '
862 return pats
863
864def descriptionfor(cat):
865 if cat['description'] != '':
866 return cat['description']
867 return allpatterns(cat)
868
869
870# show which warnings no longer occur
871def dumpfixed():
872 tablestarted = False
873 for i in warnpatterns:
874 if len(i['members']) == 0 and i['severity'] != severity.SKIP:
875 if tablestarted == False:
876 tablestarted = True
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700877 begintable(['Fixed warnings', 'No more occurences. Please consider turning these in to errors if possible, before they are reintroduced in to the build'], 'blue', '')
Marco Nelissen594375d2009-07-14 09:04:04 -0700878 tablerow(i['description'] + ' (' + allpatterns(i) + ') ' + i['option'])
879 if tablestarted:
880 endtable()
881
882
883# dump a category, provided it is not marked as 'SKIP' and has more than 0 occurrences
884def dumpcategory(cat):
885 if cat['severity'] != severity.SKIP and len(cat['members']) != 0:
886 header = [descriptionfor(cat),str(len(cat['members'])) + ' occurences:']
887 if cat['option'] != '':
888 header[1:1] = [' (related option: ' + cat['option'] +')']
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700889 begintable(header, colorforseverity(cat['severity']), cat['anchor'])
Marco Nelissen594375d2009-07-14 09:04:04 -0700890 for i in cat['members']:
891 tablerow(i)
892 endtable()
893
894
895# dump everything for a given severity
896def dumpseverity(sev):
897 for i in warnpatterns:
898 if i['severity'] == sev:
899 dumpcategory(i)
900
901
902def classifywarning(line):
903 for i in warnpatterns:
Marco Nelissen2bdc7ec2009-09-29 10:19:29 -0700904 for cpat in i['compiledpatterns']:
905 if cpat.match(line):
Marco Nelissen594375d2009-07-14 09:04:04 -0700906 i['members'].append(line)
907 return
908 else:
909 # If we end up here, there was a problem parsing the log
910 # probably caused by 'make -j' mixing the output from
911 # 2 or more concurrent compiles
912 pass
913
Marco Nelissen2bdc7ec2009-09-29 10:19:29 -0700914# precompiling every pattern speeds up parsing by about 30x
915def compilepatterns():
916 for i in warnpatterns:
917 i['compiledpatterns'] = []
918 for pat in i['patterns']:
919 i['compiledpatterns'].append(re.compile(pat))
Marco Nelissen594375d2009-07-14 09:04:04 -0700920
921infile = open(sys.argv[1], 'r')
922warnings = []
923
924platformversion = 'unknown'
925targetproduct = 'unknown'
926targetvariant = 'unknown'
927linecounter = 0
928
929warningpattern = re.compile('.* warning:.*')
Marco Nelissen2bdc7ec2009-09-29 10:19:29 -0700930compilepatterns()
Marco Nelissen594375d2009-07-14 09:04:04 -0700931
932# read the log file and classify all the warnings
933lastmatchedline = ''
934for line in infile:
Marco Nelissen8e201962010-03-10 16:16:02 -0800935 # replace fancy quotes with plain ol' quotes
936 line = line.replace("‘", "'");
937 line = line.replace("’", "'");
Marco Nelissen594375d2009-07-14 09:04:04 -0700938 if warningpattern.match(line):
939 if line != lastmatchedline:
940 classifywarning(line)
941 lastmatchedline = line
942 else:
943 # save a little bit of time by only doing this for the first few lines
944 if linecounter < 50:
945 linecounter +=1
946 m = re.search('(?<=^PLATFORM_VERSION=).*', line)
947 if m != None:
948 platformversion = m.group(0)
949 m = re.search('(?<=^TARGET_PRODUCT=).*', line)
950 if m != None:
951 targetproduct = m.group(0)
952 m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
953 if m != None:
954 targetvariant = m.group(0)
955
956
957# dump the html output to stdout
958dumphtmlprologue('Warnings for ' + platformversion + ' - ' + targetproduct + ' - ' + targetvariant)
959dumpstats()
Ian Rogers2f4ce822016-05-10 09:34:29 -0700960# sort table based on number of members once dumpstats has deduplicated the
961# members.
962warnpatterns.sort(reverse=True, key=lambda i: len(i['members']))
Chih-Hung Hsieha9be47e2016-03-21 14:11:03 -0700963dumptoc()
Marco Nelissen594375d2009-07-14 09:04:04 -0700964dumpseverity(severity.FIXMENOW)
965dumpseverity(severity.HIGH)
966dumpseverity(severity.MEDIUM)
967dumpseverity(severity.LOW)
Chih-Hung Hsieh90d46192016-03-29 15:33:11 -0700968dumpseverity(severity.TIDY)
Marco Nelissen594375d2009-07-14 09:04:04 -0700969dumpseverity(severity.HARMLESS)
970dumpseverity(severity.UNKNOWN)
971dumpfixed()