Bug 1403846 - add "header-filter" option argument to static-analysis from mach. draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Thu, 28 Sep 2017 11:21:34 +0300
changeset 674195 764420e7c7233e245d8f1010acb5c8ef0c20ec15
parent 674178 11fe0a2895aab26c57bcfe61b3041d7837e954cd
child 734254 6b6d16779c99e98b53e280eb51790b44c85e6cc5
push id82753
push userbmo:bpostelnicu@mozilla.com
push dateTue, 03 Oct 2017 12:01:55 +0000
bugs1403846
milestone58.0a1
Bug 1403846 - add "header-filter" option argument to static-analysis from mach. MozReview-Commit-ID: GulGPCCi9U4
python/mozbuild/mozbuild/mach_commands.py
--- 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 = []