Merge "Add new Asm/C++/Java/Make warning patterns" am: 041770b553

Original change: https://android-review.googlesource.com/c/platform/build/+/1724110

Change-Id: I01334bb1041ef7d395f3c0bd3c93ec9a3a6eded2
This commit is contained in:
Chih-hung Hsieh 2021-06-02 21:56:52 +00:00 committed by Automerger Merge Worker
commit dee5f7979b
5 changed files with 54 additions and 29 deletions

View file

@ -91,6 +91,8 @@ warn_patterns = [
[r".*: warning: incompatible redeclaration of library function .+"]),
high('Null passed as non-null argument',
[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',
[r".*: warning: unused parameter '.*'"]),
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 '.+'"]),
medium('Shift count greater than 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',
[r".*: warning: '.+' initialized and declared 'extern'",
r".*: warning: 'extern' variable has an initializer"]),
@ -239,6 +243,8 @@ warn_patterns = [
[r".*: warning: ignoring #pragma .+"]),
medium('Pragma warning 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',
[r".*: warning: variable '.+' 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',
[r".*: warning: 'register' storage class specifier is deprecated"]),
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',
[r".*: warning: extra tokens at end of #endif directive"]),
medium('Comparison between different enums',
@ -410,6 +416,32 @@ warn_patterns = [
[r".*: warning: missing .+Winvalid-pp-token"]),
low('need glibc to link',
[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',
[r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]),
medium('NULL used in arithmetic',

View file

@ -328,7 +328,8 @@ def dump_fixed(writer, warn_patterns):
cur_row_class = 1 - cur_row_class
# remove last '\n'
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('</blockquote>')
@ -355,7 +356,8 @@ def dump_csv(csvwriter, warn_patterns):
sort_warnings(warn_patterns)
total = 0
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'])

View file

@ -74,6 +74,8 @@ warn_patterns = [
[r'.*\.class\): warning: Cannot find annotation method .+ in']),
java_medium('No class/method in 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
java_medium('Non-ascii characters used, but ascii encoding specified',
[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'),
medium('CatchFail',
'Ignoring exceptions and calling fail() is unnecessary, and makes test output less useful'),
medium('ChangedAbstract',
'Method has changed \'abstract\' qualifier'),
medium('ClassCanBeStatic',
'Inner class is non-static but does not reference enclosing class'),
medium('ClassNewInstance',
@ -355,6 +359,8 @@ warn_patterns = [
'equals method doesn\'t override Object.equals'),
medium('NotCloseable',
'Not closeable'),
medium('NullableCollection',
'Method should not return a nullable collection'),
medium('NullableConstructor',
'Constructors should not be annotated with @Nullable since they cannot return null'),
medium('NullableDereference',

View file

@ -35,6 +35,9 @@ warn_patterns = [
{'category': 'make', 'severity': Severity.HIGH,
'description': 'System module linking to a vendor module',
'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,
'description': 'Invalid SDK/NDK linking',
'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
@ -56,6 +59,9 @@ warn_patterns = [
{'category': 'make', 'severity': Severity.MEDIUM,
'description': 'make: deprecated macros',
'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('Duplicate logtag',
[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
asm('ASM value size does not match register size',
[r".*: warning: value size does not match register size specified by the constraint and modifier"]),
asm('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
{'category': 'NDK', 'severity': Severity.HIGH,
'description': 'NDK: Generate guard with empty availability, obsoleted',
@ -168,6 +144,9 @@ warn_patterns = [
{'category': 'RenderScript', 'severity': Severity.LOW,
'description': 'RenderScript warnings',
'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.
{'category': 'Misc', 'severity': Severity.SKIP,
'description': 'skip, ,',