Recognize new clang-tidy and Java warnings.

Test: run warn.py with build.log
Change-Id: I11ff844bcfd7fb13aef8909307bc7eb1f5ee9b2a
diff --git a/tools/warn.py b/tools/warn.py
index 3a8ae66..ce78d5d 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -128,6 +128,9 @@
     { 'category':'C/C++',   'severity':severity.HIGH,     'members':[], '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,     'members':[], 'option':'-Wincompatible-library-redeclaration',
+        'description':'Incompatible redeclaration of library function',
+        'patterns':[r".*: warning: incompatible redeclaration of library function .+"] },
     { 'category':'C/C++',   'severity':severity.HIGH,     'members':[], 'option':'',
         'description':'Null passed as non-null argument',
         'patterns':[r".*: warning: Null passed to a callee that requires a non-null"] },
@@ -362,6 +365,9 @@
     { 'category':'java',    'severity':severity.MEDIUM,   'members':[], 'option':'',
         'description':'Java: Unchecked conversion',
         'patterns':[r".*: warning: \[unchecked\] unchecked conversion"] },
+    { 'category':'java',   'severity':severity.MEDIUM,     'members':[], 'option':'',
+        'description':'_ used as an identifier',
+        'patterns':[r".*: warning: '_' used as an identifier"] },
 
     # Warnings from Error Prone.
     {'category': 'java',
@@ -1487,6 +1493,10 @@
     { 'category':'C/C++',   'severity':severity.LOW,      'members':[], 'option':'-Wcomment',
         'description':'Comment inside comment',
         'patterns':[r".*: warning: "".+"" within comment"] },
+    # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
+    { 'category':'C/C++',   'severity':severity.TIDY,      'members':[], 'option':'',
+        'description':'clang-tidy Value stored is never read',
+        'patterns':[r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"] },
     { 'category':'C/C++',   'severity':severity.LOW,      'members':[], 'option':'',
         'description':'Value stored is never read',
         'patterns':[r".*: warning: Value stored to .+ is never read"] },
@@ -1544,7 +1554,7 @@
                     r".*: warning: wrong type argument to increment"] },
     { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wsign-promo',
         'description':'Overload resolution chose to promote from unsigned or enum to signed type' ,
-        'patterns':[r".*: warning: passing '.+' chooses 'int' over '.* int'"] },
+        'patterns':[r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"] },
     { 'category':'cont.',   'severity':severity.SKIP,     'members':[], 'option':'',
         'description':'',
         'patterns':[r".*: warning:   in call to '.+'"] },
@@ -1708,6 +1718,12 @@
     { 'category':'C/C++',   'severity':severity.MEDIUM,     'members':[], 'option':'',
         'description':'Result of malloc type incompatible with sizeof operand type',
         'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
+    { 'category':'C/C++',   'severity':severity.MEDIUM,     'members':[], '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,     'members':[], 'option':'',
+        'description':'Closing a previously closed file',
+        'patterns':[r".*: warning: Closing a previously closed file"] },
 
     { 'category':'C/C++',   'severity':severity.HARMLESS,     'members':[], 'option':'',
         'description':'Discarded qualifier from pointer target type',
@@ -1794,18 +1810,57 @@
         'description':'clang-tidy performance-unnecessary-value-param',
         'patterns':[r".*: .+\[performance-unnecessary-value-param\]$"] },
     { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer Unreachable code',
+        'patterns':[r".*: warning: This statement is never executed.*UnreachableCode"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer Size of malloc may overflow',
+        'patterns':[r".*: warning: .* size of .* may overflow .*MallocOverflow"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer Stream pointer might be NULL',
+        'patterns':[r".*: warning: Stream pointer might be NULL .*unix.Stream"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer Opened file never closed',
+        'patterns':[r".*: warning: Opened File never closed.*unix.Stream"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer sozeof() on a pointer type',
+        'patterns':[r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer Pointer arithmetic on non-array variables',
+        'patterns':[r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer Subtraction of pointers of different memory chunks',
+        'patterns':[r".*: warning: Subtraction of two pointers .*PointerSub"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer Access out-of-bound array element',
+        'patterns':[r".*: warning: Access out-of-bound array element .*ArrayBound"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer Out of bound memory access',
+        'patterns':[r".*: warning: Out of bound memory access .*ArrayBoundV2"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer Possible lock order reversal',
+        'patterns':[r".*: warning: .* Possible lock order reversal.*PthreadLock"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer Argument is a pointer to uninitialized value',
+        'patterns':[r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer cast to struct',
+        'patterns':[r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer call path problems',
+        'patterns':[r".*: warning: Call Path : .+"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
+        'description':'clang-analyzer other',
+        'patterns':[r".*: .+\[clang-analyzer-.+\]$",
+                    r".*: Call Path : .+$"] },
+    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
         'description':'clang-tidy CERT',
         'patterns':[r".*: .+\[cert-.+\]$"] },
     { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
         'description':'clang-tidy llvm',
         'patterns':[r".*: .+\[llvm-.+\]$"] },
     { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
-        'description':'clang-tidy clang-diagnostic',
+        'description':'clang-diagnostic',
         'patterns':[r".*: .+\[clang-diagnostic-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,     'members':[], 'option':'',
-        'description':'clang-tidy clang-analyzer',
-        'patterns':[r".*: .+\[clang-analyzer-.+\]$",
-                    r".*: Call Path : .+$"] },
 
     # catch-all for warnings this script doesn't know about yet
     { 'category':'C/C++',   'severity':severity.UNKNOWN,  'members':[], 'option':'',