Bug 1403846 - add "header-filter" option argument to static-analysis from mach.
MozReview-Commit-ID: GulGPCCi9U4
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -2200,18 +2200,22 @@ class StaticAnalysis(MachCommandBase):
help='Static analysis checks to enable. By default, this enables only '
'custom Mozilla checks, but can be any clang-tidy checks syntax.')
@CommandArgument('--jobs', '-j', default='0', metavar='jobs', type=int,
help='Number of concurrent jobs to run. Default is the number of CPUs.')
@CommandArgument('--strip', '-p', default='1', metavar='NUM',
help='Strip NUM leading components from file names in diff mode.')
@CommandArgument('--fix', '-f', default=False, action='store_true',
help='Try to autofix errors detected by clang-tidy checkers.')
+ @CommandArgument('--header-filter', '-h-f', default='', metavar='header_filter',
+ help='Regular expression matching the names of the headers to '
+ 'output diagnostics from. Diagnostics from the main file '
+ 'of each translation unit are always displayed')
def check(self, source=None, jobs=2, strip=1, verbose=False,
- checks='-*', fix=False):
+ checks='-*', fix=False, header_filter=''):
self._set_log_level(verbose)
rc = self._build_compile_db(verbose=verbose)
if rc != 0:
return rc
rc = self._build_export(jobs=jobs, verbose=verbose)
if rc != 0:
return rc
@@ -2223,16 +2227,20 @@ class StaticAnalysis(MachCommandBase):
python = self.virtualenv_manager.python_path
if checks == '-*':
checks = self._get_checks()
common_args = ['-clang-tidy-binary', self._clang_tidy_path,
'-checks=%s' % checks,
'-extra-arg=-DMOZ_CLANG_PLUGIN']
+
+ if len(header_filter):
+ common_args.append('-header-filter=%s' % header_filter)
+
if fix:
common_args.append('-fix')
self.log_manager.register_structured_logger(logging.getLogger('mozbuild'))
compile_db = json.loads(open(self._compile_db, 'r').read())
total = 0
files = []