1# python3 2# 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 18import re 19 20# pylint:disable=relative-beyond-top-level 21# pylint:disable=g-importing-member 22from .severity import Severity 23 24 25def cpp_warn(severity, description, pattern_list): 26 return { 27 'category': 'C/C++', 28 'severity': severity, 29 'description': description, 30 'patterns': pattern_list 31 } 32 33 34def fixmenow(description, pattern_list): 35 return cpp_warn(Severity.FIXMENOW, description, pattern_list) 36 37 38def high(description, pattern_list): 39 return cpp_warn(Severity.HIGH, description, pattern_list) 40 41 42def medium(description, pattern_list): 43 return cpp_warn(Severity.MEDIUM, description, pattern_list) 44 45 46def low(description, pattern_list): 47 return cpp_warn(Severity.LOW, description, pattern_list) 48 49 50def skip(description, pattern_list): 51 return cpp_warn(Severity.SKIP, description, pattern_list) 52 53 54def harmless(description, pattern_list): 55 return cpp_warn(Severity.HARMLESS, description, pattern_list) 56 57 58warn_patterns = [ 59 # pylint:disable=line-too-long,g-inconsistent-quotes 60 medium('Implicit function declaration', 61 [r".*: warning: implicit declaration of function .+", 62 r".*: warning: implicitly declaring library function"]), 63 skip('skip, conflicting types for ...', 64 [r".*: warning: conflicting types for '.+'"]), 65 high('Expression always evaluates to true or false', 66 [r".*: warning: comparison is always .+ due to limited range of data type", 67 r".*: warning: comparison of unsigned .*expression .+ is always true", 68 r".*: warning: comparison of unsigned .*expression .+ is always false"]), 69 high('Use transient memory for control value', 70 [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]), 71 high('Return address of stack memory', 72 [r".*: warning: Address of stack memory .+ returned to caller", 73 r".*: warning: Address of stack memory .+ will be a dangling reference"]), 74 high('Infinite recursion', 75 [r".*: warning: all paths through this function will call itself"]), 76 high('Potential buffer overflow', 77 [r".*: warning: Size argument is greater than .+ the destination buffer", 78 r".*: warning: Potential buffer overflow.", 79 r".*: warning: String copy function overflows destination buffer"]), 80 medium('Incompatible pointer types', 81 [r".*: warning: assignment from incompatible pointer type", 82 r".*: warning: return from incompatible pointer type", 83 r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type", 84 r".*: warning: initialization from incompatible pointer type"]), 85 high('Incompatible declaration of built in function', 86 [r".*: warning: incompatible implicit declaration of built-in function .+"]), 87 high('Incompatible redeclaration of library function', 88 [r".*: warning: incompatible redeclaration of library function .+"]), 89 high('Null passed as non-null argument', 90 [r".*: warning: Null passed to a callee that requires a non-null"]), 91 medium('Unused parameter', 92 [r".*: warning: unused parameter '.*'"]), 93 medium('Unused function, variable, label, comparison, etc.', 94 [r".*: warning: '.+' defined but not used", 95 r".*: warning: unused function '.+'", 96 r".*: warning: unused label '.+'", 97 r".*: warning: relational comparison result unused", 98 r".*: warning: lambda capture .* is not used", 99 r".*: warning: private field '.+' is not used", 100 r".*: warning: unused variable '.+'"]), 101 medium('Statement with no effect or result unused', 102 [r".*: warning: statement with no effect", 103 r".*: warning: expression result unused"]), 104 medium('Ignoreing return value of function', 105 [r".*: warning: ignoring return value of function .+Wunused-result"]), 106 medium('Missing initializer', 107 [r".*: warning: missing initializer"]), 108 medium('Need virtual destructor', 109 [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]), 110 skip('skip, near initialization for ...', 111 [r".*: warning: \(near initialization for '.+'\)"]), 112 medium('Expansion of data or time macro', 113 [r".*: warning: expansion of date or time macro is not reproducible"]), 114 medium('Macro expansion has undefined behavior', 115 [r".*: warning: macro expansion .* has undefined behavior"]), 116 medium('Format string does not match arguments', 117 [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'", 118 r".*: warning: more '%' conversions than data arguments", 119 r".*: warning: data argument not used by format string", 120 r".*: warning: incomplete format specifier", 121 r".*: warning: unknown conversion type .* in format", 122 r".*: warning: format .+ expects .+ but argument .+Wformat=", 123 r".*: warning: field precision should have .+ but argument has .+Wformat", 124 r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]), 125 medium('Too many arguments for format string', 126 [r".*: warning: too many arguments for format"]), 127 medium('Too many arguments in call', 128 [r".*: warning: too many arguments in call to "]), 129 medium('Invalid format specifier', 130 [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]), 131 medium('Comparison between signed and unsigned', 132 [r".*: warning: comparison between signed and unsigned", 133 r".*: warning: comparison of promoted \~unsigned with unsigned", 134 r".*: warning: signed and unsigned type in conditional expression"]), 135 medium('Comparison between enum and non-enum', 136 [r".*: warning: enumeral and non-enumeral type in conditional expression"]), 137 medium('libpng: zero area', 138 [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]), 139 medium('Missing braces around initializer', 140 [r".*: warning: missing braces around initializer.*"]), 141 harmless('No newline at end of file', 142 [r".*: warning: no newline at end of file"]), 143 harmless('Missing space after macro name', 144 [r".*: warning: missing whitespace after the macro name"]), 145 low('Cast increases required alignment', 146 [r".*: warning: cast from .* to .* increases required alignment .*"]), 147 medium('Qualifier discarded', 148 [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type", 149 r".*: warning: assignment discards qualifiers from pointer target type", 150 r".*: warning: passing .+ to parameter of type .+ discards qualifiers", 151 r".*: warning: assigning to .+ from .+ discards qualifiers", 152 r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers", 153 r".*: warning: return discards qualifiers from pointer target type"]), 154 medium('Unknown attribute', 155 [r".*: warning: unknown attribute '.+'"]), 156 medium('Attribute ignored', 157 [r".*: warning: '_*packed_*' attribute ignored", 158 r".*: warning: attribute declaration must precede definition .+ignored-attributes"]), 159 medium('Visibility problem', 160 [r".*: warning: declaration of '.+' will not be visible outside of this function"]), 161 medium('Visibility mismatch', 162 [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]), 163 medium('Shift count greater than width of type', 164 [r".*: warning: (left|right) shift count >= width of type"]), 165 medium('extern <foo> is initialized', 166 [r".*: warning: '.+' initialized and declared 'extern'", 167 r".*: warning: 'extern' variable has an initializer"]), 168 medium('Old style declaration', 169 [r".*: warning: 'static' is not at beginning of declaration"]), 170 medium('Missing return value', 171 [r".*: warning: control reaches end of non-void function"]), 172 medium('Implicit int type', 173 [r".*: warning: type specifier missing, defaults to 'int'", 174 r".*: warning: type defaults to 'int' in declaration of '.+'"]), 175 medium('Main function should return int', 176 [r".*: warning: return type of 'main' is not 'int'"]), 177 medium('Variable may be used uninitialized', 178 [r".*: warning: '.+' may be used uninitialized in this function"]), 179 high('Variable is used uninitialized', 180 [r".*: warning: '.+' is used uninitialized in this function", 181 r".*: warning: variable '.+' is uninitialized when used here"]), 182 medium('ld: possible enum size mismatch', 183 [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]), 184 medium('Pointer targets differ in signedness', 185 [r".*: warning: pointer targets in initialization differ in signedness", 186 r".*: warning: pointer targets in assignment differ in signedness", 187 r".*: warning: pointer targets in return differ in signedness", 188 r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]), 189 medium('Assuming overflow does not occur', 190 [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]), 191 medium('Suggest adding braces around empty body', 192 [r".*: warning: suggest braces around empty body in an 'if' statement", 193 r".*: warning: empty body in an if-statement", 194 r".*: warning: suggest braces around empty body in an 'else' statement", 195 r".*: warning: empty body in an else-statement"]), 196 medium('Suggest adding parentheses', 197 [r".*: warning: suggest explicit braces to avoid ambiguous 'else'", 198 r".*: warning: suggest parentheses around arithmetic in operand of '.+'", 199 r".*: warning: suggest parentheses around comparison in operand of '.+'", 200 r".*: warning: logical not is only applied to the left hand side of this comparison", 201 r".*: warning: using the result of an assignment as a condition without parentheses", 202 r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses", 203 r".*: warning: suggest parentheses around '.+?' .+ '.+?'", 204 r".*: warning: suggest parentheses around assignment used as truth value"]), 205 medium('Static variable used in non-static inline function', 206 [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]), 207 medium('No type or storage class (will default to int)', 208 [r".*: warning: data definition has no type or storage class"]), 209 skip('skip, parameter name (without types) in function declaration', 210 [r".*: warning: parameter names \(without types\) in function declaration"]), 211 medium('Dereferencing <foo> breaks strict aliasing rules', 212 [r".*: warning: dereferencing .* break strict-aliasing rules"]), 213 medium('Cast from pointer to integer of different size', 214 [r".*: warning: cast from pointer to integer of different size", 215 r".*: warning: initialization makes pointer from integer without a cast"]), 216 medium('Cast to pointer from integer of different size', 217 [r".*: warning: cast to pointer from integer of different size"]), 218 medium('Macro redefined', 219 [r".*: warning: '.+' macro redefined"]), 220 skip('skip, ... location of the previous definition', 221 [r".*: warning: this is the location of the previous definition"]), 222 medium('ld: type and size of dynamic symbol are not defined', 223 [r".*: warning: type and size of dynamic symbol `.+' are not defined"]), 224 medium('Pointer from integer without cast', 225 [r".*: warning: assignment makes pointer from integer without a cast"]), 226 medium('Pointer from integer without cast', 227 [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]), 228 medium('Integer from pointer without cast', 229 [r".*: warning: assignment makes integer from pointer without a cast"]), 230 medium('Integer from pointer without cast', 231 [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]), 232 medium('Integer from pointer without cast', 233 [r".*: warning: return makes integer from pointer without a cast"]), 234 medium('Ignoring pragma', 235 [r".*: warning: ignoring #pragma .+"]), 236 medium('Pragma warning messages', 237 [r".*: warning: .+W#pragma-messages"]), 238 medium('Variable might be clobbered by longjmp or vfork', 239 [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]), 240 medium('Argument might be clobbered by longjmp or vfork', 241 [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]), 242 medium('Redundant declaration', 243 [r".*: warning: redundant redeclaration of '.+'"]), 244 skip('skip, previous declaration ... was here', 245 [r".*: warning: previous declaration of '.+' was here"]), 246 high('Enum value not handled in switch', 247 [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]), 248 medium('User defined warnings', 249 [r".*: warning: .* \[-Wuser-defined-warnings\]$"]), 250 medium('Taking address of temporary', 251 [r".*: warning: taking address of temporary"]), 252 medium('Taking address of packed member', 253 [r".*: warning: taking address of packed member"]), 254 medium('Possible broken line continuation', 255 [r".*: warning: backslash and newline separated by space"]), 256 medium('Undefined variable template', 257 [r".*: warning: instantiation of variable .* no definition is available"]), 258 medium('Inline function is not defined', 259 [r".*: warning: inline function '.*' is not defined"]), 260 medium('Excess elements in initializer', 261 [r".*: warning: excess elements in .+ initializer"]), 262 medium('Decimal constant is unsigned only in ISO C90', 263 [r".*: warning: this decimal constant is unsigned only in ISO C90"]), 264 medium('main is usually a function', 265 [r".*: warning: 'main' is usually a function"]), 266 medium('Typedef ignored', 267 [r".*: warning: 'typedef' was ignored in this declaration"]), 268 high('Address always evaluates to true', 269 [r".*: warning: the address of '.+' will always evaluate as 'true'"]), 270 fixmenow('Freeing a non-heap object', 271 [r".*: warning: attempt to free a non-heap object '.+'"]), 272 medium('Array subscript has type char', 273 [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]), 274 medium('Constant too large for type', 275 [r".*: warning: integer constant is too large for '.+' type"]), 276 medium('Constant too large for type, truncated', 277 [r".*: warning: large integer implicitly truncated to unsigned type"]), 278 medium('Overflow in expression', 279 [r".*: warning: overflow in expression; .*Winteger-overflow"]), 280 medium('Overflow in implicit constant conversion', 281 [r".*: warning: overflow in implicit constant conversion"]), 282 medium('Declaration does not declare anything', 283 [r".*: warning: declaration 'class .+' does not declare anything"]), 284 medium('Initialization order will be different', 285 [r".*: warning: '.+' will be initialized after", 286 r".*: warning: field .+ will be initialized after .+Wreorder"]), 287 skip('skip, ....', 288 [r".*: warning: '.+'"]), 289 skip('skip, base ...', 290 [r".*: warning: base '.+'"]), 291 skip('skip, when initialized here', 292 [r".*: warning: when initialized here"]), 293 medium('Parameter type not specified', 294 [r".*: warning: type of '.+' defaults to 'int'"]), 295 medium('Missing declarations', 296 [r".*: warning: declaration does not declare anything"]), 297 medium('Missing noreturn', 298 [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]), 299 medium('User warning', 300 [r".*: warning: #warning "".+"""]), 301 medium('Vexing parsing problem', 302 [r".*: warning: empty parentheses interpreted as a function declaration"]), 303 medium('Dereferencing void*', 304 [r".*: warning: dereferencing 'void \*' pointer"]), 305 medium('Comparison of pointer and integer', 306 [r".*: warning: ordered comparison of pointer with integer zero", 307 r".*: warning: .*comparison between pointer and integer"]), 308 medium('Use of error-prone unary operator', 309 [r".*: warning: use of unary operator that may be intended as compound assignment"]), 310 medium('Conversion of string constant to non-const char*', 311 [r".*: warning: deprecated conversion from string constant to '.+'"]), 312 medium('Function declaration isn''t a prototype', 313 [r".*: warning: function declaration isn't a prototype"]), 314 medium('Type qualifiers ignored on function return value', 315 [r".*: warning: type qualifiers ignored on function return type", 316 r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]), 317 medium('<foo> declared inside parameter list, scope limited to this definition', 318 [r".*: warning: '.+' declared inside parameter list"]), 319 skip('skip, its scope is only this ...', 320 [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]), 321 low('Line continuation inside comment', 322 [r".*: warning: multi-line comment"]), 323 low('Comment inside comment', 324 [r".*: warning: '.+' within block comment .*-Wcomment"]), 325 low('Deprecated declarations', 326 [r".*: warning: .+ is deprecated.+deprecated-declarations"]), 327 low('Deprecated register', 328 [r".*: warning: 'register' storage class specifier is deprecated"]), 329 low('Converts between pointers to integer types with different sign', 330 [r".*: warning: .+ converts between pointers to integer types with different sign"]), 331 harmless('Extra tokens after #endif', 332 [r".*: warning: extra tokens at end of #endif directive"]), 333 medium('Comparison between different enums', 334 [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare", 335 r".*: warning: comparison of .* enumeration types .*-Wenum-compare-switch"]), 336 medium('Conversion may change value', 337 [r".*: warning: converting negative value '.+' to '.+'", 338 r".*: warning: conversion to '.+' .+ may (alter|change)"]), 339 medium('Converting to non-pointer type from NULL', 340 [r".*: warning: converting to non-pointer type '.+' from NULL"]), 341 medium('Implicit sign conversion', 342 [r".*: warning: implicit conversion changes signedness"]), 343 medium('Converting NULL to non-pointer type', 344 [r".*: warning: implicit conversion of NULL constant to '.+'"]), 345 medium('Zero used as null pointer', 346 [r".*: warning: expression .* zero treated as a null pointer constant"]), 347 medium('Compare pointer to null character', 348 [r".*: warning: comparing a pointer to a null character constant"]), 349 medium('Implicit conversion changes value or loses precision', 350 [r".*: warning: implicit conversion .* changes value from .* to .*-conversion", 351 r".*: warning: implicit conversion loses integer precision:"]), 352 medium('Passing NULL as non-pointer argument', 353 [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]), 354 medium('Class seems unusable because of private ctor/dtor', 355 [r".*: warning: all member functions in class '.+' are private"]), 356 # skip this next one, because it only points out some RefBase-based classes 357 # where having a private destructor is perfectly fine 358 skip('Class seems unusable because of private ctor/dtor', 359 [r".*: warning: 'class .+' only defines a private destructor and has no friends"]), 360 medium('Class seems unusable because of private ctor/dtor', 361 [r".*: warning: 'class .+' only defines private constructors and has no friends"]), 362 medium('In-class initializer for static const float/double', 363 [r".*: warning: in-class initializer for static data member of .+const (float|double)"]), 364 medium('void* used in arithmetic', 365 [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)", 366 r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith", 367 r".*: warning: wrong type argument to increment"]), 368 medium('Overload resolution chose to promote from unsigned or enum to signed type', 369 [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]), 370 skip('skip, in call to ...', 371 [r".*: warning: in call to '.+'"]), 372 high('Base should be explicitly initialized in copy constructor', 373 [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]), 374 medium('Return value from void function', 375 [r".*: warning: 'return' with a value, in function returning void"]), 376 medium('Multi-character character constant', 377 [r".*: warning: multi-character character constant"]), 378 medium('Conversion from string literal to char*', 379 [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]), 380 low('Extra \';\'', 381 [r".*: warning: extra ';' .+extra-semi"]), 382 low('Useless specifier', 383 [r".*: warning: useless storage class specifier in empty declaration"]), 384 low('Duplicate declaration specifier', 385 [r".*: warning: duplicate '.+' declaration specifier"]), 386 low('Comparison of self is always false', 387 [r".*: self-comparison always evaluates to false"]), 388 low('Logical op with constant operand', 389 [r".*: use of logical '.+' with constant operand"]), 390 low('Needs a space between literal and string macro', 391 [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]), 392 low('Warnings from #warning', 393 [r".*: warning: .+-W#warnings"]), 394 low('Using float/int absolute value function with int/float argument', 395 [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value", 396 r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]), 397 low('Using C++11 extensions', 398 [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]), 399 low('Refers to implicitly defined namespace', 400 [r".*: warning: using directive refers to implicitly-defined namespace .+"]), 401 low('Invalid pp token', 402 [r".*: warning: missing .+Winvalid-pp-token"]), 403 low('need glibc to link', 404 [r".*: warning: .* requires at runtime .* glibc .* for linking"]), 405 medium('Operator new returns NULL', 406 [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]), 407 medium('NULL used in arithmetic', 408 [r".*: warning: NULL used in arithmetic", 409 r".*: warning: comparison between NULL and non-pointer"]), 410 medium('Misspelled header guard', 411 [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]), 412 medium('Empty loop body', 413 [r".*: warning: .+ loop has empty body"]), 414 medium('Implicit conversion from enumeration type', 415 [r".*: warning: implicit conversion from enumeration type '.+'"]), 416 medium('case value not in enumerated type', 417 [r".*: warning: case value not in enumerated type '.+'"]), 418 medium('Use of deprecated method', 419 [r".*: warning: '.+' is deprecated .+"]), 420 medium('Use of garbage or uninitialized value', 421 [r".*: warning: .+ uninitialized .+\[-Wsometimes-uninitialized\]"]), 422 medium('Sizeof on array argument', 423 [r".*: warning: sizeof on array function parameter will return"]), 424 medium('Bad argument size of memory access functions', 425 [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]), 426 medium('Return value not checked', 427 [r".*: warning: The return value from .+ is not checked"]), 428 medium('Possible heap pollution', 429 [r".*: warning: .*Possible heap pollution from .+ type .+"]), 430 medium('Variable used in loop condition not modified in loop body', 431 [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]), 432 medium('Closing a previously closed file', 433 [r".*: warning: Closing a previously closed file"]), 434 medium('Unnamed template type argument', 435 [r".*: warning: template argument.+Wunnamed-type-template-args"]), 436 medium('Unannotated fall-through between switch labels', 437 [r".*: warning: unannotated fall-through between switch labels.+Wimplicit-fallthrough"]), 438 medium('Invalid partial specialization', 439 [r".*: warning: class template partial specialization.+Winvalid-partial-specialization"]), 440 medium('Overlapping compatisons', 441 [r".*: warning: overlapping comparisons.+Wtautological-overlap-compare"]), 442 medium('int in bool context', 443 [r".*: warning: converting.+to a boolean.+Wint-in-bool-context"]), 444 medium('bitwise conditional parentheses', 445 [r".*: warning: operator.+has lower precedence.+Wbitwise-conditional-parentheses"]), 446 medium('sizeof array div', 447 [r".*: warning: .+number of elements in.+array.+Wsizeof-array-div"]), 448 medium('bool operation', 449 [r".*: warning: .+boolean.+always.+Wbool-operation"]), 450 medium('Undefined bool conversion', 451 [r".*: warning: .+may be.+always.+true.+Wundefined-bool-conversion"]), 452 medium('Typedef requires a name', 453 [r".*: warning: typedef requires a name.+Wmissing-declaration"]), 454 medium('Unknown escape sequence', 455 [r".*: warning: unknown escape sequence.+Wunknown-escape-sequence"]), 456 medium('Unicode whitespace', 457 [r".*: warning: treating Unicode.+as whitespace.+Wunicode-whitespace"]), 458 medium('Unused local typedef', 459 [r".*: warning: unused typedef.+Wunused-local-typedef"]), 460 medium('varargs warnings', 461 [r".*: warning: .*argument to 'va_start'.+\[-Wvarargs\]"]), 462 harmless('Discarded qualifier from pointer target type', 463 [r".*: warning: .+ discards '.+' qualifier from pointer target type"]), 464 harmless('Use snprintf instead of sprintf', 465 [r".*: warning: .*sprintf is often misused; please use snprintf"]), 466 harmless('Unsupported optimizaton flag', 467 [r".*: warning: optimization flag '.+' is not supported"]), 468 harmless('Extra or missing parentheses', 469 [r".*: warning: equality comparison with extraneous parentheses", 470 r".*: warning: .+ within .+Wlogical-op-parentheses"]), 471 harmless('Mismatched class vs struct tags', 472 [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags", 473 r".*: warning: .+ was previously declared as a .+mismatched-tags"]), 474] 475 476 477def compile_patterns(patterns): 478 """Precompiling every pattern speeds up parsing by about 30x.""" 479 for i in patterns: 480 i['compiled_patterns'] = [] 481 for pat in i['patterns']: 482 i['compiled_patterns'].append(re.compile(pat)) 483 484 485compile_patterns(warn_patterns) 486