Merge "Add Identity Credential 1.0"
diff --git a/Changes.md b/Changes.md
index 04e0161..70e338c 100644
--- a/Changes.md
+++ b/Changes.md
@@ -1,5 +1,20 @@
 # Build System Changes for Android.mk Writers
 
+## `m4` is not available on `$PATH`
+
+There is a prebuilt of it available in prebuilts/build-tools, and a make
+variable `M4` that contains the path.
+
+Beyond the direct usage, whenever you use bison or flex directly, they call m4
+behind the scene, so you must set the M4 environment variable (and depend upon
+it for incremental build correctness):
+
+```
+$(intermediates)/foo.c: .KATI_IMPLICIT_OUTPUTS := $(intermediates)/foo.h
+$(intermediates)/foo.c: $(LOCAL_PATH)/foo.y $(M4) $(BISON) $(BISON_DATA)
+	M4=$(M4) $(BISON) ...
+```
+
 ## Rules executed within limited environment
 
 With `ALLOW_NINJA_ENV=false` (soon to be the default), ninja, and all the
diff --git a/core/build_rro_package.mk b/core/build_rro_package.mk
index e5d7685..ae528bd 100644
--- a/core/build_rro_package.mk
+++ b/core/build_rro_package.mk
@@ -32,6 +32,12 @@
   LOCAL_MODULE_PATH := $(partition)/overlay/$(LOCAL_RRO_THEME)
 endif
 
+# Do not remove resources without default values nor dedupe resource
+# configurations with the same value
+LOCAL_AAPT_FLAGS += \
+    --no-resource-deduping \
+    --no-resource-removal
+
 partition :=
 
 include $(BUILD_SYSTEM)/package.mk
diff --git a/envsetup.sh b/envsetup.sh
index a44cd50..389fbb7 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -1342,7 +1342,7 @@
         refreshmod || return 1
     fi
 
-    python -c "import json; print '\n'.join(sorted(json.load(open('$ANDROID_PRODUCT_OUT/module-info.json')).keys()))"
+    python -c "import json; print('\n'.join(sorted(json.load(open('$ANDROID_PRODUCT_OUT/module-info.json')).keys())))"
 }
 
 # Get the path of a specific module in the android tree, as cached in module-info.json. If any build change
@@ -1368,7 +1368,7 @@
 module_info = json.load(open('$ANDROID_PRODUCT_OUT/module-info.json'))
 if module not in module_info:
     exit(1)
-print module_info[module]['path'][0]" 2>/dev/null)
+print(module_info[module]['path'][0])" 2>/dev/null)
 
     if [ -z "$relpath" ]; then
         echo "Could not find module '$1' (try 'refreshmod' if there have been build changes?)." >&2
diff --git a/tools/warn/cpp_warn_patterns.py b/tools/warn/cpp_warn_patterns.py
index af8bfe8..0c458fb 100644
--- a/tools/warn/cpp_warn_patterns.py
+++ b/tools/warn/cpp_warn_patterns.py
@@ -22,563 +22,431 @@
 from .severity import Severity
 
 
+def cpp_warn(severity, description, pattern_list):
+  return {
+      'category': 'C/C++',
+      'severity': severity,
+      'description': description,
+      'patterns': pattern_list
+  }
+
+
+def fixmenow(description, pattern_list):
+  return cpp_warn(Severity.FIXMENOW, description, pattern_list)
+
+
+def high(description, pattern_list):
+  return cpp_warn(Severity.HIGH, description, pattern_list)
+
+
+def medium(description, pattern_list):
+  return cpp_warn(Severity.MEDIUM, description, pattern_list)
+
+
+def low(description, pattern_list):
+  return cpp_warn(Severity.LOW, description, pattern_list)
+
+
+def skip(description, pattern_list):
+  return cpp_warn(Severity.SKIP, description, pattern_list)
+
+
+def harmless(description, pattern_list):
+  return cpp_warn(Severity.HARMLESS, description, pattern_list)
+
+
 warn_patterns = [
     # pylint:disable=line-too-long,g-inconsistent-quotes
-    {'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"]},
-    {'category': 'C/C++', 'severity': Severity.SKIP,
-     'description': 'skip, conflicting types for ...',
-     'patterns': [r".*: warning: conflicting types for '.+'"]},
-    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
-     'description': 'Expression always evaluates to true or false',
-     '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': 'Use transient memory for control value',
-     'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
-    {'category': 'C/C++', 'severity': Severity.HIGH,
-     '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, 'option': 'infinite-recursion',
-     'description': 'Infinite recursion',
-     'patterns': [r".*: warning: all paths through this function will call itself"]},
-    {'category': 'C/C++', 'severity': Severity.HIGH,
-     'description': 'Potential buffer overflow',
-     'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
-                  r".*: warning: Potential buffer overflow.",
-                  r".*: warning: String copy function overflows destination buffer"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Incompatible pointer types',
-     'patterns': [r".*: warning: assignment from incompatible pointer type",
-                  r".*: warning: return from incompatible pointer type",
-                  r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
-                  r".*: warning: initialization from incompatible pointer type"]},
-    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
-     'description': 'Incompatible declaration of built in function',
-     'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
-    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
-     'description': 'Incompatible redeclaration of library function',
-     'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
-    {'category': 'C/C++', 'severity': Severity.HIGH,
-     'description': 'Null passed as non-null argument',
-     'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
-     'description': 'Unused parameter',
-     'patterns': [r".*: warning: unused parameter '.*'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
-     'description': 'Unused function, variable, label, comparison, etc.',
-     'patterns': [r".*: warning: '.+' defined but not used",
-                  r".*: warning: unused function '.+'",
-                  r".*: warning: unused label '.+'",
-                  r".*: warning: relational comparison result unused",
-                  r".*: warning: lambda capture .* is not used",
-                  r".*: warning: private field '.+' is not used",
-                  r".*: warning: unused variable '.+'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
-     'description': 'Statement with no effect or result unused',
-     'patterns': [r".*: warning: statement with no effect",
-                  r".*: warning: expression result unused"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
-     'description': 'Ignoreing return value of function',
-     'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
-     'description': 'Missing initializer',
-     'patterns': [r".*: warning: missing initializer"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
-     'description': 'Need virtual destructor',
-     'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
-    {'category': 'cont.', 'severity': Severity.SKIP,
-     'description': 'skip, near initialization for ...',
-     'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
-    {'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 '.+'",
-                  r".*: warning: more '%' conversions than data arguments",
-                  r".*: warning: data argument not used by format string",
-                  r".*: warning: incomplete format specifier",
-                  r".*: warning: unknown conversion type .* in format",
-                  r".*: warning: format .+ expects .+ but argument .+Wformat=",
-                  r".*: warning: field precision should have .+ but argument has .+Wformat",
-                  r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
-     'description': 'Too many arguments for format string',
-     'patterns': [r".*: warning: too many arguments for format"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Too many arguments in call',
-     'patterns': [r".*: warning: too many arguments in call to "]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
-     'description': 'Invalid format specifier',
-     'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
-     'description': 'Comparison between signed and unsigned',
-     'patterns': [r".*: warning: comparison between signed and unsigned",
-                  r".*: warning: comparison of promoted \~unsigned with unsigned",
-                  r".*: warning: signed and unsigned type in conditional expression"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Comparison between enum and non-enum',
-     'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
-    {'category': 'libpng', 'severity': Severity.MEDIUM,
-     'description': 'libpng: zero area',
-     'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
-     'description': 'Missing braces around initializer',
-     'patterns': [r".*: warning: missing braces around initializer.*"]},
-    {'category': 'C/C++', 'severity': Severity.HARMLESS,
-     'description': 'No newline at end of file',
-     'patterns': [r".*: warning: no newline at end of file"]},
-    {'category': 'C/C++', 'severity': Severity.HARMLESS,
-     'description': 'Missing space after macro name',
-     'patterns': [r".*: warning: missing whitespace after the macro name"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
-     'description': 'Cast increases required alignment',
-     'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
-     'description': 'Qualifier discarded',
-     'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
-                  r".*: warning: assignment discards qualifiers from pointer target type",
-                  r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
-                  r".*: warning: assigning to .+ from .+ discards qualifiers",
-                  r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
-                  r".*: warning: return discards qualifiers from pointer target type"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
-     'description': 'Unknown attribute',
-     'patterns': [r".*: warning: unknown attribute '.+'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
-     'description': 'Attribute ignored',
-     'patterns': [r".*: warning: '_*packed_*' attribute ignored",
-                  r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
-     'description': 'Visibility problem',
-     'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
-     'description': 'Visibility mismatch',
-     'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Shift count greater than width of type',
-     'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
-     'description': 'extern <foo> is initialized',
-     'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
-                  r".*: warning: 'extern' variable has an initializer"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
-     'description': 'Old style declaration',
-     'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
-     'description': 'Missing return value',
-     'patterns': [r".*: warning: control reaches end of non-void function"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
-     'description': 'Implicit int type',
-     'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
-                  r".*: warning: type defaults to 'int' in declaration of '.+'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
-     'description': 'Main function should return int',
-     'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
-     'description': 'Variable may be used uninitialized',
-     'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
-    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
-     'description': 'Variable is used uninitialized',
-     'patterns': [r".*: warning: '.+' is used uninitialized in this function",
-                  r".*: warning: variable '.+' is uninitialized when used here"]},
-    {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
-     'description': 'ld: possible enum size mismatch',
-     'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
-     'description': 'Pointer targets differ in signedness',
-     'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
-                  r".*: warning: pointer targets in assignment differ in signedness",
-                  r".*: warning: pointer targets in return differ in signedness",
-                  r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
-     'description': 'Assuming overflow does not occur',
-     'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
-     'description': 'Suggest adding braces around empty body',
-     'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
-                  r".*: warning: empty body in an if-statement",
-                  r".*: warning: suggest braces around empty body in an 'else' statement",
-                  r".*: warning: empty body in an else-statement"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
-     'description': 'Suggest adding parentheses',
-     'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
-                  r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
-                  r".*: warning: suggest parentheses around comparison in operand of '.+'",
-                  r".*: warning: logical not is only applied to the left hand side of this comparison",
-                  r".*: warning: using the result of an assignment as a condition without parentheses",
-                  r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
-                  r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
-                  r".*: warning: suggest parentheses around assignment used as truth value"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Static variable used in non-static inline function',
-     'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
-    {'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': 'cont.', 'severity': Severity.SKIP,
-     'description': 'skip, parameter name (without types) in function declaration',
-     'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
-     'description': 'Dereferencing <foo> breaks strict aliasing rules',
-     'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
-     'description': 'Cast from pointer to integer of different size',
-     'patterns': [r".*: warning: cast from pointer to integer of different size",
-                  r".*: warning: initialization makes pointer from integer without a cast"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
-     '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': '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"]},
-    {'category': 'ld', 'severity': Severity.MEDIUM,
-     'description': 'ld: type and size of dynamic symbol are not defined',
-     'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Pointer from integer without cast',
-     'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Pointer from integer without cast',
-     'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Integer from pointer without cast',
-     'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Integer from pointer without cast',
-     'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Integer from pointer without cast',
-     'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
-     'description': 'Ignoring pragma',
-     'patterns': [r".*: warning: ignoring #pragma .+"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
-     'description': 'Pragma warning messages',
-     'patterns': [r".*: warning: .+W#pragma-messages"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
-     'description': 'Variable might be clobbered by longjmp or vfork',
-     'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
-     'description': 'Argument might be clobbered by longjmp or vfork',
-     'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
-     'description': 'Redundant declaration',
-     'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
-    {'category': 'cont.', 'severity': Severity.SKIP,
-     'description': 'skip, previous declaration ... was here',
-     'patterns': [r".*: warning: previous declaration of '.+' was here"]},
-    {'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',
-     'description': 'User defined warnings',
-     'patterns': [r".*: warning: .* \[-Wuser-defined-warnings\]$"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Taking address of temporary',
-     'patterns': [r".*: warning: taking address of temporary"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Taking address of packed member',
-     'patterns': [r".*: warning: taking address of packed member"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Possible broken line continuation',
-     'patterns': [r".*: warning: backslash and newline separated by space"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
-     'description': 'Undefined variable template',
-     'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
-    {'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,
-     'description': 'Excess elements in initializer',
-     'patterns': [r".*: warning: excess elements in .+ initializer"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Decimal constant is unsigned only in ISO C90',
-     'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
-     'description': 'main is usually a function',
-     'patterns': [r".*: warning: 'main' is usually a function"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Typedef ignored',
-     'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
-    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
-     'description': 'Address always evaluates to true',
-     'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
-    {'category': 'C/C++', 'severity': Severity.FIXMENOW,
-     'description': 'Freeing a non-heap object',
-     'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
-     'description': 'Array subscript has type char',
-     'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Constant too large for type',
-     'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
-     'description': 'Constant too large for type, truncated',
-     'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
-     'description': 'Overflow in expression',
-     'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
-     'description': 'Overflow in implicit constant conversion',
-     'patterns': [r".*: warning: overflow in implicit constant conversion"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Declaration does not declare anything',
-     'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
-     'description': 'Initialization order will be different',
-     'patterns': [r".*: warning: '.+' will be initialized after",
-                  r".*: warning: field .+ will be initialized after .+Wreorder"]},
-    {'category': 'cont.', 'severity': Severity.SKIP,
-     'description': 'skip,   ....',
-     'patterns': [r".*: warning:   '.+'"]},
-    {'category': 'cont.', 'severity': Severity.SKIP,
-     'description': 'skip,   base ...',
-     'patterns': [r".*: warning:   base '.+'"]},
-    {'category': 'cont.', 'severity': Severity.SKIP,
-     'description': 'skip,   when initialized here',
-     'patterns': [r".*: warning:   when initialized here"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
-     'description': 'Parameter type not specified',
-     'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
-     'description': 'Missing declarations',
-     'patterns': [r".*: warning: declaration does not declare anything"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
-     'description': 'Missing noreturn',
-     'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'User warning',
-     'patterns': [r".*: warning: #warning "".+"""]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
-     'description': 'Vexing parsing problem',
-     'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
-     'description': 'Dereferencing void*',
-     'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Comparison of pointer and integer',
-     'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
-                  r".*: warning: .*comparison between pointer and integer"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Use of error-prone unary operator',
-     'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
-     'description': 'Conversion of string constant to non-const char*',
-     'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
-     'description': 'Function declaration isn''t a prototype',
-     'patterns': [r".*: warning: function declaration isn't a prototype"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
-     'description': 'Type qualifiers ignored on function return value',
-     'patterns': [r".*: warning: type qualifiers ignored on function return type",
-                  r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': '<foo> declared inside parameter list, scope limited to this definition',
-     'patterns': [r".*: warning: '.+' declared inside parameter list"]},
-    {'category': 'cont.', 'severity': Severity.SKIP,
-     'description': 'skip, its scope is only this ...',
-     'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
-     'description': 'Line continuation inside comment',
-     'patterns': [r".*: warning: multi-line comment"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
-     'description': 'Comment inside comment',
-     '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"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
-     'description': 'Deprecated register',
-     'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
-     'description': 'Converts between pointers to integer types with different sign',
-     'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
-    {'category': 'C/C++', 'severity': Severity.HARMLESS,
-     'description': 'Extra tokens after #endif',
-     '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",
-                  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 '.+'",
-                  r".*: warning: conversion to '.+' .+ may (alter|change)"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
-     'description': 'Converting to non-pointer type from NULL',
-     'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-conversion',
-     'description': 'Implicit sign conversion',
-     'patterns': [r".*: warning: implicit conversion changes signedness"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
-     'description': 'Converting NULL to non-pointer type',
-     'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
-     'description': 'Zero used as null pointer',
-     'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-compare',
-     'description': 'Compare pointer to null character',
-     'patterns': [r".*: warning: comparing a pointer to a null character constant"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     '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 '.+'"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
-     'description': 'Class seems unusable because of private ctor/dtor',
-     'patterns': [r".*: warning: all member functions in class '.+' are private"]},
+    medium('Implicit function declaration',
+           [r".*: warning: implicit declaration of function .+",
+            r".*: warning: implicitly declaring library function"]),
+    skip('skip, conflicting types for ...',
+         [r".*: warning: conflicting types for '.+'"]),
+    high('Expression always evaluates to true or false',
+         [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"]),
+    high('Use transient memory for control value',
+         [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]),
+    high('Return address of stack memory',
+         [r".*: warning: Address of stack memory .+ returned to caller",
+          r".*: warning: Address of stack memory .+ will be a dangling reference"]),
+    high('Infinite recursion',
+         [r".*: warning: all paths through this function will call itself"]),
+    high('Potential buffer overflow',
+         [r".*: warning: Size argument is greater than .+ the destination buffer",
+          r".*: warning: Potential buffer overflow.",
+          r".*: warning: String copy function overflows destination buffer"]),
+    medium('Incompatible pointer types',
+           [r".*: warning: assignment from incompatible pointer type",
+            r".*: warning: return from incompatible pointer type",
+            r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
+            r".*: warning: initialization from incompatible pointer type"]),
+    high('Incompatible declaration of built in function',
+         [r".*: warning: incompatible implicit declaration of built-in function .+"]),
+    high('Incompatible redeclaration of library function',
+         [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 parameter',
+           [r".*: warning: unused parameter '.*'"]),
+    medium('Unused function, variable, label, comparison, etc.',
+           [r".*: warning: '.+' defined but not used",
+            r".*: warning: unused function '.+'",
+            r".*: warning: unused label '.+'",
+            r".*: warning: relational comparison result unused",
+            r".*: warning: lambda capture .* is not used",
+            r".*: warning: private field '.+' is not used",
+            r".*: warning: unused variable '.+'"]),
+    medium('Statement with no effect or result unused',
+           [r".*: warning: statement with no effect",
+            r".*: warning: expression result unused"]),
+    medium('Ignoreing return value of function',
+           [r".*: warning: ignoring return value of function .+Wunused-result"]),
+    medium('Missing initializer',
+           [r".*: warning: missing initializer"]),
+    medium('Need virtual destructor',
+           [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]),
+    skip('skip, near initialization for ...',
+         [r".*: warning: \(near initialization for '.+'\)"]),
+    medium('Expansion of data or time macro',
+           [r".*: warning: expansion of date or time macro is not reproducible"]),
+    medium('Macro expansion has undefined behavior',
+           [r".*: warning: macro expansion .* has undefined behavior"]),
+    medium('Format string does not match arguments',
+           [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
+            r".*: warning: more '%' conversions than data arguments",
+            r".*: warning: data argument not used by format string",
+            r".*: warning: incomplete format specifier",
+            r".*: warning: unknown conversion type .* in format",
+            r".*: warning: format .+ expects .+ but argument .+Wformat=",
+            r".*: warning: field precision should have .+ but argument has .+Wformat",
+            r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]),
+    medium('Too many arguments for format string',
+           [r".*: warning: too many arguments for format"]),
+    medium('Too many arguments in call',
+           [r".*: warning: too many arguments in call to "]),
+    medium('Invalid format specifier',
+           [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]),
+    medium('Comparison between signed and unsigned',
+           [r".*: warning: comparison between signed and unsigned",
+            r".*: warning: comparison of promoted \~unsigned with unsigned",
+            r".*: warning: signed and unsigned type in conditional expression"]),
+    medium('Comparison between enum and non-enum',
+           [r".*: warning: enumeral and non-enumeral type in conditional expression"]),
+    medium('libpng: zero area',
+           [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]),
+    medium('Missing braces around initializer',
+           [r".*: warning: missing braces around initializer.*"]),
+    harmless('No newline at end of file',
+             [r".*: warning: no newline at end of file"]),
+    harmless('Missing space after macro name',
+             [r".*: warning: missing whitespace after the macro name"]),
+    low('Cast increases required alignment',
+        [r".*: warning: cast from .* to .* increases required alignment .*"]),
+    medium('Qualifier discarded',
+           [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
+            r".*: warning: assignment discards qualifiers from pointer target type",
+            r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
+            r".*: warning: assigning to .+ from .+ discards qualifiers",
+            r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
+            r".*: warning: return discards qualifiers from pointer target type"]),
+    medium('Unknown attribute',
+           [r".*: warning: unknown attribute '.+'"]),
+    medium('Attribute ignored',
+           [r".*: warning: '_*packed_*' attribute ignored",
+            r".*: warning: attribute declaration must precede definition .+ignored-attributes"]),
+    medium('Visibility problem',
+           [r".*: warning: declaration of '.+' will not be visible outside of this function"]),
+    medium('Visibility mismatch',
+           [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('extern <foo> is initialized',
+           [r".*: warning: '.+' initialized and declared 'extern'",
+            r".*: warning: 'extern' variable has an initializer"]),
+    medium('Old style declaration',
+           [r".*: warning: 'static' is not at beginning of declaration"]),
+    medium('Missing return value',
+           [r".*: warning: control reaches end of non-void function"]),
+    medium('Implicit int type',
+           [r".*: warning: type specifier missing, defaults to 'int'",
+            r".*: warning: type defaults to 'int' in declaration of '.+'"]),
+    medium('Main function should return int',
+           [r".*: warning: return type of 'main' is not 'int'"]),
+    medium('Variable may be used uninitialized',
+           [r".*: warning: '.+' may be used uninitialized in this function"]),
+    high('Variable is used uninitialized',
+         [r".*: warning: '.+' is used uninitialized in this function",
+          r".*: warning: variable '.+' is uninitialized when used here"]),
+    medium('ld: possible enum size mismatch',
+           [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]),
+    medium('Pointer targets differ in signedness',
+           [r".*: warning: pointer targets in initialization differ in signedness",
+            r".*: warning: pointer targets in assignment differ in signedness",
+            r".*: warning: pointer targets in return differ in signedness",
+            r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]),
+    medium('Assuming overflow does not occur',
+           [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]),
+    medium('Suggest adding braces around empty body',
+           [r".*: warning: suggest braces around empty body in an 'if' statement",
+            r".*: warning: empty body in an if-statement",
+            r".*: warning: suggest braces around empty body in an 'else' statement",
+            r".*: warning: empty body in an else-statement"]),
+    medium('Suggest adding parentheses',
+           [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
+            r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
+            r".*: warning: suggest parentheses around comparison in operand of '.+'",
+            r".*: warning: logical not is only applied to the left hand side of this comparison",
+            r".*: warning: using the result of an assignment as a condition without parentheses",
+            r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
+            r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
+            r".*: warning: suggest parentheses around assignment used as truth value"]),
+    medium('Static variable used in non-static inline function',
+           [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]),
+    medium('No type or storage class (will default to int)',
+           [r".*: warning: data definition has no type or storage class"]),
+    skip('skip, parameter name (without types) in function declaration',
+         [r".*: warning: parameter names \(without types\) in function declaration"]),
+    medium('Dereferencing <foo> breaks strict aliasing rules',
+           [r".*: warning: dereferencing .* break strict-aliasing rules"]),
+    medium('Cast from pointer to integer of different size',
+           [r".*: warning: cast from pointer to integer of different size",
+            r".*: warning: initialization makes pointer from integer without a cast"]),
+    medium('Cast to pointer from integer of different size',
+           [r".*: warning: cast to pointer from integer of different size"]),
+    medium('Macro redefined',
+           [r".*: warning: '.+' macro redefined"]),
+    skip('skip, ... location of the previous definition',
+         [r".*: warning: this is the location of the previous definition"]),
+    medium('ld: type and size of dynamic symbol are not defined',
+           [r".*: warning: type and size of dynamic symbol `.+' are not defined"]),
+    medium('Pointer from integer without cast',
+           [r".*: warning: assignment makes pointer from integer without a cast"]),
+    medium('Pointer from integer without cast',
+           [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]),
+    medium('Integer from pointer without cast',
+           [r".*: warning: assignment makes integer from pointer without a cast"]),
+    medium('Integer from pointer without cast',
+           [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]),
+    medium('Integer from pointer without cast',
+           [r".*: warning: return makes integer from pointer without a cast"]),
+    medium('Ignoring pragma',
+           [r".*: warning: ignoring #pragma .+"]),
+    medium('Pragma warning messages',
+           [r".*: warning: .+W#pragma-messages"]),
+    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',
+           [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]),
+    medium('Redundant declaration',
+           [r".*: warning: redundant redeclaration of '.+'"]),
+    skip('skip, previous declaration ... was here',
+         [r".*: warning: previous declaration of '.+' was here"]),
+    high('Enum value not handled in switch',
+         [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]),
+    medium('User defined warnings',
+           [r".*: warning: .* \[-Wuser-defined-warnings\]$"]),
+    medium('Taking address of temporary',
+           [r".*: warning: taking address of temporary"]),
+    medium('Taking address of packed member',
+           [r".*: warning: taking address of packed member"]),
+    medium('Possible broken line continuation',
+           [r".*: warning: backslash and newline separated by space"]),
+    medium('Undefined variable template',
+           [r".*: warning: instantiation of variable .* no definition is available"]),
+    medium('Inline function is not defined',
+           [r".*: warning: inline function '.*' is not defined"]),
+    medium('Excess elements in initializer',
+           [r".*: warning: excess elements in .+ initializer"]),
+    medium('Decimal constant is unsigned only in ISO C90',
+           [r".*: warning: this decimal constant is unsigned only in ISO C90"]),
+    medium('main is usually a function',
+           [r".*: warning: 'main' is usually a function"]),
+    medium('Typedef ignored',
+           [r".*: warning: 'typedef' was ignored in this declaration"]),
+    high('Address always evaluates to true',
+         [r".*: warning: the address of '.+' will always evaluate as 'true'"]),
+    fixmenow('Freeing a non-heap object',
+             [r".*: warning: attempt to free a non-heap object '.+'"]),
+    medium('Array subscript has type char',
+           [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]),
+    medium('Constant too large for type',
+           [r".*: warning: integer constant is too large for '.+' type"]),
+    medium('Constant too large for type, truncated',
+           [r".*: warning: large integer implicitly truncated to unsigned type"]),
+    medium('Overflow in expression',
+           [r".*: warning: overflow in expression; .*Winteger-overflow"]),
+    medium('Overflow in implicit constant conversion',
+           [r".*: warning: overflow in implicit constant conversion"]),
+    medium('Declaration does not declare anything',
+           [r".*: warning: declaration 'class .+' does not declare anything"]),
+    medium('Initialization order will be different',
+           [r".*: warning: '.+' will be initialized after",
+            r".*: warning: field .+ will be initialized after .+Wreorder"]),
+    skip('skip,   ....',
+         [r".*: warning:   '.+'"]),
+    skip('skip,   base ...',
+         [r".*: warning:   base '.+'"]),
+    skip('skip,   when initialized here',
+         [r".*: warning:   when initialized here"]),
+    medium('Parameter type not specified',
+           [r".*: warning: type of '.+' defaults to 'int'"]),
+    medium('Missing declarations',
+           [r".*: warning: declaration does not declare anything"]),
+    medium('Missing noreturn',
+           [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]),
+    medium('User warning',
+           [r".*: warning: #warning "".+"""]),
+    medium('Vexing parsing problem',
+           [r".*: warning: empty parentheses interpreted as a function declaration"]),
+    medium('Dereferencing void*',
+           [r".*: warning: dereferencing 'void \*' pointer"]),
+    medium('Comparison of pointer and integer',
+           [r".*: warning: ordered comparison of pointer with integer zero",
+            r".*: warning: .*comparison between pointer and integer"]),
+    medium('Use of error-prone unary operator',
+           [r".*: warning: use of unary operator that may be intended as compound assignment"]),
+    medium('Conversion of string constant to non-const char*',
+           [r".*: warning: deprecated conversion from string constant to '.+'"]),
+    medium('Function declaration isn''t a prototype',
+           [r".*: warning: function declaration isn't a prototype"]),
+    medium('Type qualifiers ignored on function return value',
+           [r".*: warning: type qualifiers ignored on function return type",
+            r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]),
+    medium('<foo> declared inside parameter list, scope limited to this definition',
+           [r".*: warning: '.+' declared inside parameter list"]),
+    skip('skip, its scope is only this ...',
+         [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]),
+    low('Line continuation inside comment',
+        [r".*: warning: multi-line comment"]),
+    low('Comment inside comment',
+        [r".*: warning: '.+' within block comment .*-Wcomment"]),
+    low('Deprecated declarations',
+        [r".*: warning: .+ is deprecated.+deprecated-declarations"]),
+    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"]),
+    harmless('Extra tokens after #endif',
+             [r".*: warning: extra tokens at end of #endif directive"]),
+    medium('Comparison between different enums',
+           [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare",
+            r".*: warning: comparison of .* enumeration types .*-Wenum-compare-switch"]),
+    medium('Conversion may change value',
+           [r".*: warning: converting negative value '.+' to '.+'",
+            r".*: warning: conversion to '.+' .+ may (alter|change)"]),
+    medium('Converting to non-pointer type from NULL',
+           [r".*: warning: converting to non-pointer type '.+' from NULL"]),
+    medium('Implicit sign conversion',
+           [r".*: warning: implicit conversion changes signedness"]),
+    medium('Converting NULL to non-pointer type',
+           [r".*: warning: implicit conversion of NULL constant to '.+'"]),
+    medium('Zero used as null pointer',
+           [r".*: warning: expression .* zero treated as a null pointer constant"]),
+    medium('Compare pointer to null character',
+           [r".*: warning: comparing a pointer to a null character constant"]),
+    medium('Implicit conversion changes value or loses precision',
+           [r".*: warning: implicit conversion .* changes value from .* to .*-conversion",
+            r".*: warning: implicit conversion loses integer precision:"]),
+    medium('Passing NULL as non-pointer argument',
+           [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]),
+    medium('Class seems unusable because of private ctor/dtor',
+           [r".*: warning: all member functions in class '.+' are private"]),
     # skip this next one, because it only points out some RefBase-based classes
     # where having a private destructor is perfectly fine
-    {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
-     'description': 'Class seems unusable because of private ctor/dtor',
-     'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
-     'description': 'Class seems unusable because of private ctor/dtor',
-     'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
-     'description': 'In-class initializer for static const float/double',
-     'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
-     'description': 'void* used in arithmetic',
-     'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
-                  r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
-                  r".*: warning: wrong type argument to increment"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
-     'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
-     'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
-    {'category': 'cont.', 'severity': Severity.SKIP,
-     'description': 'skip,   in call to ...',
-     'patterns': [r".*: warning:   in call to '.+'"]},
-    {'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': 'Return value from void function',
-     'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
-     'description': 'Multi-character character constant',
-     'patterns': [r".*: warning: multi-character character constant"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
-     'description': 'Conversion from string literal to char*',
-     'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
-     'description': 'Extra \';\'',
-     'patterns': [r".*: warning: extra ';' .+extra-semi"]},
-    {'category': 'C/C++', 'severity': Severity.LOW,
-     'description': 'Useless specifier',
-     'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
-     'description': 'Duplicate declaration specifier',
-     'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
-     'description': 'Comparison of self is always false',
-     'patterns': [r".*: self-comparison always evaluates to false"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
-     'description': 'Logical op with constant operand',
-     'patterns': [r".*: use of logical '.+' with constant operand"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
-     'description': 'Needs a space between literal and string macro',
-     'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
-     'description': 'Warnings from #warning',
-     'patterns': [r".*: warning: .+-W#warnings"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
-     'description': 'Using float/int absolute value function with int/float argument',
-     'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
-                  r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
-     'description': 'Using C++11 extensions',
-     'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
-    {'category': 'C/C++', 'severity': Severity.LOW,
-     'description': 'Refers to implicitly defined namespace',
-     'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
-    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
-     'description': 'Invalid pp token',
-     'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
-    {'category': 'link', 'severity': Severity.LOW,
-     'description': 'need glibc to link',
-     'patterns': [r".*: warning: .* requires at runtime .* glibc .* for linking"]},
-
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Operator new returns NULL',
-     'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
-     'description': 'NULL used in arithmetic',
-     'patterns': [r".*: warning: NULL used in arithmetic",
-                  r".*: warning: comparison between NULL and non-pointer"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
-     'description': 'Misspelled header guard',
-     'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
-     'description': 'Empty loop body',
-     'patterns': [r".*: warning: .+ loop has empty body"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
-     'description': 'Implicit conversion from enumeration type',
-     'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
-    {'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': '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: .+ uninitialized .+\[-Wsometimes-uninitialized\]"]},
-    {'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"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
-     'description': 'Bad argument size of memory access functions',
-     'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Return value not checked',
-     'patterns': [r".*: warning: The return value from .+ is not checked"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Possible heap pollution',
-     'patterns': [r".*: warning: .*Possible heap pollution from .+ 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"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM,
-     'description': 'Closing a previously closed file',
-     'patterns': [r".*: warning: Closing a previously closed file"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
-     'description': 'Unnamed template type argument',
-     'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
-    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-fallthrough',
-     'description': 'Unannotated fall-through between switch labels',
-     'patterns': [r".*: warning: unannotated fall-through between switch labels.+Wimplicit-fallthrough"]},
-    {'category': 'C/C++', 'severity': Severity.HARMLESS,
-     'description': 'Discarded qualifier from pointer target type',
-     'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
-    {'category': 'C/C++', 'severity': Severity.HARMLESS,
-     'description': 'Use snprintf instead of sprintf',
-     'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
-    {'category': 'C/C++', 'severity': Severity.HARMLESS,
-     'description': 'Unsupported optimizaton flag',
-     'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
-    {'category': 'C/C++', 'severity': Severity.HARMLESS,
-     'description': 'Extra or missing parentheses',
-     'patterns': [r".*: warning: equality comparison with extraneous parentheses",
-                  r".*: warning: .+ within .+Wlogical-op-parentheses"]},
-    {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
-     'description': 'Mismatched class vs struct tags',
-     'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
-                  r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
+    skip('Class seems unusable because of private ctor/dtor',
+         [r".*: warning: 'class .+' only defines a private destructor and has no friends"]),
+    medium('Class seems unusable because of private ctor/dtor',
+           [r".*: warning: 'class .+' only defines private constructors and has no friends"]),
+    medium('In-class initializer for static const float/double',
+           [r".*: warning: in-class initializer for static data member of .+const (float|double)"]),
+    medium('void* used in arithmetic',
+           [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
+            r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
+            r".*: warning: wrong type argument to increment"]),
+    medium('Overload resolution chose to promote from unsigned or enum to signed type',
+           [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]),
+    skip('skip,   in call to ...',
+         [r".*: warning:   in call to '.+'"]),
+    high('Base should be explicitly initialized in copy constructor',
+         [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]),
+    medium('Return value from void function',
+           [r".*: warning: 'return' with a value, in function returning void"]),
+    medium('Multi-character character constant',
+           [r".*: warning: multi-character character constant"]),
+    medium('Conversion from string literal to char*',
+           [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]),
+    low('Extra \';\'',
+        [r".*: warning: extra ';' .+extra-semi"]),
+    low('Useless specifier',
+        [r".*: warning: useless storage class specifier in empty declaration"]),
+    low('Duplicate declaration specifier',
+        [r".*: warning: duplicate '.+' declaration specifier"]),
+    low('Comparison of self is always false',
+        [r".*: self-comparison always evaluates to false"]),
+    low('Logical op with constant operand',
+        [r".*: use of logical '.+' with constant operand"]),
+    low('Needs a space between literal and string macro',
+        [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]),
+    low('Warnings from #warning',
+        [r".*: warning: .+-W#warnings"]),
+    low('Using float/int absolute value function with int/float argument',
+        [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
+         r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]),
+    low('Using C++11 extensions',
+        [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]),
+    low('Refers to implicitly defined namespace',
+        [r".*: warning: using directive refers to implicitly-defined namespace .+"]),
+    low('Invalid pp token',
+        [r".*: warning: missing .+Winvalid-pp-token"]),
+    low('need glibc to link',
+        [r".*: warning: .* requires at runtime .* glibc .* for linking"]),
+    medium('Operator new returns NULL',
+           [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]),
+    medium('NULL used in arithmetic',
+           [r".*: warning: NULL used in arithmetic",
+            r".*: warning: comparison between NULL and non-pointer"]),
+    medium('Misspelled header guard',
+           [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]),
+    medium('Empty loop body',
+           [r".*: warning: .+ loop has empty body"]),
+    medium('Implicit conversion from enumeration type',
+           [r".*: warning: implicit conversion from enumeration type '.+'"]),
+    medium('case value not in enumerated type',
+           [r".*: warning: case value not in enumerated type '.+'"]),
+    medium('Use of deprecated method',
+           [r".*: warning: '.+' is deprecated .+"]),
+    medium('Use of garbage or uninitialized value',
+           [r".*: warning: .+ uninitialized .+\[-Wsometimes-uninitialized\]"]),
+    medium('Sizeof on array argument',
+           [r".*: warning: sizeof on array function parameter will return"]),
+    medium('Bad argument size of memory access functions',
+           [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]),
+    medium('Return value not checked',
+           [r".*: warning: The return value from .+ is not checked"]),
+    medium('Possible heap pollution',
+           [r".*: warning: .*Possible heap pollution from .+ type .+"]),
+    medium('Variable used in loop condition not modified in loop body',
+           [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]),
+    medium('Closing a previously closed file',
+           [r".*: warning: Closing a previously closed file"]),
+    medium('Unnamed template type argument',
+           [r".*: warning: template argument.+Wunnamed-type-template-args"]),
+    medium('Unannotated fall-through between switch labels',
+           [r".*: warning: unannotated fall-through between switch labels.+Wimplicit-fallthrough"]),
+    harmless('Discarded qualifier from pointer target type',
+             [r".*: warning: .+ discards '.+' qualifier from pointer target type"]),
+    harmless('Use snprintf instead of sprintf',
+             [r".*: warning: .*sprintf is often misused; please use snprintf"]),
+    harmless('Unsupported optimizaton flag',
+             [r".*: warning: optimization flag '.+' is not supported"]),
+    harmless('Extra or missing parentheses',
+             [r".*: warning: equality comparison with extraneous parentheses",
+              r".*: warning: .+ within .+Wlogical-op-parentheses"]),
+    harmless('Mismatched class vs struct tags',
+             [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
+              r".*: warning: .+ was previously declared as a .+mismatched-tags"]),
 ]
 
 
diff --git a/tools/warn/java_warn_patterns.py b/tools/warn/java_warn_patterns.py
index 3a3a676..0a443d4 100644
--- a/tools/warn/java_warn_patterns.py
+++ b/tools/warn/java_warn_patterns.py
@@ -93,6 +93,8 @@
              [r".*: warning: \[MultipleTopLevelClasses\] .+"]),
     java_low('Avoid having multiple unary operators acting on the same variable in a method call',
              [r".*: warning: \[MultipleUnaryOperatorsInMethodCall\] .+"]),
+    java_low('OnNameExpected naming style',
+             [r".*\.java:.*: warning: .+ \[OnNameExpected\]$"]),
     java_low('Package names should match the directory they are declared in',
              [r".*: warning: \[PackageLocation\] .+"]),
     java_low('Non-standard parameter comment; prefer `/* paramName= */ arg`',
diff --git a/tools/warn/other_warn_patterns.py b/tools/warn/other_warn_patterns.py
index 1331bc6..19a4e38 100644
--- a/tools/warn/other_warn_patterns.py
+++ b/tools/warn/other_warn_patterns.py
@@ -46,6 +46,10 @@
   return warn('Kotlin', Severity.MEDIUM, description, pattern_list)
 
 
+def yacc(description, pattern_list):
+  return warn('yacc', Severity.MEDIUM, description, pattern_list)
+
+
 warn_patterns = [
     # pylint:disable=line-too-long,g-inconsistent-quotes
     # aapt warnings
@@ -115,6 +119,14 @@
     kotlin('library has Kotlin runtime',
            [r".*: warning: library has Kotlin runtime bundled into it",
             r".*: warning: some JAR files .* have the Kotlin Runtime library"]),
+    # Yacc warnings
+    yacc('deprecate directive',
+         [r".*\.yy?:.*: warning: deprecated directive: "]),
+    yacc('shift/reduce conflicts',
+         [r".*\.yy?: warning: .+ shift/reduce conflicts "]),
+    {'category': 'yacc', 'severity': Severity.SKIP,
+     'description': 'yacc: fix-its can be applied',
+     'patterns': [r".*\.yy?: warning: fix-its can be applied."]},
     # Rust warnings
     {'category': 'Rust', 'severity': Severity.HIGH,
      'description': 'Rust: Does not derive Copy',
diff --git a/tools/warn/warn_common.py b/tools/warn/warn_common.py
index 9f392ed..0c9d9ef 100755
--- a/tools/warn/warn_common.py
+++ b/tools/warn/warn_common.py
@@ -28,7 +28,6 @@
 #   warn_patterns[w]['category']     tool that issued the warning, not used now
 #   warn_patterns[w]['description']  table heading
 #   warn_patterns[w]['members']      matched warnings from input
-#   warn_patterns[w]['option']       compiler flag to control the warning
 #   warn_patterns[w]['patterns']     regular expressions to match warnings
 #   warn_patterns[w]['projects'][p]  number of warnings of pattern w in p
 #   warn_patterns[w]['severity']     severity tuple
@@ -70,7 +69,6 @@
 #   ProjectNames:          project_names, or project_list[*][0]
 #   WarnPatternsSeverity:     warn_patterns[*]['severity']
 #   WarnPatternsDescription:  warn_patterns[*]['description']
-#   WarnPatternsOption:       warn_patterns[*]['option']
 #   WarningMessages:          warning_messages
 #   Warnings:                 warning_records
 #   StatsHeader:           warning count table header row
@@ -148,8 +146,6 @@
   project_patterns = [re.compile(p[1]) for p in project_list]
   for w in warn_patterns:
     w['members'] = []
-    if 'option' not in w:
-      w['option'] = ''
     # Each warning pattern has a 'projects' dictionary, that
     # maps a project name to number of warnings in that project.
     w['projects'] = {}
@@ -203,22 +199,30 @@
 """
 
 
+def make_writer(output_stream):
+
+  def writer(text):
+    return output_stream.write(text + '\n')
+
+  return writer
+
+
 def html_big(param):
   return '<font size="+2">' + param + '</font>'
 
 
-def dump_html_prologue(title):
-  print('<html>\n<head>')
-  print('<title>' + title + '</title>')
-  print(html_head_scripts)
-  emit_stats_by_project()
-  print('</head>\n<body>')
-  print(html_big(title))
-  print('<p>')
+def dump_html_prologue(title, writer):
+  writer('<html>\n<head>')
+  writer('<title>' + title + '</title>')
+  writer(html_head_scripts)
+  emit_stats_by_project(writer)
+  writer('</head>\n<body>')
+  writer(html_big(title))
+  writer('<p>')
 
 
-def dump_html_epilogue():
-  print('</body>\n</head>\n</html>')
+def dump_html_epilogue(writer):
+  writer('</body>\n</head>\n</html>')
 
 
 def sort_warnings():
@@ -226,7 +230,7 @@
     i['members'] = sorted(set(i['members']))
 
 
-def emit_stats_by_project():
+def emit_stats_by_project(writer):
   """Dump a google chart table of warnings per project and severity."""
   # warnings[p][s] is number of warnings in project p of severity s.
   # pylint:disable=g-complex-comprehension
@@ -281,14 +285,14 @@
       total_all_severities += total_by_severity[s.value]
   one_row.append(total_all_projects)
   stats_rows.append(one_row)
-  print('<script>')
-  emit_const_string_array('StatsHeader', stats_header)
-  emit_const_object_array('StatsRows', stats_rows)
-  print(draw_table_javascript)
-  print('</script>')
+  writer('<script>')
+  emit_const_string_array('StatsHeader', stats_header, writer)
+  emit_const_object_array('StatsRows', stats_rows, writer)
+  writer(draw_table_javascript)
+  writer('</script>')
 
 
-def dump_stats():
+def dump_stats(writer):
   """Dump some stats about total number of warnings and such."""
   known = 0
   skipped = 0
@@ -301,14 +305,14 @@
       skipped += len(i['members'])
     else:
       known += len(i['members'])
-  print('Number of classified warnings: <b>' + str(known) + '</b><br>')
-  print('Number of skipped warnings: <b>' + str(skipped) + '</b><br>')
-  print('Number of unclassified warnings: <b>' + str(unknown) + '</b><br>')
+  writer('Number of classified warnings: <b>' + str(known) + '</b><br>')
+  writer('Number of skipped warnings: <b>' + str(skipped) + '</b><br>')
+  writer('Number of unclassified warnings: <b>' + str(unknown) + '</b><br>')
   total = unknown + known + skipped
   extra_msg = ''
   if total < 1000:
     extra_msg = ' (low count may indicate incremental build)'
-  print('Total number of warnings: <b>' + str(total) + '</b>' + extra_msg)
+  writer('Total number of warnings: <b>' + str(total) + '</b>' + extra_msg)
 
 
 # New base table of warnings, [severity, warn_id, project, warning_message]
@@ -321,15 +325,15 @@
 # (3) New, group by project + severity,
 #     id for each warning pattern
 #     sort by project, severity, warn_id, warning_message
-def emit_buttons():
-  print('<button class="button" onclick="expandCollapse(1);">'
-        'Expand all warnings</button>\n'
-        '<button class="button" onclick="expandCollapse(0);">'
-        'Collapse all warnings</button>\n'
-        '<button class="button" onclick="groupBySeverity();">'
-        'Group warnings by severity</button>\n'
-        '<button class="button" onclick="groupByProject();">'
-        'Group warnings by project</button><br>')
+def emit_buttons(writer):
+  writer('<button class="button" onclick="expandCollapse(1);">'
+         'Expand all warnings</button>\n'
+         '<button class="button" onclick="expandCollapse(0);">'
+         'Collapse all warnings</button>\n'
+         '<button class="button" onclick="groupBySeverity();">'
+         'Group warnings by severity</button>\n'
+         '<button class="button" onclick="groupByProject();">'
+         'Group warnings by project</button><br>')
 
 
 def all_patterns(category):
@@ -340,35 +344,32 @@
   return patterns
 
 
-def dump_fixed():
+def dump_fixed(writer):
   """Show which warnings no longer occur."""
   anchor = 'fixed_warnings'
   mark = anchor + '_mark'
-  print('\n<br><p style="background-color:lightblue"><b>'
-        '<button id="' + mark + '" '
-        'class="bt" onclick="expand(\'' + anchor + '\');">'
-        '&#x2295</button> Fixed warnings. '
-        'No more occurrences. Please consider turning these into '
-        'errors if possible, before they are reintroduced in to the build'
-        ':</b></p>')
-  print('<blockquote>')
+  writer('\n<br><p style="background-color:lightblue"><b>'
+         '<button id="' + mark + '" '
+         'class="bt" onclick="expand(\'' + anchor + '\');">'
+         '&#x2295</button> Fixed warnings. '
+         'No more occurrences. Please consider turning these into '
+         'errors if possible, before they are reintroduced in to the build'
+         ':</b></p>')
+  writer('<blockquote>')
   fixed_patterns = []
   for i in warn_patterns:
     if not i['members']:
-      fixed_patterns.append(i['description'] + ' (' +
-                            all_patterns(i) + ')')
-    if i['option']:
-      fixed_patterns.append(' ' + i['option'])
+      fixed_patterns.append(i['description'] + ' (' + all_patterns(i) + ')')
   fixed_patterns = sorted(fixed_patterns)
-  print('<div id="' + anchor + '" style="display:none;"><table>')
+  writer('<div id="' + anchor + '" style="display:none;"><table>')
   cur_row_class = 0
   for text in fixed_patterns:
     cur_row_class = 1 - cur_row_class
     # remove last '\n'
     t = text[:-1] if text[-1] == '\n' else text
-    print('<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>')
-  print('</table></div>')
-  print('</blockquote>')
+    writer('<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>')
+  writer('</table></div>')
+  writer('</blockquote>')
 
 
 def find_project_index(line):
@@ -546,6 +547,7 @@
       prev_warning = 'unknown_source_file: ' + prev_warning
       warning_lines.add(normalize_warning_line(prev_warning))
       prev_warning = ''
+
     if warning_pattern.match(line):
       if warning_without_file.match(line):
         # save this line and combine it with the next line
@@ -553,6 +555,7 @@
       else:
         warning_lines.add(normalize_warning_line(line))
       continue
+
     if line_counter < 100:
       # save a little bit of time by only doing this for the first few lines
       line_counter += 1
@@ -586,22 +589,22 @@
   return escape_string(s)
 
 
-def emit_warning_array(name):
-  print('var warning_{} = ['.format(name))
+def emit_warning_array(name, writer):
+  writer('var warning_{} = ['.format(name))
   for i in range(len(warn_patterns)):
-    print('{},'.format(warn_patterns[i][name]))
-  print('];')
+    writer('{},'.format(warn_patterns[i][name]))
+  writer('];')
 
 
-def emit_warning_arrays():
-  emit_warning_array('severity')
-  print('var warning_description = [')
+def emit_warning_arrays(writer):
+  emit_warning_array('severity', writer)
+  writer('var warning_description = [')
   for i in range(len(warn_patterns)):
     if warn_patterns[i]['members']:
-      print('"{}",'.format(escape_string(warn_patterns[i]['description'])))
+      writer('"{}",'.format(escape_string(warn_patterns[i]['description'])))
     else:
-      print('"",')  # no such warning
-  print('];')
+      writer('"",')  # no such warning
+  writer('];')
 
 
 scripts_for_warning_groups = """
@@ -707,7 +710,8 @@
     var result = "";
     var groups = groupWarningsBySeverity();
     for (s=0; s<SeverityColors.length; s++) {
-      result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
+      result += createWarningSection(SeverityHeaders[s], SeverityColors[s],
+                                     groups[s]);
     }
     return result;
   }
@@ -734,65 +738,67 @@
 
 
 # Emit a JavaScript const string
-def emit_const_string(name, value):
-  print('const ' + name + ' = "' + escape_string(value) + '";')
+def emit_const_string(name, value, writer):
+  writer('const ' + name + ' = "' + escape_string(value) + '";')
 
 
 # Emit a JavaScript const integer array.
-def emit_const_int_array(name, array):
-  print('const ' + name + ' = [')
+def emit_const_int_array(name, array, writer):
+  writer('const ' + name + ' = [')
   for n in array:
-    print(str(n) + ',')
-  print('];')
+    writer(str(n) + ',')
+  writer('];')
 
 
 # Emit a JavaScript const string array.
-def emit_const_string_array(name, array):
-  print('const ' + name + ' = [')
+def emit_const_string_array(name, array, writer):
+  writer('const ' + name + ' = [')
   for s in array:
-    print('"' + strip_escape_string(s) + '",')
-  print('];')
+    writer('"' + strip_escape_string(s) + '",')
+  writer('];')
 
 
 # Emit a JavaScript const string array for HTML.
-def emit_const_html_string_array(name, array):
-  print('const ' + name + ' = [')
+def emit_const_html_string_array(name, array, writer):
+  writer('const ' + name + ' = [')
   for s in array:
     # Not using html.escape yet, to work for both python 2 and 3,
     # until all users switch to python 3.
     # pylint:disable=deprecated-method
-    print('"' + cgi.escape(strip_escape_string(s)) + '",')
-  print('];')
+    writer('"' + cgi.escape(strip_escape_string(s)) + '",')
+  writer('];')
 
 
 # Emit a JavaScript const object array.
-def emit_const_object_array(name, array):
-  print('const ' + name + ' = [')
+def emit_const_object_array(name, array, writer):
+  writer('const ' + name + ' = [')
   for x in array:
-    print(str(x) + ',')
-  print('];')
+    writer(str(x) + ',')
+  writer('];')
 
 
-def emit_js_data():
+def emit_js_data(writer):
   """Dump dynamic HTML page's static JavaScript data."""
-  emit_const_string('FlagURL', args.url if args.url else '')
-  emit_const_string('FlagSeparator', args.separator if args.separator else '')
-  emit_const_string_array('SeverityColors', [s.color for s in Severity.levels])
+  emit_const_string('FlagURL',
+                    args.url if args.url else '', writer)
+  emit_const_string('FlagSeparator',
+                    args.separator if args.separator else '', writer)
+  emit_const_string_array('SeverityColors',
+                          [s.color for s in Severity.levels], writer)
   emit_const_string_array('SeverityHeaders',
-                          [s.header for s in Severity.levels])
+                          [s.header for s in Severity.levels], writer)
   emit_const_string_array('SeverityColumnHeaders',
-                          [s.column_header for s in Severity.levels])
-  emit_const_string_array('ProjectNames', project_names)
+                          [s.column_header for s in Severity.levels], writer)
+  emit_const_string_array('ProjectNames', project_names, writer)
   # pytype: disable=attribute-error
   emit_const_int_array('WarnPatternsSeverity',
-                       [w['severity'].value for w in warn_patterns])
+                       [w['severity'].value for w in warn_patterns], writer)
   # pytype: enable=attribute-error
   emit_const_html_string_array('WarnPatternsDescription',
-                               [w['description'] for w in warn_patterns])
-  emit_const_html_string_array('WarnPatternsOption',
-                               [w['option'] for w in warn_patterns])
-  emit_const_html_string_array('WarningMessages', warning_messages)
-  emit_const_object_array('Warnings', warning_records)
+                               [w['description'] for w in warn_patterns],
+                               writer)
+  emit_const_html_string_array('WarningMessages', warning_messages, writer)
+  emit_const_object_array('Warnings', warning_records, writer)
 
 draw_table_javascript = """
 google.charts.load('current', {'packages':['table']});
@@ -809,31 +815,33 @@
       data.setProperty(i, j, 'style', 'border:1px solid black;');
     }
   }
-  var table = new google.visualization.Table(document.getElementById('stats_table'));
+  var table = new google.visualization.Table(
+      document.getElementById('stats_table'));
   table.draw(data, {allowHtml: true, alternatingRowStyle: true});
 }
 """
 
 
-def dump_html():
-  """Dump the html output to stdout."""
+def dump_html(output_stream):
+  """Dump the html output to output_stream."""
+  writer = make_writer(output_stream)
   dump_html_prologue('Warnings for ' + platform_version + ' - ' +
-                     target_product + ' - ' + target_variant)
-  dump_stats()
-  print('<br><div id="stats_table"></div><br>')
-  print('\n<script>')
-  emit_js_data()
-  print(scripts_for_warning_groups)
-  print('</script>')
-  emit_buttons()
+                     target_product + ' - ' + target_variant, writer)
+  dump_stats(writer)
+  writer('<br><div id="stats_table"></div><br>')
+  writer('\n<script>')
+  emit_js_data(writer)
+  writer(scripts_for_warning_groups)
+  writer('</script>')
+  emit_buttons(writer)
   # Warning messages are grouped by severities or project names.
-  print('<br><div id="warning_groups"></div>')
+  writer('<br><div id="warning_groups"></div>')
   if args.byproject:
-    print('<script>groupByProject();</script>')
+    writer('<script>groupByProject();</script>')
   else:
-    print('<script>groupBySeverity();</script>')
-  dump_fixed()
-  dump_html_epilogue()
+    writer('<script>groupBySeverity();</script>')
+  dump_fixed(writer)
+  dump_html_epilogue(writer)
 
 
 ##### Functions to count warnings and dump csv file. #########################
@@ -892,4 +900,4 @@
   if args.gencsv:
     dump_csv(csv.writer(sys.stdout, lineterminator='\n'))
   else:
-    dump_html()
+    dump_html(sys.stdout)