From 8ef1aae6d38e12d4a6f2c7d68d051a6e3fbc0680 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Thu, 18 May 2017 11:40:08 -0700 Subject: [PATCH] Recognize new clang and make warnings. Test: warn.py build.log Change-Id: I078b3cc35a00590312208cb90af0a1f2431abf09 --- tools/warn.py | 152 +++++++++++++++++++++++++++++--------------------- 1 file changed, 89 insertions(+), 63 deletions(-) diff --git a/tools/warn.py b/tools/warn.py index 8aed83043..be659b8e7 100755 --- a/tools/warn.py +++ b/tools/warn.py @@ -138,6 +138,24 @@ class Severity(object): column_headers = [a[1] for a in attributes] headers = [a[2] for a in attributes] + +def tidy_warn_pattern(description, pattern): + return { + 'category': 'C/C++', + 'severity': Severity.TIDY, + 'description': 'clang-tidy ' + description, + 'patterns': [r'.*: .+\[' + pattern + r'\]$'] + } + + +def simple_tidy_warn_pattern(description): + return tidy_warn_pattern(description, description) + + +def group_tidy_warn_pattern(description): + return tidy_warn_pattern(description, description + r'-.+') + + warn_patterns = [ # pylint:disable=line-too-long,g-inconsistent-quotes {'category': 'C/C++', 'severity': Severity.ANALYZER, @@ -223,6 +241,7 @@ warn_patterns = [ 'description': 'Unused function, variable or label', 'patterns': [r".*: warning: '.+' defined but not used", r".*: warning: unused function '.+'", + 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', @@ -257,6 +276,9 @@ warn_patterns = [ {'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"]}, @@ -436,6 +458,9 @@ warn_patterns = [ {'category': 'C/C++', 'severity': Severity.MEDIUM, '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': 'java', 'severity': Severity.MEDIUM, 'option': '-encoding', 'description': 'Java: Non-ascii characters used, but ascii encoding specified', 'patterns': [r".*: warning: unmappable character for encoding ascii"]}, @@ -451,6 +476,9 @@ warn_patterns = [ {'category': 'java', 'severity': Severity.MEDIUM, 'description': '_ used as an identifier', 'patterns': [r".*: warning: '_' used as an identifier"]}, + {'category': 'java', 'severity': Severity.HIGH, + 'description': 'Use of internal proprietary API', + 'patterns': [r".*: warning: .* is internal proprietary API and may be removed"]}, # Warnings from Javac {'category': 'java', @@ -1381,6 +1409,9 @@ warn_patterns = [ {'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"]}, @@ -1525,6 +1556,9 @@ warn_patterns = [ {'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 '.+'"]}, @@ -1654,6 +1688,9 @@ warn_patterns = [ {'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', @@ -1748,6 +1785,15 @@ warn_patterns = [ '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"]}, + {'category': 'FindEmulator', 'severity': Severity.HARMLESS, + 'description': 'FindEmulator: No such file or directory', + 'patterns': [r".*: warning: FindEmulator: .* No such file or directory"]}, + {'category': 'google_tests', 'severity': Severity.HARMLESS, + 'description': 'google_tests: unknown installed file', + 'patterns': [r".*: warning: .*_tests: Unknown installed file for module"]}, + {'category': 'make', 'severity': Severity.HARMLESS, + 'description': 'unusual tags debug eng', + 'patterns': [r".*: warning: .*: unusual tags debug eng"]}, # these next ones are to deal with formatting problems resulting from the log being mixed up by 'make -j' {'category': 'C/C++', 'severity': Severity.SKIP, @@ -1761,60 +1807,46 @@ warn_patterns = [ 'patterns': [r".*: warning: In file included from .+,"]}, # warnings from clang-tidy - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy readability', - 'patterns': [r".*: .+\[readability-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy c++ core guidelines', - 'patterns': [r".*: .+\[cppcoreguidelines-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy google-default-arguments', - 'patterns': [r".*: .+\[google-default-arguments\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy google-runtime-int', - 'patterns': [r".*: .+\[google-runtime-int\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy google-runtime-operator', - 'patterns': [r".*: .+\[google-runtime-operator\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy google-runtime-references', - 'patterns': [r".*: .+\[google-runtime-references\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy google-build', - 'patterns': [r".*: .+\[google-build-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy google-explicit', - 'patterns': [r".*: .+\[google-explicit-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy google-readability', - 'patterns': [r".*: .+\[google-readability-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy google-global', - 'patterns': [r".*: .+\[google-global-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy google- other', - 'patterns': [r".*: .+\[google-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy modernize', - 'patterns': [r".*: .+\[modernize-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy misc', - 'patterns': [r".*: .+\[misc-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy performance-faster-string-find', - 'patterns': [r".*: .+\[performance-faster-string-find\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy performance-for-range-copy', - 'patterns': [r".*: .+\[performance-for-range-copy\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy performance-implicit-cast-in-loop', - 'patterns': [r".*: .+\[performance-implicit-cast-in-loop\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy performance-unnecessary-copy-initialization', - 'patterns': [r".*: .+\[performance-unnecessary-copy-initialization\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy performance-unnecessary-value-param', - 'patterns': [r".*: .+\[performance-unnecessary-value-param\]$"]}, + group_tidy_warn_pattern('cert'), + group_tidy_warn_pattern('clang-diagnostic'), + group_tidy_warn_pattern('cppcoreguidelines'), + group_tidy_warn_pattern('llvm'), + simple_tidy_warn_pattern('google-default-arguments'), + simple_tidy_warn_pattern('google-runtime-int'), + simple_tidy_warn_pattern('google-runtime-operator'), + simple_tidy_warn_pattern('google-runtime-references'), + group_tidy_warn_pattern('google-build'), + group_tidy_warn_pattern('google-explicit'), + group_tidy_warn_pattern('google-redability'), + group_tidy_warn_pattern('google-global'), + group_tidy_warn_pattern('google-redability'), + group_tidy_warn_pattern('google-redability'), + group_tidy_warn_pattern('google'), + simple_tidy_warn_pattern('hicpp-explicit-conversions'), + simple_tidy_warn_pattern('hicpp-function-size'), + simple_tidy_warn_pattern('hicpp-invalid-access-moved'), + simple_tidy_warn_pattern('hicpp-member-init'), + simple_tidy_warn_pattern('hicpp-delete-operators'), + simple_tidy_warn_pattern('hicpp-special-member-functions'), + simple_tidy_warn_pattern('hicpp-use-equals-default'), + simple_tidy_warn_pattern('hicpp-use-equals-delete'), + simple_tidy_warn_pattern('hicpp-no-assembler'), + simple_tidy_warn_pattern('hicpp-noexcept-move'), + simple_tidy_warn_pattern('hicpp-use-override'), + group_tidy_warn_pattern('hicpp'), + group_tidy_warn_pattern('modernize'), + group_tidy_warn_pattern('misc'), + simple_tidy_warn_pattern('performance-faster-string-find'), + simple_tidy_warn_pattern('performance-for-range-copy'), + simple_tidy_warn_pattern('performance-implicit-cast-in-loop'), + simple_tidy_warn_pattern('performance-inefficient-string-concatenation'), + simple_tidy_warn_pattern('performance-type-promotion-in-math-fn'), + simple_tidy_warn_pattern('performance-unnecessary-copy-initialization'), + simple_tidy_warn_pattern('performance-unnecessary-value-param'), + group_tidy_warn_pattern('performance'), + group_tidy_warn_pattern('readability'), + + # warnings from clang-tidy's clang-analyzer checks {'category': 'C/C++', 'severity': Severity.ANALYZER, 'description': 'clang-analyzer Unreachable code', 'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]}, @@ -1854,19 +1886,13 @@ warn_patterns = [ {'category': 'C/C++', 'severity': Severity.ANALYZER, 'description': 'clang-analyzer call path problems', 'patterns': [r".*: warning: Call Path : .+"]}, + {'category': 'C/C++', 'severity': Severity.ANALYZER, + 'description': 'clang-analyzer excessive padding', + 'patterns': [r".*: warning: Excessive padding in '.*'"]}, {'category': 'C/C++', 'severity': Severity.ANALYZER, 'description': 'clang-analyzer other', 'patterns': [r".*: .+\[clang-analyzer-.+\]$", r".*: Call Path : .+$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy CERT', - 'patterns': [r".*: .+\[cert-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-tidy llvm', - 'patterns': [r".*: .+\[llvm-.+\]$"]}, - {'category': 'C/C++', 'severity': Severity.TIDY, - 'description': 'clang-diagnostic', - 'patterns': [r".*: .+\[clang-diagnostic-.+\]$"]}, # catch-all for warnings this script doesn't know about yet {'category': 'C/C++', 'severity': Severity.UNKNOWN,