diff --git a/.arcconfig b/.arcconfig --- a/.arcconfig +++ b/.arcconfig @@ -1,5 +1,5 @@ { - "phabricator.uri" : "https://phabricator.services.mozilla.com/", + "phabricator.uri" : "https://phabricator-dev.allizom.org/", "repository.callsign": "MOZILLACENTRAL", "history.immutable": false } diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py --- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py +++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py @@ -160,10 +160,15 @@ check_config = get_check_config(warning['flag']) if check_config is not None: warning['reliability'] = check_config.get('reliability', 'low') warning['reason'] = check_config.get('reason') warning['publish'] = check_config.get('publish', True) + elif warning["flag"] == "clang-diagnostic-error": + # For a "warning" that is flagged as "clang-diagnostic-error" + # set it as "publish" + warning['publish'] = True + return (warning, True) @CommandProvider class StaticAnalysis(MachCommandBase): @@ -574,11 +579,10 @@ (event for event in issue['events'] if event['main'] is True), None) dict_issue = { 'line': issue['mainEventLineNumber'], 'flag': issue['checkerName'], - 'build_error': issue['checkerName'].startswith('RW.CLANG'), 'message': event_path['eventDescription'], 'reliability': self.get_reliability_index_for_cov_checker( issue['checkerName'] ), 'extra': { @@ -600,10 +604,14 @@ return dict_issue for issue in result['issues']: path = build_repo_relative_path(issue['strippedMainEventFilePathname'], self.topsrcdir) + # Skip clang diagnostic messages + if issue['checkerName'].startswith('RW.CLANG'): + continue + if path is None: # Since we skip a result we should log it self.log(logging.INFO, 'static-analysis', {}, 'Skipping CID: {0} from file: {1} since it\'s not related ' 'with the current patch.'.format( diff --git a/python/mozbuild/mozbuild/compilation/warnings.py b/python/mozbuild/mozbuild/compilation/warnings.py --- a/python/mozbuild/mozbuild/compilation/warnings.py +++ b/python/mozbuild/mozbuild/compilation/warnings.py @@ -21,41 +21,31 @@ # needed to properly analyze Clang compiler output, which may be colorized. # It assumes ANSI escape sequences. RE_STRIP_COLORS = re.compile(r'\x1b\[[\d;]+m') # This captures Clang diagnostics with the standard formatting. -RE_CLANG_WARNING = re.compile(r""" +RE_CLANG_WARNING_AND_ERROR = re.compile(r""" (?P[^:]+) : (?P\d+) : (?P\d+) : - \swarning:\s + \s(?Pwarning|error):\s (?P.+) \[(?P[^\]]+) """, re.X) # This captures Clang-cl warning format. -RE_CLANG_CL_WARNING = re.compile(r""" +RE_CLANG_CL_WARNING_AND_ERROR = re.compile(r""" (?P.*) \((?P\d+),(?P\d+)\) - \s?:\s+warning:\s + \s?:\s+(?Pwarning|error):\s (?P.*) \[(?P[^\]]+) """, re.X) -# This captures Visual Studio's warning format. -RE_MSVC_WARNING = re.compile(r""" - (?P.*) - \((?P\d+)\) - \s?:\swarning\s - (?P[^:]+) - :\s - (?P.*) - """, re.X) - IN_FILE_INCLUDED_FROM = 'In file included from ' class CompilerWarning(dict): """Represents an individual compiler warning.""" @@ -335,38 +325,32 @@ warning = CompilerWarning() filename = None # TODO make more efficient so we run minimal regexp matches. - match_clang = RE_CLANG_WARNING.match(filtered) - match_clang_cl = RE_CLANG_CL_WARNING.match(filtered) - match_msvc = RE_MSVC_WARNING.match(filtered) + match_clang = RE_CLANG_WARNING_AND_ERROR.match(filtered) + match_clang_cl = RE_CLANG_CL_WARNING_AND_ERROR.match(filtered) if match_clang: d = match_clang.groupdict() filename = d['file'] + warning['type'] = d['type'] warning['line'] = int(d['line']) warning['column'] = int(d['column']) warning['flag'] = d['flag'] warning['message'] = d['message'].rstrip() elif match_clang_cl: d = match_clang_cl.groupdict() filename = d['file'] + warning['type'] = d['type'] warning['line'] = int(d['line']) warning['column'] = int(d['column']) warning['flag'] = d['flag'] warning['message'] = d['message'].rstrip() - elif match_msvc: - d = match_msvc.groupdict() - - filename = d['file'] - warning['line'] = int(d['line']) - warning['flag'] = d['flag'] - warning['message'] = d['message'].rstrip() else: self.included_from = [] return None filename = os.path.normpath(filename) diff --git a/python/mozbuild/mozbuild/controller/building.py b/python/mozbuild/mozbuild/controller/building.py --- a/python/mozbuild/mozbuild/controller/building.py +++ b/python/mozbuild/mozbuild/controller/building.py @@ -223,10 +223,14 @@ # Contains warnings unique to this invocation. Not populated with old # warnings. self.instance_warnings = WarningsDatabase() def on_warning(warning): + # Skip `errors` + if warning['type'] == 'error': + return + filename = warning['filename'] if not os.path.exists(filename): raise Exception('Could not find file containing warning: %s' % filename) diff --git a/python/mozbuild/mozbuild/test/compilation/test_warnings.py b/python/mozbuild/mozbuild/test/compilation/test_warnings.py --- a/python/mozbuild/mozbuild/test/compilation/test_warnings.py +++ b/python/mozbuild/mozbuild/test/compilation/test_warnings.py @@ -15,23 +15,15 @@ from mozunit import main CLANG_TESTS = [ ('foobar.cpp:123:10: warning: you messed up [-Wfoo]', - 'foobar.cpp', 123, 10, 'you messed up', '-Wfoo'), - ("c_locale_dummy.c:457:1: warning: (near initialization for " - "'full_wmonthname[0]') [-Wpointer-sign]", - 'c_locale_dummy.c', 457, 1, - "(near initialization for 'full_wmonthname[0]')", '-Wpointer-sign') -] - -MSVC_TESTS = [ - ("C:/mozilla-central/test/foo.cpp(793) : warning C4244: 'return' : " - "conversion from 'double' to 'uint32_t', possible loss of data", - 'C:/mozilla-central/test/foo.cpp', 793, 'C4244', - "'return' : conversion from 'double' to 'uint32_t', possible loss of " - 'data') + 'foobar.cpp', 123, 10, 'warning', 'you messed up', '-Wfoo'), + ("c_locale_dummy.c:457:1: error: (near initialization for " + "'full_wmonthname[0]') [clang-diagnostic-error]", + 'c_locale_dummy.c', 457, 1, 'error', + "(near initialization for 'full_wmonthname[0]')", 'clang-diagnostic-error') ] CURRENT_LINE = 1 @@ -125,36 +117,25 @@ self.assertLessEqual(w2, w1) self.assertGreaterEqual(w2, w1) self.assertGreaterEqual(w1, w2) -class TestWarningsParsing(unittest.TestCase): +class TestWarningsAndErrorsParsing(unittest.TestCase): def test_clang_parsing(self): - for source, filename, line, column, message, flag in CLANG_TESTS: + for source, filename, line, column, diag_type, message, flag in CLANG_TESTS: collector = WarningsCollector(lambda w: None) warning = collector.process_line(source) self.assertIsNotNone(warning) self.assertEqual(warning['filename'], filename) self.assertEqual(warning['line'], line) self.assertEqual(warning['column'], column) + self.assertEqual(warning['type'], diag_type) self.assertEqual(warning['message'], message) self.assertEqual(warning['flag'], flag) - def test_msvc_parsing(self): - for source, filename, line, flag, message in MSVC_TESTS: - collector = WarningsCollector(lambda w: None) - warning = collector.process_line(source) - - self.assertIsNotNone(warning) - - self.assertEqual(warning['filename'], os.path.normpath(filename)) - self.assertEqual(warning['line'], line) - self.assertEqual(warning['flag'], flag) - self.assertEqual(warning['message'], message) - class TestWarningsDatabase(unittest.TestCase): def test_basic(self): db = WarningsDatabase()