Use new Severity class and update *_warn_patterns

* This new class definition and patterns are
  shared between Android and ChromeOS compiler tools.
* Suppress hard to fix and false positive linter warnings.

Test: warn.py --url=http://cs/android --separator='?l=' build.log > warnings.html
Test: warn.py --gencsv build.log > warnings.csv
Change-Id: Icb47809100ad30796cb1da82610e989d450194fa
diff --git a/tools/warn/severity.py b/tools/warn/severity.py
index bb23f2c..b1c38e4 100644
--- a/tools/warn/severity.py
+++ b/tools/warn/severity.py
@@ -1,4 +1,4 @@
-#
+# python3
 # Copyright (C) 2019 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,35 +13,45 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""Severity levels and attributes."""
+"""Clang_Tidy_Warn Severity class definition.
+
+This file stores definition for class Severity that is used in warn_patterns.
+"""
 
 
-class Severity(object):
-  """Severity levels and attributes."""
-  # numbered by dump order
-  FIXMENOW = 0
-  HIGH = 1
-  MEDIUM = 2
-  LOW = 3
-  ANALYZER = 4
-  TIDY = 5
-  HARMLESS = 6
-  UNKNOWN = 7
-  SKIP = 8
-  range = range(SKIP + 1)
-  attributes = [
-      # pylint:disable=bad-whitespace
-      ['fuchsia',   'FixNow',    'Critical warnings, fix me now'],
-      ['red',       'High',      'High severity warnings'],
-      ['orange',    'Medium',    'Medium severity warnings'],
-      ['yellow',    'Low',       'Low severity warnings'],
-      ['hotpink',   'Analyzer',  'Clang-Analyzer warnings'],
-      ['peachpuff', 'Tidy',      'Clang-Tidy warnings'],
-      ['limegreen', 'Harmless',  'Harmless warnings'],
-      ['lightblue', 'Unknown',   'Unknown warnings'],
-      ['grey',      'Unhandled', 'Unhandled warnings']
+# pylint:disable=old-style-class
+class Severity:
+  """Class of Severity levels where each level is a SeverityInfo."""
+
+  class SeverityInfo:
+
+    def __init__(self, value, color, column_header, header):
+      self.value = value
+      self.color = color
+      self.column_header = column_header
+      self.header = header
+
+  # SEVERITY_UNKNOWN should never occur since every warn_pattern listed has
+  # a specified severity. It exists for protobuf, the other values must
+  # map to non-zero values (since 0 is reserved for a default UNKNOWN), but
+  # logic in clang_tidy_warn.py assumes severity level values are consecutive
+  # ints starting with 0.
+  SEVERITY_UNKNOWN = SeverityInfo(0, 'blueviolet', 'Errors of unknown severity',
+                                  'Unknown severity (should not occur)')
+  FIXMENOW = SeverityInfo(1, 'fuschia', 'FixNow',
+                          'Critical warnings, fix me now')
+  HIGH = SeverityInfo(2, 'red', 'High', 'High severity warnings')
+  MEDIUM = SeverityInfo(3, 'orange', 'Medium', 'Medium severity warnings')
+  LOW = SeverityInfo(4, 'yellow', 'Low', 'Low severity warnings')
+  ANALYZER = SeverityInfo(5, 'hotpink', 'Analyzer', 'Clang-Analyzer warnings')
+  TIDY = SeverityInfo(6, 'peachpuff', 'Tidy', 'Clang-Tidy warnings')
+  HARMLESS = SeverityInfo(7, 'limegreen', 'Harmless', 'Harmless warnings')
+  UNMATCHED = SeverityInfo(8, 'lightblue', 'Unmatched', 'Unmatched warnings')
+  SKIP = SeverityInfo(9, 'grey', 'Unhandled', 'Unhandled warnings')
+
+  levels = [
+      SEVERITY_UNKNOWN, FIXMENOW, HIGH, MEDIUM, LOW, ANALYZER, TIDY, HARMLESS,
+      UNMATCHED, SKIP
   ]
-  colors = [a[0] for a in attributes]
-  column_headers = [a[1] for a in attributes]
-  headers = [a[2] for a in attributes]
-
+  # HTML relies on ordering by value. Sort here to ensure that this is proper
+  levels = sorted(levels, key=lambda severity: severity.value)