From d591a5e01208693f3273a5327a1568ebd4c109a8 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Tue, 24 Sep 2019 11:13:00 -0700 Subject: [PATCH] Add new compiler warning patterns * Add Kotlin, NDK, Protoc, Asm, and other new patterns. * Put all clang-analyzer warnings to the ANALYZER severity group. Some security and null pointer warnings still have HIGH severity. * Comment out old C/C++ warnings that overlap with analyzer warnings and do not appear in current build.log. * Other old fixed warning patterns should be commented out later. Bug: 141493530 Test: warn.py --url=http://cs/android --separator='?l=' build.log > warnings.html Change-Id: Idc7b09e5e4eefa127d41e9f37da1f566ed1ede1f --- tools/warn.py | 346 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 209 insertions(+), 137 deletions(-) diff --git a/tools/warn.py b/tools/warn.py index 86fa8c0239..f0fbfbc80a 100755 --- a/tools/warn.py +++ b/tools/warn.py @@ -159,11 +159,43 @@ def group_tidy_warn_pattern(description): return tidy_warn_pattern(description, description + r'-.+') +def analyzer_high(description, patterns): + # Important clang analyzer warnings to be fixed ASAP. + return { + 'category': 'C/C++', + 'severity': Severity.HIGH, + 'description': description, + 'patterns': patterns + } + + +def analyzer_high_check(check): + return analyzer_high(check, [r'.*: .+\[' + check + r'\]$']) + + +def analyzer_group_high(check): + return analyzer_high(check, [r'.*: .+\[' + check + r'.+\]$']) + + +def analyzer_warn(description, patterns): + return { + 'category': 'C/C++', + 'severity': Severity.ANALYZER, + 'description': description, + 'patterns': patterns + } + + +def analyzer_warn_check(check): + return analyzer_warn(check, [r'.*: .+\[' + check + r'\]$']) + + +def analyzer_group_check(check): + return analyzer_warn(check, [r'.*: .+\[' + check + r'.+\]$']) + + warn_patterns = [ # pylint:disable=line-too-long,g-inconsistent-quotes - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Security warning', - 'patterns': [r".*: warning: .+\[clang-analyzer-security.*\]"]}, {'category': 'make', 'severity': Severity.MEDIUM, 'description': 'make: overriding commands/ignoring old commands', 'patterns': [r".*: warning: overriding commands for target .+", @@ -183,7 +215,7 @@ warn_patterns = [ {'category': 'make', 'severity': Severity.MEDIUM, 'description': 'Duplicate header copy', 'patterns': [r".*: warning: Duplicate header copy: .+"]}, - {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wimplicit-function-declaration', + {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-function-declaration', 'description': 'Implicit function declaration', 'patterns': [r".*: warning: implicit declaration of function .+", r".*: warning: implicitly declaring library function"]}, @@ -195,17 +227,17 @@ warn_patterns = [ 'patterns': [r".*: warning: comparison is always .+ due to limited range of data type", r".*: warning: comparison of unsigned .*expression .+ is always true", r".*: warning: comparison of unsigned .*expression .+ is always false"]}, - {'category': 'C/C++', 'severity': Severity.HIGH, - 'description': 'Potential leak of memory, bad free, use after free', - 'patterns': [r".*: warning: Potential leak of memory", - r".*: warning: Potential memory leak", - r".*: warning: Memory allocated by alloca\(\) should not be deallocated", - r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+", - r".*: warning: 'delete' applied to a pointer that was allocated", - r".*: warning: Use of memory after it is freed", - r".*: warning: Argument to .+ is the address of .+ variable", - r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by", - r".*: warning: Attempt to .+ released memory"]}, + # {'category': 'C/C++', 'severity': Severity.HIGH, + # 'description': 'Potential leak of memory, bad free, use after free', + # 'patterns': [r".*: warning: Potential leak of memory", + # r".*: warning: Potential memory leak", + # r".*: warning: Memory allocated by alloca\(\) should not be deallocated", + # r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+", + # r".*: warning: 'delete' applied to a pointer that was allocated", + # r".*: warning: Use of memory after it is freed", + # r".*: warning: Argument to .+ is the address of .+ variable", + # r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by", + # r".*: warning: Attempt to .+ released memory"]}, {'category': 'C/C++', 'severity': Severity.HIGH, 'description': 'Use transient memory for control value', 'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]}, @@ -213,10 +245,10 @@ warn_patterns = [ 'description': 'Return address of stack memory', 'patterns': [r".*: warning: Address of stack memory .+ returned to caller", r".*: warning: Address of stack memory .+ will be a dangling reference"]}, - {'category': 'C/C++', 'severity': Severity.HIGH, - 'description': 'Problem with vfork', - 'patterns': [r".*: warning: This .+ is prohibited after a successful vfork", - r".*: warning: Call to function '.+' is insecure "]}, + # {'category': 'C/C++', 'severity': Severity.HIGH, + # 'description': 'Problem with vfork', + # 'patterns': [r".*: warning: This .+ is prohibited after a successful vfork", + # r".*: warning: Call to function '.+' is insecure "]}, {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion', 'description': 'Infinite recursion', 'patterns': [r".*: warning: all paths through this function will call itself"]}, @@ -271,6 +303,9 @@ warn_patterns = [ {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time', 'description': 'Expansion of data or time macro', 'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]}, + {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wexpansion-to-defined', + 'description': 'Macro expansion has undefined behavior', + 'patterns': [r".*: warning: macro expansion .* has undefined behavior"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat', 'description': 'Format string does not match arguments', 'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'", @@ -398,16 +433,16 @@ warn_patterns = [ {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int', 'description': 'No type or storage class (will default to int)', 'patterns': [r".*: warning: data definition has no type or storage class"]}, - {'category': 'C/C++', 'severity': Severity.MEDIUM, - 'description': 'Null pointer', - 'patterns': [r".*: warning: Dereference of null pointer", - r".*: warning: Called .+ pointer is null", - r".*: warning: Forming reference to null pointer", - r".*: warning: Returning null reference", - r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter", - r".*: warning: .+ results in a null pointer dereference", - r".*: warning: Access to .+ results in a dereference of a null pointer", - r".*: warning: Null pointer argument in"]}, + # {'category': 'C/C++', 'severity': Severity.MEDIUM, + # 'description': 'Null pointer', + # 'patterns': [r".*: warning: Dereference of null pointer", + # r".*: warning: Called .+ pointer is null", + # r".*: warning: Forming reference to null pointer", + # r".*: warning: Returning null reference", + # r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter", + # r".*: warning: .+ results in a null pointer dereference", + # r".*: warning: Access to .+ results in a dereference of a null pointer", + # r".*: warning: Null pointer argument in"]}, {'category': 'cont.', 'severity': Severity.SKIP, 'description': 'skip, parameter name (without types) in function declaration', 'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]}, @@ -422,8 +457,8 @@ warn_patterns = [ 'description': 'Cast to pointer from integer of different size', 'patterns': [r".*: warning: cast to pointer from integer of different size"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, - 'description': 'Symbol redefined', - 'patterns': [r".*: warning: "".+"" redefined"]}, + 'description': 'Macro redefined', + 'patterns': [r".*: warning: '.+' macro redefined"]}, {'category': 'cont.', 'severity': Severity.SKIP, 'description': 'skip, ... location of the previous definition', 'patterns': [r".*: warning: this is the location of the previous definition"]}, @@ -463,7 +498,7 @@ warn_patterns = [ {'category': 'cont.', 'severity': Severity.SKIP, 'description': 'skip, previous declaration ... was here', 'patterns': [r".*: warning: previous declaration of '.+' was here"]}, - {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wswitch-enum', + {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wswitch-enum', 'description': 'Enum value not handled in switch', 'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuser-defined-warnings', @@ -484,6 +519,9 @@ warn_patterns = [ {'category': 'java', 'severity': Severity.MEDIUM, 'description': '_ used as an identifier', 'patterns': [r".*: warning: '_' used as an identifier"]}, + {'category': 'java', 'severity': Severity.MEDIUM, + 'description': 'Java: hidden superclass', + 'patterns': [r".*: warning: .* stripped of .* superclass .* \[HiddenSuperclass\]"]}, {'category': 'java', 'severity': Severity.HIGH, 'description': 'Use of internal proprietary API', 'patterns': [r".*: warning: .* is internal proprietary API and may be removed"]}, @@ -2184,11 +2222,11 @@ warn_patterns = [ {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline', 'description': 'Inline function is not defined', 'patterns': [r".*: warning: inline function '.*' is not defined"]}, - {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds', - 'description': 'Array subscript out of bounds', - 'patterns': [r".*: warning: array subscript is above array bounds", - r".*: warning: Array subscript is undefined", - r".*: warning: array subscript is below array bounds"]}, + # {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds', + # 'description': 'Array subscript out of bounds', + # 'patterns': [r".*: warning: array subscript is above array bounds", + # r".*: warning: Array subscript is undefined", + # r".*: warning: array subscript is below array bounds"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'description': 'Excess elements in initializer', 'patterns': [r".*: warning: excess elements in .+ initializer"]}, @@ -2289,14 +2327,7 @@ warn_patterns = [ 'patterns': [r".*: warning: multi-line comment"]}, {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment', 'description': 'Comment inside comment', - 'patterns': [r".*: warning: "".+"" within comment"]}, - # Warning "value stored is never read" could be from clang-tidy or clang static analyzer. - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Value stored is never read', - 'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]}, - {'category': 'C/C++', 'severity': Severity.LOW, - 'description': 'Value stored is never read', - 'patterns': [r".*: warning: Value stored to .+ is never read"]}, + 'patterns': [r".*: warning: '.+' within block comment .*-Wcomment"]}, {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations', 'description': 'Deprecated declarations', 'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]}, @@ -2311,7 +2342,8 @@ warn_patterns = [ 'patterns': [r".*: warning: extra tokens at end of #endif directive"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare', 'description': 'Comparison between different enums', - 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]}, + 'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare", + r".*: warning: comparison of .* enumeration types .*-Wenum-compare-switch"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion', 'description': 'Conversion may change value', 'patterns': [r".*: warning: converting negative value '.+' to '.+'", @@ -2329,8 +2361,9 @@ warn_patterns = [ 'description': 'Zero used as null pointer', 'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, - 'description': 'Implicit conversion changes value', - 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]}, + 'description': 'Implicit conversion changes value or loses precision', + 'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion", + r".*: warning: implicit conversion loses integer precision:"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'description': 'Passing NULL as non-pointer argument', 'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]}, @@ -2361,9 +2394,9 @@ warn_patterns = [ {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra', 'description': 'Base should be explicitly initialized in copy constructor', 'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]}, - {'category': 'C/C++', 'severity': Severity.MEDIUM, - 'description': 'VLA has zero or negative size', - 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]}, + # {'category': 'C/C++', 'severity': Severity.MEDIUM, + # 'description': 'VLA has zero or negative size', + # 'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'description': 'Return value from void function', 'patterns': [r".*: warning: 'return' with a value, in function returning void"]}, @@ -2420,9 +2453,9 @@ warn_patterns = [ {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual', 'description': 'Hides overloaded virtual function', 'patterns': [r".*: '.+' hides overloaded virtual function"]}, - {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types', + {'category': 'logtags', 'severity': Severity.LOW, 'description': 'Incompatible pointer types', - 'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]}, + 'patterns': [r".*: warning: incompatible .*pointer types .*-Wincompatible-.*pointer-types"]}, {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths', 'description': 'ASM value size does not match register size', 'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]}, @@ -2474,35 +2507,38 @@ warn_patterns = [ {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch', 'description': 'case value not in enumerated type', 'patterns': [r".*: warning: case value not in enumerated type '.+'"]}, - {'category': 'C/C++', 'severity': Severity.MEDIUM, - 'description': 'Undefined result', - 'patterns': [r".*: warning: The result of .+ is undefined", - r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]", - r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;", - r".*: warning: shifting a negative signed value is undefined"]}, - {'category': 'C/C++', 'severity': Severity.MEDIUM, - 'description': 'Division by zero', - 'patterns': [r".*: warning: Division by zero"]}, + # {'category': 'C/C++', 'severity': Severity.MEDIUM, + # 'description': 'Undefined result', + # 'patterns': [r".*: warning: The result of .+ is undefined", + # r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]", + # r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;", + # r".*: warning: shifting a negative signed value is undefined"]}, + # {'category': 'C/C++', 'severity': Severity.MEDIUM, + # 'description': 'Division by zero', + # 'patterns': [r".*: warning: Division by zero"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'description': 'Use of deprecated method', 'patterns': [r".*: warning: '.+' is deprecated .+"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'description': 'Use of garbage or uninitialized value', - 'patterns': [r".*: warning: .+ is a garbage value", - r".*: warning: Function call argument is an uninitialized value", - r".*: warning: Undefined or garbage value returned to caller", - r".*: warning: Called .+ pointer is.+uninitialized", - r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message - r".*: warning: Use of zero-allocated memory", - r".*: warning: Dereference of undefined pointer value", - r".*: warning: Passed-by-value .+ contains uninitialized data", - r".*: warning: Branch condition evaluates to a garbage value", - r".*: warning: The .+ of .+ is an uninitialized value.", - r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized", - r".*: warning: Assigned value is garbage or undefined"]}, - {'category': 'C/C++', 'severity': Severity.MEDIUM, - 'description': 'Result of malloc type incompatible with sizeof operand type', - 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]}, + 'patterns': [r".*: warning: .+ uninitialized .+\[-Wsometimes-uninitialized\]"]}, + # {'category': 'C/C++', 'severity': Severity.MEDIUM, + # 'description': 'Use of garbage or uninitialized value', + # 'patterns': [r".*: warning: .+ is a garbage value", + # r".*: warning: Function call argument is an uninitialized value", + # r".*: warning: Undefined or garbage value returned to caller", + # r".*: warning: Called .+ pointer is.+uninitialized", + # r".*: warning: Called .+ pointer is.+uninitalized", # match a typo in compiler message + # r".*: warning: Use of zero-allocated memory", + # r".*: warning: Dereference of undefined pointer value", + # r".*: warning: Passed-by-value .+ contains uninitialized data", + # r".*: warning: Branch condition evaluates to a garbage value", + # r".*: warning: The .+ of .+ is an uninitialized value.", + # r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized", + # r".*: warning: Assigned value is garbage or undefined"]}, + # {'category': 'C/C++', 'severity': Severity.MEDIUM, + # 'description': 'Result of malloc type incompatible with sizeof operand type', + # 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument', 'description': 'Sizeof on array argument', 'patterns': [r".*: warning: sizeof on array function parameter will return"]}, @@ -2515,12 +2551,12 @@ warn_patterns = [ {'category': 'C/C++', 'severity': Severity.MEDIUM, 'description': 'Possible heap pollution', 'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]}, - {'category': 'C/C++', 'severity': Severity.MEDIUM, - 'description': 'Allocation size of 0 byte', - 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]}, - {'category': 'C/C++', 'severity': Severity.MEDIUM, - 'description': 'Result of malloc type incompatible with sizeof operand type', - 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]}, + # {'category': 'C/C++', 'severity': Severity.MEDIUM, + # 'description': 'Allocation size of 0 byte', + # 'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]}, + # {'category': 'C/C++', 'severity': Severity.MEDIUM, + # 'description': 'Result of malloc type incompatible with sizeof operand type', + # 'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis', 'description': 'Variable used in loop condition not modified in loop body', 'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]}, @@ -2554,12 +2590,15 @@ warn_patterns = [ {'category': 'FindEmulator', 'severity': Severity.HARMLESS, 'description': 'FindEmulator: No such file or directory', 'patterns': [r".*: warning: FindEmulator: .* No such file or directory"]}, - {'category': 'google_tests', 'severity': Severity.HARMLESS, - 'description': 'google_tests: unknown installed file', + {'category': 'make', 'severity': Severity.HARMLESS, + 'description': 'make: unknown installed file', 'patterns': [r".*: warning: .*_tests: Unknown installed file for module"]}, {'category': 'make', 'severity': Severity.HARMLESS, 'description': 'unusual tags debug eng', 'patterns': [r".*: warning: .*: unusual tags debug eng"]}, + {'category': 'make', 'severity': Severity.MEDIUM, + 'description': 'make: please convert to soong', + 'patterns': [r".*: warning: .* has been deprecated. Please convert to Soong."]}, # these next ones are to deal with formatting problems resulting from the log being mixed up by 'make -j' {'category': 'C/C++', 'severity': Severity.SKIP, @@ -2574,6 +2613,7 @@ warn_patterns = [ # warnings from clang-tidy group_tidy_warn_pattern('android'), + simple_tidy_warn_pattern('abseil-string-find-startswith'), simple_tidy_warn_pattern('bugprone-argument-comment'), simple_tidy_warn_pattern('bugprone-copy-constructor-init'), simple_tidy_warn_pattern('bugprone-fold-init-type'), @@ -2633,66 +2673,98 @@ warn_patterns = [ simple_tidy_warn_pattern('performance-type-promotion-in-math-fn'), simple_tidy_warn_pattern('performance-unnecessary-copy-initialization'), simple_tidy_warn_pattern('performance-unnecessary-value-param'), + simple_tidy_warn_pattern('portability-simd-intrinsics'), group_tidy_warn_pattern('performance'), group_tidy_warn_pattern('readability'), # warnings from clang-tidy's clang-analyzer checks - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Unreachable code', - 'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Size of malloc may overflow', - 'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Stream pointer might be NULL', - 'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Opened file never closed', - 'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer sozeof() on a pointer type', - 'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Pointer arithmetic on non-array variables', - 'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Subtraction of pointers of different memory chunks', - 'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Access out-of-bound array element', - 'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Out of bound memory access', - 'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Possible lock order reversal', - 'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer Argument is a pointer to uninitialized value', - 'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer cast to struct', - 'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer call path problems', - 'patterns': [r".*: warning: Call Path : .+"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer excessive padding', - 'patterns': [r".*: warning: Excessive padding in '.*'"]}, - {'category': 'C/C++', 'severity': Severity.ANALYZER, - 'description': 'clang-analyzer other', - 'patterns': [r".*: .+\[clang-analyzer-.+\]$", - r".*: Call Path : .+$"]}, + analyzer_high('clang-analyzer-core, null pointer', + [r".*: warning: .+ pointer is null .*\[clang-analyzer-core"]), + analyzer_high('clang-analyzer-core, uninitialized value', + [r".*: warning: .+ uninitialized (value|data) .*\[clang-analyzer-core"]), + analyzer_warn('clang-analyzer-optin.performance.Padding', + [r".*: warning: Excessive padding in '.*'"]), + # analyzer_warn('clang-analyzer Unreachable code', + # [r".*: warning: This statement is never executed.*UnreachableCode"]), + analyzer_warn('clang-analyzer Size of malloc may overflow', + [r".*: warning: .* size of .* may overflow .*MallocOverflow"]), + analyzer_warn('clang-analyzer sozeof() on a pointer type', + [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]), + analyzer_warn('clang-analyzer Pointer arithmetic on non-array variables', + [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]), + analyzer_warn('clang-analyzer Subtraction of pointers of different memory chunks', + [r".*: warning: Subtraction of two pointers .*PointerSub"]), + analyzer_warn('clang-analyzer Access out-of-bound array element', + [r".*: warning: Access out-of-bound array element .*ArrayBound"]), + analyzer_warn('clang-analyzer Out of bound memory access', + [r".*: warning: Out of bound memory access .*ArrayBoundV2"]), + analyzer_warn('clang-analyzer Possible lock order reversal', + [r".*: warning: .* Possible lock order reversal.*PthreadLock"]), + analyzer_warn('clang-analyzer call path problems', + [r".*: warning: Call Path : .+"]), + analyzer_warn_check('clang-analyzer-core.CallAndMessage'), + analyzer_high_check('clang-analyzer-core.NonNullParamChecker'), + analyzer_high_check('clang-analyzer-core.NullDereference'), + analyzer_warn_check('clang-analyzer-core.UndefinedBinaryOperatorResult'), + analyzer_warn_check('clang-analyzer-core.DivideZero'), + analyzer_warn_check('clang-analyzer-core.VLASize'), + analyzer_warn_check('clang-analyzer-core.uninitialized.ArraySubscript'), + analyzer_warn_check('clang-analyzer-core.uninitialized.Assign'), + analyzer_warn_check('clang-analyzer-core.uninitialized.UndefReturn'), + analyzer_warn_check('clang-analyzer-cplusplus.Move'), + analyzer_warn_check('clang-analyzer-deadcode.DeadStores'), + analyzer_warn_check('clang-analyzer-optin.cplusplus.UninitializedObject'), + analyzer_warn_check('clang-analyzer-optin.cplusplus.VirtualCall'), + analyzer_warn_check('clang-analyzer-portability.UnixAPI'), + analyzer_warn_check('clang-analyzer-unix.cstring.NullArg'), + analyzer_high_check('clang-analyzer-unix.MallocSizeof'), + analyzer_warn_check('clang-analyzer-valist.Uninitialized'), + analyzer_warn_check('clang-analyzer-valist.Unterminated'), + analyzer_group_check('clang-analyzer-core.uninitialized'), + analyzer_group_check('clang-analyzer-deadcode'), + analyzer_warn_check('clang-analyzer-security.insecureAPI.strcpy'), + analyzer_group_high('clang-analyzer-security.insecureAPI'), + analyzer_group_high('clang-analyzer-security'), + analyzer_group_check('clang-analyzer-unix.Malloc'), + analyzer_group_check('clang-analyzer-unix'), + analyzer_group_check('clang-analyzer'), # catch al + + # Assembler warnings + {'category': 'Asm', 'severity': Severity.MEDIUM, + 'description': 'Asm: IT instruction is deprecated', + 'patterns': [r".*: warning: applying IT instruction .* is deprecated"]}, + + # NDK warnings + {'category': 'NDK', 'severity': Severity.HIGH, + 'description': 'NDK: Generate guard with empty availability, obsoleted', + 'patterns': [r".*: warning: .* generate guard with empty availability: obsoleted ="]}, + + # Protoc warnings + {'category': 'Protoc', 'severity': Severity.MEDIUM, + 'description': 'Proto: Enum name colision after strip', + 'patterns': [r".*: warning: Enum .* has the same name .* ignore case and strip"]}, + + # Kotlin warnings + {'category': 'Kotlin', 'severity': Severity.MEDIUM, + 'description': 'Kotlin: never used parameter', + 'patterns': [r".*: warning: parameter '.*' is never used"]}, + {'category': 'Kotlin', 'severity': Severity.MEDIUM, + 'description': 'Kotlin: Deprecated in Java', + 'patterns': [r".*: warning: '.*' is deprecated. Deprecated in Java"]}, + {'category': 'Kotlin', 'severity': Severity.MEDIUM, + 'description': 'Kotlin: library has Kotlin runtime', + 'patterns': [r".*: warning: library has Kotlin runtime bundled into it", + r".*: warning: some JAR files .* have the Kotlin Runtime library"]}, # rustc warnings - {'category': 'rust', 'severity': Severity.HIGH, - 'description': 'Does not derive Copy', + {'category': 'Rust', 'severity': Severity.HIGH, + 'description': 'Rust: Does not derive Copy', 'patterns': [r".*: warning: .+ does not derive Copy"]}, - {'category': 'rust', 'severity': Severity.MEDIUM, - 'description': 'Deprecated range pattern', + {'category': 'Rust', 'severity': Severity.MEDIUM, + 'description': 'Rust: Deprecated range pattern', 'patterns': [r".*: warning: .+ range patterns are deprecated"]}, - {'category': 'rust', 'severity': Severity.MEDIUM, - 'description': 'Deprecated missing explicit \'dyn\'', + {'category': 'Rust', 'severity': Severity.MEDIUM, + 'description': 'Rust: Deprecated missing explicit \'dyn\'', 'patterns': [r".*: warning: .+ without an explicit `dyn` are deprecated"]}, # catch-all for warnings this script doesn't know about yet