blob: af8bfe8965bd55595f98fbc0500f6f8af8740ace [file] [log] [blame]
Chih-Hung Hsieh949205a2020-01-10 10:33:40 -08001# python3
Chih-Hung Hsieh888d1432019-12-09 19:32:03 -08002# Copyright (C) 2019 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16"""Warning patterns for C/C++ compiler, but not clang-tidy."""
17
Chih-Hung Hsieh949205a2020-01-10 10:33:40 -080018import re
Chih-Hung Hsieh888d1432019-12-09 19:32:03 -080019
Chih-Hung Hsieh949205a2020-01-10 10:33:40 -080020# pylint:disable=relative-beyond-top-level
21# pylint:disable=g-importing-member
22from .severity import Severity
23
24
25warn_patterns = [
Chih-Hung Hsieh888d1432019-12-09 19:32:03 -080026 # pylint:disable=line-too-long,g-inconsistent-quotes
27 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-function-declaration',
28 'description': 'Implicit function declaration',
29 'patterns': [r".*: warning: implicit declaration of function .+",
30 r".*: warning: implicitly declaring library function"]},
31 {'category': 'C/C++', 'severity': Severity.SKIP,
32 'description': 'skip, conflicting types for ...',
33 'patterns': [r".*: warning: conflicting types for '.+'"]},
34 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
35 'description': 'Expression always evaluates to true or false',
36 'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
37 r".*: warning: comparison of unsigned .*expression .+ is always true",
38 r".*: warning: comparison of unsigned .*expression .+ is always false"]},
39 {'category': 'C/C++', 'severity': Severity.HIGH,
40 'description': 'Use transient memory for control value',
41 'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
42 {'category': 'C/C++', 'severity': Severity.HIGH,
43 'description': 'Return address of stack memory',
44 'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
45 r".*: warning: Address of stack memory .+ will be a dangling reference"]},
46 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
47 'description': 'Infinite recursion',
48 'patterns': [r".*: warning: all paths through this function will call itself"]},
49 {'category': 'C/C++', 'severity': Severity.HIGH,
50 'description': 'Potential buffer overflow',
51 'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
52 r".*: warning: Potential buffer overflow.",
53 r".*: warning: String copy function overflows destination buffer"]},
54 {'category': 'C/C++', 'severity': Severity.MEDIUM,
55 'description': 'Incompatible pointer types',
56 'patterns': [r".*: warning: assignment from incompatible pointer type",
57 r".*: warning: return from incompatible pointer type",
58 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
59 r".*: warning: initialization from incompatible pointer type"]},
60 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
61 'description': 'Incompatible declaration of built in function',
62 'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
63 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
64 'description': 'Incompatible redeclaration of library function',
65 'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
66 {'category': 'C/C++', 'severity': Severity.HIGH,
67 'description': 'Null passed as non-null argument',
68 'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
69 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
70 'description': 'Unused parameter',
71 'patterns': [r".*: warning: unused parameter '.*'"]},
72 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
73 'description': 'Unused function, variable, label, comparison, etc.',
74 'patterns': [r".*: warning: '.+' defined but not used",
75 r".*: warning: unused function '.+'",
76 r".*: warning: unused label '.+'",
77 r".*: warning: relational comparison result unused",
78 r".*: warning: lambda capture .* is not used",
79 r".*: warning: private field '.+' is not used",
80 r".*: warning: unused variable '.+'"]},
81 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
82 'description': 'Statement with no effect or result unused',
83 'patterns': [r".*: warning: statement with no effect",
84 r".*: warning: expression result unused"]},
85 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
86 'description': 'Ignoreing return value of function',
87 'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
88 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
89 'description': 'Missing initializer',
90 'patterns': [r".*: warning: missing initializer"]},
91 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
92 'description': 'Need virtual destructor',
93 'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
94 {'category': 'cont.', 'severity': Severity.SKIP,
95 'description': 'skip, near initialization for ...',
96 'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
97 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
98 'description': 'Expansion of data or time macro',
99 'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
100 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wexpansion-to-defined',
101 'description': 'Macro expansion has undefined behavior',
102 'patterns': [r".*: warning: macro expansion .* has undefined behavior"]},
103 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
104 'description': 'Format string does not match arguments',
105 'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
106 r".*: warning: more '%' conversions than data arguments",
107 r".*: warning: data argument not used by format string",
108 r".*: warning: incomplete format specifier",
109 r".*: warning: unknown conversion type .* in format",
110 r".*: warning: format .+ expects .+ but argument .+Wformat=",
111 r".*: warning: field precision should have .+ but argument has .+Wformat",
112 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
113 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
114 'description': 'Too many arguments for format string',
115 'patterns': [r".*: warning: too many arguments for format"]},
116 {'category': 'C/C++', 'severity': Severity.MEDIUM,
117 'description': 'Too many arguments in call',
118 'patterns': [r".*: warning: too many arguments in call to "]},
119 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
120 'description': 'Invalid format specifier',
121 'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
122 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
123 'description': 'Comparison between signed and unsigned',
124 'patterns': [r".*: warning: comparison between signed and unsigned",
125 r".*: warning: comparison of promoted \~unsigned with unsigned",
126 r".*: warning: signed and unsigned type in conditional expression"]},
127 {'category': 'C/C++', 'severity': Severity.MEDIUM,
128 'description': 'Comparison between enum and non-enum',
129 'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
130 {'category': 'libpng', 'severity': Severity.MEDIUM,
131 'description': 'libpng: zero area',
132 'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
Chih-Hung Hsieh888d1432019-12-09 19:32:03 -0800133 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
134 'description': 'Missing braces around initializer',
135 'patterns': [r".*: warning: missing braces around initializer.*"]},
136 {'category': 'C/C++', 'severity': Severity.HARMLESS,
137 'description': 'No newline at end of file',
138 'patterns': [r".*: warning: no newline at end of file"]},
139 {'category': 'C/C++', 'severity': Severity.HARMLESS,
140 'description': 'Missing space after macro name',
141 'patterns': [r".*: warning: missing whitespace after the macro name"]},
142 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
143 'description': 'Cast increases required alignment',
144 'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
145 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
146 'description': 'Qualifier discarded',
147 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
148 r".*: warning: assignment discards qualifiers from pointer target type",
149 r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
150 r".*: warning: assigning to .+ from .+ discards qualifiers",
151 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
152 r".*: warning: return discards qualifiers from pointer target type"]},
153 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
154 'description': 'Unknown attribute',
155 'patterns': [r".*: warning: unknown attribute '.+'"]},
156 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
157 'description': 'Attribute ignored',
158 'patterns': [r".*: warning: '_*packed_*' attribute ignored",
159 r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
160 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
161 'description': 'Visibility problem',
162 'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
163 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
164 'description': 'Visibility mismatch',
165 'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
166 {'category': 'C/C++', 'severity': Severity.MEDIUM,
167 'description': 'Shift count greater than width of type',
168 'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
169 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
170 'description': 'extern <foo> is initialized',
171 'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
172 r".*: warning: 'extern' variable has an initializer"]},
173 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
174 'description': 'Old style declaration',
175 'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
176 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
177 'description': 'Missing return value',
178 'patterns': [r".*: warning: control reaches end of non-void function"]},
179 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
180 'description': 'Implicit int type',
181 'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
182 r".*: warning: type defaults to 'int' in declaration of '.+'"]},
183 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
184 'description': 'Main function should return int',
185 'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
186 {'category': 'C/C++', 'severity': Severity.MEDIUM, '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, 'option': '-Wuninitialized',
190 'description': 'Variable is used uninitialized',
191 'patterns': [r".*: warning: '.+' is used uninitialized in this function",
192 r".*: warning: variable '.+' is uninitialized when used here"]},
193 {'category': 'ld', 'severity': Severity.MEDIUM, '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, '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, '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, '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, '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 '.+'",
216 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",
219 r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
220 r".*: warning: suggest parentheses around assignment used as truth value"]},
221 {'category': 'C/C++', 'severity': Severity.MEDIUM,
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, '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"]},
227 {'category': 'cont.', 'severity': Severity.SKIP,
228 'description': 'skip, parameter name (without types) in function declaration',
229 'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
230 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
231 'description': 'Dereferencing <foo> breaks strict aliasing rules',
232 'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
233 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
234 'description': 'Cast from pointer to integer of different size',
235 'patterns': [r".*: warning: cast from pointer to integer of different size",
236 r".*: warning: initialization makes pointer from integer without a cast"]},
237 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
238 'description': 'Cast to pointer from integer of different size',
239 'patterns': [r".*: warning: cast to pointer from integer of different size"]},
240 {'category': 'C/C++', 'severity': Severity.MEDIUM,
241 'description': 'Macro redefined',
242 'patterns': [r".*: warning: '.+' macro redefined"]},
243 {'category': 'cont.', 'severity': Severity.SKIP,
244 'description': 'skip, ... location of the previous definition',
245 'patterns': [r".*: warning: this is the location of the previous definition"]},
246 {'category': 'ld', 'severity': Severity.MEDIUM,
247 'description': 'ld: type and size of dynamic symbol are not defined',
248 'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
249 {'category': 'C/C++', 'severity': Severity.MEDIUM,
250 'description': 'Pointer from integer without cast',
251 'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
252 {'category': 'C/C++', 'severity': Severity.MEDIUM,
253 'description': 'Pointer from integer without cast',
254 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
255 {'category': 'C/C++', 'severity': Severity.MEDIUM,
256 'description': 'Integer from pointer without cast',
257 'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
258 {'category': 'C/C++', 'severity': Severity.MEDIUM,
259 'description': 'Integer from pointer without cast',
260 'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
261 {'category': 'C/C++', 'severity': Severity.MEDIUM,
262 'description': 'Integer from pointer without cast',
263 'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
264 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
265 'description': 'Ignoring pragma',
266 'patterns': [r".*: warning: ignoring #pragma .+"]},
267 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
268 'description': 'Pragma warning messages',
269 'patterns': [r".*: warning: .+W#pragma-messages"]},
270 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
271 'description': 'Variable might be clobbered by longjmp or vfork',
272 'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
273 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
274 'description': 'Argument might be clobbered by longjmp or vfork',
275 'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
276 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
277 'description': 'Redundant declaration',
278 'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
279 {'category': 'cont.', 'severity': Severity.SKIP,
280 'description': 'skip, previous declaration ... was here',
281 'patterns': [r".*: warning: previous declaration of '.+' was here"]},
282 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wswitch-enum',
283 'description': 'Enum value not handled in switch',
284 'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
285 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuser-defined-warnings',
286 'description': 'User defined warnings',
287 'patterns': [r".*: warning: .* \[-Wuser-defined-warnings\]$"]},
288 {'category': 'C/C++', 'severity': Severity.MEDIUM,
289 'description': 'Taking address of temporary',
290 'patterns': [r".*: warning: taking address of temporary"]},
291 {'category': 'C/C++', 'severity': Severity.MEDIUM,
292 'description': 'Taking address of packed member',
293 'patterns': [r".*: warning: taking address of packed member"]},
294 {'category': 'C/C++', 'severity': Severity.MEDIUM,
295 'description': 'Possible broken line continuation',
296 'patterns': [r".*: warning: backslash and newline separated by space"]},
297 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
298 'description': 'Undefined variable template',
299 'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
300 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
301 'description': 'Inline function is not defined',
302 'patterns': [r".*: warning: inline function '.*' is not defined"]},
303 {'category': 'C/C++', 'severity': Severity.MEDIUM,
304 'description': 'Excess elements in initializer',
305 'patterns': [r".*: warning: excess elements in .+ initializer"]},
306 {'category': 'C/C++', 'severity': Severity.MEDIUM,
307 'description': 'Decimal constant is unsigned only in ISO C90',
308 'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
309 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
310 'description': 'main is usually a function',
311 'patterns': [r".*: warning: 'main' is usually a function"]},
312 {'category': 'C/C++', 'severity': Severity.MEDIUM,
313 'description': 'Typedef ignored',
314 'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
315 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
316 'description': 'Address always evaluates to true',
317 'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
318 {'category': 'C/C++', 'severity': Severity.FIXMENOW,
319 'description': 'Freeing a non-heap object',
320 'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
321 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
322 'description': 'Array subscript has type char',
323 'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
324 {'category': 'C/C++', 'severity': Severity.MEDIUM,
325 'description': 'Constant too large for type',
326 'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
327 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
328 'description': 'Constant too large for type, truncated',
329 'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
330 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
331 'description': 'Overflow in expression',
332 'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
333 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
334 'description': 'Overflow in implicit constant conversion',
335 'patterns': [r".*: warning: overflow in implicit constant conversion"]},
336 {'category': 'C/C++', 'severity': Severity.MEDIUM,
337 'description': 'Declaration does not declare anything',
338 'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
339 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
340 'description': 'Initialization order will be different',
341 'patterns': [r".*: warning: '.+' will be initialized after",
342 r".*: warning: field .+ will be initialized after .+Wreorder"]},
343 {'category': 'cont.', 'severity': Severity.SKIP,
344 'description': 'skip, ....',
345 'patterns': [r".*: warning: '.+'"]},
346 {'category': 'cont.', 'severity': Severity.SKIP,
347 'description': 'skip, base ...',
348 'patterns': [r".*: warning: base '.+'"]},
349 {'category': 'cont.', 'severity': Severity.SKIP,
350 'description': 'skip, when initialized here',
351 'patterns': [r".*: warning: when initialized here"]},
352 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
353 'description': 'Parameter type not specified',
354 'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
355 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
356 'description': 'Missing declarations',
357 'patterns': [r".*: warning: declaration does not declare anything"]},
358 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
359 'description': 'Missing noreturn',
360 'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
361 {'category': 'C/C++', 'severity': Severity.MEDIUM,
362 'description': 'User warning',
363 'patterns': [r".*: warning: #warning "".+"""]},
364 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
365 'description': 'Vexing parsing problem',
366 'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
367 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
368 'description': 'Dereferencing void*',
369 'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
370 {'category': 'C/C++', 'severity': Severity.MEDIUM,
371 'description': 'Comparison of pointer and integer',
372 'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
373 r".*: warning: .*comparison between pointer and integer"]},
374 {'category': 'C/C++', 'severity': Severity.MEDIUM,
375 'description': 'Use of error-prone unary operator',
376 'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
377 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
378 'description': 'Conversion of string constant to non-const char*',
379 'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
380 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
381 'description': 'Function declaration isn''t a prototype',
382 'patterns': [r".*: warning: function declaration isn't a prototype"]},
383 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
384 'description': 'Type qualifiers ignored on function return value',
385 'patterns': [r".*: warning: type qualifiers ignored on function return type",
386 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
387 {'category': 'C/C++', 'severity': Severity.MEDIUM,
388 'description': '<foo> declared inside parameter list, scope limited to this definition',
389 'patterns': [r".*: warning: '.+' declared inside parameter list"]},
390 {'category': 'cont.', 'severity': Severity.SKIP,
391 'description': 'skip, its scope is only this ...',
392 'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
393 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
394 'description': 'Line continuation inside comment',
395 'patterns': [r".*: warning: multi-line comment"]},
396 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
397 'description': 'Comment inside comment',
398 'patterns': [r".*: warning: '.+' within block comment .*-Wcomment"]},
399 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
400 'description': 'Deprecated declarations',
401 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
402 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
403 'description': 'Deprecated register',
404 'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
405 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
406 'description': 'Converts between pointers to integer types with different sign',
407 'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
408 {'category': 'C/C++', 'severity': Severity.HARMLESS,
409 'description': 'Extra tokens after #endif',
410 'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
411 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
412 'description': 'Comparison between different enums',
413 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare",
414 r".*: warning: comparison of .* enumeration types .*-Wenum-compare-switch"]},
415 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
416 'description': 'Conversion may change value',
417 'patterns': [r".*: warning: converting negative value '.+' to '.+'",
418 r".*: warning: conversion to '.+' .+ may (alter|change)"]},
419 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
420 'description': 'Converting to non-pointer type from NULL',
421 'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
422 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-conversion',
423 'description': 'Implicit sign conversion',
424 'patterns': [r".*: warning: implicit conversion changes signedness"]},
425 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
426 'description': 'Converting NULL to non-pointer type',
427 'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
428 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
429 'description': 'Zero used as null pointer',
430 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
Chih-Hung Hsieha9f77462020-01-06 12:02:27 -0800431 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-compare',
432 'description': 'Compare pointer to null character',
433 'patterns': [r".*: warning: comparing a pointer to a null character constant"]},
Chih-Hung Hsieh888d1432019-12-09 19:32:03 -0800434 {'category': 'C/C++', 'severity': Severity.MEDIUM,
435 'description': 'Implicit conversion changes value or loses precision',
436 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion",
437 r".*: warning: implicit conversion loses integer precision:"]},
438 {'category': 'C/C++', 'severity': Severity.MEDIUM,
439 'description': 'Passing NULL as non-pointer argument',
440 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
441 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
442 'description': 'Class seems unusable because of private ctor/dtor',
443 'patterns': [r".*: warning: all member functions in class '.+' are private"]},
444 # skip this next one, because it only points out some RefBase-based classes
445 # where having a private destructor is perfectly fine
446 {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
447 'description': 'Class seems unusable because of private ctor/dtor',
448 'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
449 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
450 'description': 'Class seems unusable because of private ctor/dtor',
451 'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
452 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
453 'description': 'In-class initializer for static const float/double',
454 'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
455 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
456 'description': 'void* used in arithmetic',
457 'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
458 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
459 r".*: warning: wrong type argument to increment"]},
460 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
461 'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
462 'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
463 {'category': 'cont.', 'severity': Severity.SKIP,
464 'description': 'skip, in call to ...',
465 'patterns': [r".*: warning: in call to '.+'"]},
466 {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
467 'description': 'Base should be explicitly initialized in copy constructor',
468 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
469 {'category': 'C/C++', 'severity': Severity.MEDIUM,
470 'description': 'Return value from void function',
471 'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
472 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
473 'description': 'Multi-character character constant',
474 'patterns': [r".*: warning: multi-character character constant"]},
475 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
476 'description': 'Conversion from string literal to char*',
477 'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
478 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
479 'description': 'Extra \';\'',
480 'patterns': [r".*: warning: extra ';' .+extra-semi"]},
481 {'category': 'C/C++', 'severity': Severity.LOW,
482 'description': 'Useless specifier',
483 'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
484 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
485 'description': 'Duplicate declaration specifier',
486 'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
487 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
488 'description': 'Comparison of self is always false',
489 'patterns': [r".*: self-comparison always evaluates to false"]},
490 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
491 'description': 'Logical op with constant operand',
492 'patterns': [r".*: use of logical '.+' with constant operand"]},
493 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
494 'description': 'Needs a space between literal and string macro',
495 'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
496 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
497 'description': 'Warnings from #warning',
498 'patterns': [r".*: warning: .+-W#warnings"]},
499 {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
500 'description': 'Using float/int absolute value function with int/float argument',
501 'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
502 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
503 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
504 'description': 'Using C++11 extensions',
505 'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
506 {'category': 'C/C++', 'severity': Severity.LOW,
507 'description': 'Refers to implicitly defined namespace',
508 'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
509 {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
510 'description': 'Invalid pp token',
511 'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
512 {'category': 'link', 'severity': Severity.LOW,
513 'description': 'need glibc to link',
514 'patterns': [r".*: warning: .* requires at runtime .* glibc .* for linking"]},
515
516 {'category': 'C/C++', 'severity': Severity.MEDIUM,
517 'description': 'Operator new returns NULL',
518 'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
519 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
520 'description': 'NULL used in arithmetic',
521 'patterns': [r".*: warning: NULL used in arithmetic",
522 r".*: warning: comparison between NULL and non-pointer"]},
523 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
524 'description': 'Misspelled header guard',
525 'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
526 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
527 'description': 'Empty loop body',
528 'patterns': [r".*: warning: .+ loop has empty body"]},
529 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
530 'description': 'Implicit conversion from enumeration type',
531 'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
532 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
533 'description': 'case value not in enumerated type',
534 'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
535 {'category': 'C/C++', 'severity': Severity.MEDIUM,
536 'description': 'Use of deprecated method',
537 'patterns': [r".*: warning: '.+' is deprecated .+"]},
538 {'category': 'C/C++', 'severity': Severity.MEDIUM,
539 'description': 'Use of garbage or uninitialized value',
540 'patterns': [r".*: warning: .+ uninitialized .+\[-Wsometimes-uninitialized\]"]},
541 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
542 'description': 'Sizeof on array argument',
543 'patterns': [r".*: warning: sizeof on array function parameter will return"]},
544 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
545 'description': 'Bad argument size of memory access functions',
546 'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
547 {'category': 'C/C++', 'severity': Severity.MEDIUM,
548 'description': 'Return value not checked',
549 'patterns': [r".*: warning: The return value from .+ is not checked"]},
550 {'category': 'C/C++', 'severity': Severity.MEDIUM,
551 'description': 'Possible heap pollution',
552 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
553 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
554 'description': 'Variable used in loop condition not modified in loop body',
555 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
556 {'category': 'C/C++', 'severity': Severity.MEDIUM,
557 'description': 'Closing a previously closed file',
558 'patterns': [r".*: warning: Closing a previously closed file"]},
559 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
560 'description': 'Unnamed template type argument',
561 'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
562 {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-fallthrough',
563 'description': 'Unannotated fall-through between switch labels',
564 'patterns': [r".*: warning: unannotated fall-through between switch labels.+Wimplicit-fallthrough"]},
565 {'category': 'C/C++', 'severity': Severity.HARMLESS,
566 'description': 'Discarded qualifier from pointer target type',
567 'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
568 {'category': 'C/C++', 'severity': Severity.HARMLESS,
569 'description': 'Use snprintf instead of sprintf',
570 'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
571 {'category': 'C/C++', 'severity': Severity.HARMLESS,
572 'description': 'Unsupported optimizaton flag',
573 'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
574 {'category': 'C/C++', 'severity': Severity.HARMLESS,
575 'description': 'Extra or missing parentheses',
576 'patterns': [r".*: warning: equality comparison with extraneous parentheses",
577 r".*: warning: .+ within .+Wlogical-op-parentheses"]},
578 {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
579 'description': 'Mismatched class vs struct tags',
580 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
581 r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
582]
Chih-Hung Hsieh949205a2020-01-10 10:33:40 -0800583
584
585def compile_patterns(patterns):
586 """Precompiling every pattern speeds up parsing by about 30x."""
587 for i in patterns:
588 i['compiled_patterns'] = []
589 for pat in i['patterns']:
590 i['compiled_patterns'].append(re.compile(pat))
591
592
593compile_patterns(warn_patterns)