diff options
author | Chih-Hung Hsieh <chh@google.com> | 2020-01-10 10:33:40 -0800 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2020-01-10 15:21:20 -0800 |
commit | 949205a6618491b883d3ae03959d1316702a63e0 (patch) | |
tree | 88ded2423a9cbf522fce57856702f2a4fd57b220 /tools/warn/cpp_warn_patterns.py | |
parent | 5ec7b56e5d3143329f9a5d77630be54924dee2a5 (diff) |
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
Diffstat (limited to 'tools/warn/cpp_warn_patterns.py')
-rw-r--r-- | tools/warn/cpp_warn_patterns.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/tools/warn/cpp_warn_patterns.py b/tools/warn/cpp_warn_patterns.py index ce10693d97..af8bfe8965 100644 --- a/tools/warn/cpp_warn_patterns.py +++ b/tools/warn/cpp_warn_patterns.py @@ -1,4 +1,4 @@ -# +# python3 # Copyright (C) 2019 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,9 +15,14 @@ """Warning patterns for C/C++ compiler, but not clang-tidy.""" -from severity import Severity +import re + +# pylint:disable=relative-beyond-top-level +# pylint:disable=g-importing-member +from .severity import Severity -patterns = [ + +warn_patterns = [ # pylint:disable=line-too-long,g-inconsistent-quotes {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-function-declaration', 'description': 'Implicit function declaration', @@ -125,9 +130,6 @@ patterns = [ {'category': 'libpng', 'severity': Severity.MEDIUM, 'description': 'libpng: zero area', 'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]}, - {'category': 'aapt', 'severity': Severity.MEDIUM, - 'description': 'aapt: no comment for public symbol', - 'patterns': [r".*: warning: No comment for public symbol .+"]}, {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces', 'description': 'Missing braces around initializer', 'patterns': [r".*: warning: missing braces around initializer.*"]}, @@ -578,3 +580,14 @@ patterns = [ 'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags", r".*: warning: .+ was previously declared as a .+mismatched-tags"]}, ] + + +def compile_patterns(patterns): + """Precompiling every pattern speeds up parsing by about 30x.""" + for i in patterns: + i['compiled_patterns'] = [] + for pat in i['patterns']: + i['compiled_patterns'].append(re.compile(pat)) + + +compile_patterns(warn_patterns) |