Merge "Add new Asm/C++/Java/Make warning patterns"

This commit is contained in:
Chih-hung Hsieh
2021-06-02 21:37:04 +00:00
committed by Gerrit Code Review
5 changed files with 54 additions and 29 deletions

View File

@@ -91,6 +91,8 @@ warn_patterns = [
[r".*: warning: incompatible redeclaration of library function .+"]), [r".*: warning: incompatible redeclaration of library function .+"]),
high('Null passed as non-null argument', high('Null passed as non-null argument',
[r".*: warning: Null passed to a callee that requires a non-null"]), [r".*: warning: Null passed to a callee that requires a non-null"]),
medium('Unused command line argument',
[r".*: warning: argument unused during compilation: .+"]),
medium('Unused parameter', medium('Unused parameter',
[r".*: warning: unused parameter '.*'"]), [r".*: warning: unused parameter '.*'"]),
medium('Unused function, variable, label, comparison, etc.', medium('Unused function, variable, label, comparison, etc.',
@@ -166,6 +168,8 @@ warn_patterns = [
[r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]), [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]),
medium('Shift count greater than width of type', medium('Shift count greater than width of type',
[r".*: warning: (left|right) shift count >= width of type"]), [r".*: warning: (left|right) shift count >= width of type"]),
medium('Shift operator precedence',
[r".*: warning: operator .* has lower precedence .+Wshift-op-parentheses.+"]),
medium('extern <foo> is initialized', medium('extern <foo> is initialized',
[r".*: warning: '.+' initialized and declared 'extern'", [r".*: warning: '.+' initialized and declared 'extern'",
r".*: warning: 'extern' variable has an initializer"]), r".*: warning: 'extern' variable has an initializer"]),
@@ -239,6 +243,8 @@ warn_patterns = [
[r".*: warning: ignoring #pragma .+"]), [r".*: warning: ignoring #pragma .+"]),
medium('Pragma warning messages', medium('Pragma warning messages',
[r".*: warning: .+W#pragma-messages"]), [r".*: warning: .+W#pragma-messages"]),
medium('Pragma once in main file',
[r".*: warning: #pragma once in main file .+Wpragma-once-outside-header.*"]),
medium('Variable might be clobbered by longjmp or vfork', medium('Variable might be clobbered by longjmp or vfork',
[r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]), [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]),
medium('Argument might be clobbered by longjmp or vfork', medium('Argument might be clobbered by longjmp or vfork',
@@ -333,7 +339,7 @@ warn_patterns = [
low('Deprecated register', low('Deprecated register',
[r".*: warning: 'register' storage class specifier is deprecated"]), [r".*: warning: 'register' storage class specifier is deprecated"]),
low('Converts between pointers to integer types with different sign', low('Converts between pointers to integer types with different sign',
[r".*: warning: .+ converts between pointers to integer types with different sign"]), [r".*: warning: .+ converts between pointers to integer types .+Wpointer-sign\]"]),
harmless('Extra tokens after #endif', harmless('Extra tokens after #endif',
[r".*: warning: extra tokens at end of #endif directive"]), [r".*: warning: extra tokens at end of #endif directive"]),
medium('Comparison between different enums', medium('Comparison between different enums',
@@ -410,6 +416,32 @@ warn_patterns = [
[r".*: warning: missing .+Winvalid-pp-token"]), [r".*: warning: missing .+Winvalid-pp-token"]),
low('need glibc to link', low('need glibc to link',
[r".*: warning: .* requires at runtime .* glibc .* for linking"]), [r".*: warning: .* requires at runtime .* glibc .* for linking"]),
low('Add braces to avoid dangling else',
[r".*: warning: add explicit braces to avoid dangling else"]),
low('Assigning value to self',
[r".*: warning: explicitly assigning value of .+ to itself"]),
low('Comparison of integers of different signs',
[r".*: warning: comparison of integers of different signs.+sign-compare"]),
low('Incompatible pointer types',
[r".*: warning: incompatible .*pointer types .*-Wincompatible-.*pointer-types"]),
low('Missing braces',
[r".*: warning: suggest braces around initialization of",
r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
r".*: warning: braces around scalar initializer"]),
low('Missing field initializers',
[r".*: warning: missing field '.+' initializer"]),
low('Typedef redefinition',
[r".*: warning: redefinition of typedef '.+' is a C11 feature"]),
low('GNU old-style field designator',
[r".*: warning: use of GNU old-style field designator extension"]),
low('Initializer overrides prior initialization',
[r".*: warning: initializer overrides prior initialization of this subobject"]),
low('GNU extension, variable sized type not at end',
[r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]),
low('Comparison of constant is always false/true',
[r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]),
low('Hides overloaded virtual function',
[r".*: '.+' hides overloaded virtual function"]),
medium('Operator new returns NULL', medium('Operator new returns NULL',
[r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]), [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]),
medium('NULL used in arithmetic', medium('NULL used in arithmetic',

View File

@@ -328,7 +328,8 @@ def dump_fixed(writer, warn_patterns):
cur_row_class = 1 - cur_row_class cur_row_class = 1 - cur_row_class
# remove last '\n' # remove last '\n'
out_text = text[:-1] if text[-1] == '\n' else text out_text = text[:-1] if text[-1] == '\n' else text
writer('<tr><td class="c' + str(cur_row_class) + '">' + out_text + '</td></tr>') writer('<tr><td class="c' + str(cur_row_class) + '">'
+ out_text + '</td></tr>')
writer('</table></div>') writer('</table></div>')
writer('</blockquote>') writer('</blockquote>')
@@ -355,7 +356,8 @@ def dump_csv(csvwriter, warn_patterns):
sort_warnings(warn_patterns) sort_warnings(warn_patterns)
total = 0 total = 0
for severity in Severity.levels: for severity in Severity.levels:
total += write_severity(csvwriter, severity, severity.column_header, warn_patterns) total += write_severity(
csvwriter, severity, severity.column_header, warn_patterns)
csvwriter.writerow([total, '', 'All warnings']) csvwriter.writerow([total, '', 'All warnings'])

View File

@@ -74,6 +74,8 @@ warn_patterns = [
[r'.*\.class\): warning: Cannot find annotation method .+ in']), [r'.*\.class\): warning: Cannot find annotation method .+ in']),
java_medium('No class/method in SDK ...', java_medium('No class/method in SDK ...',
[r'.*\.java:.*: warning: No such (class|method) .* for SDK']), [r'.*\.java:.*: warning: No such (class|method) .* for SDK']),
java_medium('Unknown enum constant',
[r'unknown_source_file: warning: unknown enum constant .+']),
# Warnings generated by Error Prone # Warnings generated by Error Prone
java_medium('Non-ascii characters used, but ascii encoding specified', java_medium('Non-ascii characters used, but ascii encoding specified',
[r".*: warning: unmappable character for encoding ascii"]), [r".*: warning: unmappable character for encoding ascii"]),
@@ -207,6 +209,8 @@ warn_patterns = [
'Logging or rethrowing exceptions should usually be preferred to catching and calling printStackTrace'), 'Logging or rethrowing exceptions should usually be preferred to catching and calling printStackTrace'),
medium('CatchFail', medium('CatchFail',
'Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful'), 'Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful'),
medium('ChangedAbstract',
'Method has changed \'abstract\' qualifier'),
medium('ClassCanBeStatic', medium('ClassCanBeStatic',
'Inner class is non-static but does not reference enclosing class'), 'Inner class is non-static but does not reference enclosing class'),
medium('ClassNewInstance', medium('ClassNewInstance',
@@ -355,6 +359,8 @@ warn_patterns = [
'equals method doesn\'t override Object.equals'), 'equals method doesn\'t override Object.equals'),
medium('NotCloseable', medium('NotCloseable',
'Not closeable'), 'Not closeable'),
medium('NullableCollection',
'Method should not return a nullable collection'),
medium('NullableConstructor', medium('NullableConstructor',
'Constructors should not be annotated with @Nullable since they cannot return null'), 'Constructors should not be annotated with @Nullable since they cannot return null'),
medium('NullableDereference', medium('NullableDereference',

View File

@@ -35,6 +35,9 @@ warn_patterns = [
{'category': 'make', 'severity': Severity.HIGH, {'category': 'make', 'severity': Severity.HIGH,
'description': 'System module linking to a vendor module', 'description': 'System module linking to a vendor module',
'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]}, 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
{'category': 'make', 'severity': Severity.HIGH,
'description': 'make: lstat file does not exist',
'patterns': [r".*: warning: lstat .+: file does not exist"]},
{'category': 'make', 'severity': Severity.MEDIUM, {'category': 'make', 'severity': Severity.MEDIUM,
'description': 'Invalid SDK/NDK linking', 'description': 'Invalid SDK/NDK linking',
'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]}, 'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
@@ -56,6 +59,9 @@ warn_patterns = [
{'category': 'make', 'severity': Severity.MEDIUM, {'category': 'make', 'severity': Severity.MEDIUM,
'description': 'make: deprecated macros', 'description': 'make: deprecated macros',
'patterns': [r".*\.mk:.* warning:.* [A-Z_]+ (is|has been) deprecated."]}, 'patterns': [r".*\.mk:.* warning:.* [A-Z_]+ (is|has been) deprecated."]},
{'category': 'make', 'severity': Severity.MEDIUM,
'description': 'make: other Android.mk warnings',
'patterns': [r".*/Android.mk:.*: warning: .+"]},
] ]

View File

@@ -75,37 +75,13 @@ warn_patterns = [
# misc warnings # misc warnings
misc('Duplicate logtag', misc('Duplicate logtag',
[r".*: warning: tag \".+\" \(.+\) duplicated in .+"]), [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]),
misc('Typedef redefinition',
[r".*: warning: redefinition of typedef '.+' is a C11 feature"]),
misc('GNU old-style field designator',
[r".*: warning: use of GNU old-style field designator extension"]),
misc('Missing field initializers',
[r".*: warning: missing field '.+' initializer"]),
misc('Missing braces',
[r".*: warning: suggest braces around initialization of",
r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
r".*: warning: braces around scalar initializer"]),
misc('Comparison of integers of different signs',
[r".*: warning: comparison of integers of different signs.+sign-compare"]),
misc('Add braces to avoid dangling else',
[r".*: warning: add explicit braces to avoid dangling else"]),
misc('Initializer overrides prior initialization',
[r".*: warning: initializer overrides prior initialization of this subobject"]),
misc('Assigning value to self',
[r".*: warning: explicitly assigning value of .+ to itself"]),
misc('GNU extension, variable sized type not at end',
[r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]),
misc('Comparison of constant is always false/true',
[r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]),
misc('Hides overloaded virtual function',
[r".*: '.+' hides overloaded virtual function"]),
misc('Incompatible pointer types',
[r".*: warning: incompatible .*pointer types .*-Wincompatible-.*pointer-types"]),
# Assembler warnings # Assembler warnings
asm('ASM value size does not match register size', asm('ASM value size does not match register size',
[r".*: warning: value size does not match register size specified by the constraint and modifier"]), [r".*: warning: value size does not match register size specified by the constraint and modifier"]),
asm('IT instruction is deprecated', asm('IT instruction is deprecated',
[r".*: warning: applying IT instruction .* is deprecated"]), [r".*: warning: applying IT instruction .* is deprecated"]),
asm('setjmp/longjmp/vfork changed binding',
[r".*: warning: .*(setjmp|longjmp|vfork) changed binding to .*"]),
# NDK warnings # NDK warnings
{'category': 'NDK', 'severity': Severity.HIGH, {'category': 'NDK', 'severity': Severity.HIGH,
'description': 'NDK: Generate guard with empty availability, obsoleted', 'description': 'NDK: Generate guard with empty availability, obsoleted',
@@ -168,6 +144,9 @@ warn_patterns = [
{'category': 'RenderScript', 'severity': Severity.LOW, {'category': 'RenderScript', 'severity': Severity.LOW,
'description': 'RenderScript warnings', 'description': 'RenderScript warnings',
'patterns': [r'.*\.rscript:.*: warning: ']}, 'patterns': [r'.*\.rscript:.*: warning: ']},
{'category': 'RenderScript', 'severity': Severity.HIGH,
'description': 'RenderScript is deprecated',
'patterns': [r'.*: warning: Renderscript is deprecated:.+']},
# Broken/partial warning messages will be skipped. # Broken/partial warning messages will be skipped.
{'category': 'Misc', 'severity': Severity.SKIP, {'category': 'Misc', 'severity': Severity.SKIP,
'description': 'skip, ,', 'description': 'skip, ,',