adding patch for more specific compiler warning parsing from atr #1903
This commit is contained in:
parent
c7de6a1aa6
commit
541749bbf0
|
@ -54,6 +54,7 @@ from . import parallel_build
|
|||
from . import package_stats
|
||||
|
||||
from optparse import OptionParser
|
||||
from gcc_output_parse import Warnings
|
||||
|
||||
# #3883
|
||||
_popen_lock = threading.Lock()
|
||||
|
@ -421,10 +422,15 @@ class RosMakeAll:
|
|||
self.printer.print_full_verbose( pstd_out)
|
||||
with self._result_lock:
|
||||
self.result[argument][p] = True
|
||||
|
||||
num_warnings = len(re.findall("warning:", pstd_out))
|
||||
warnings = Warnings( pstd_out )
|
||||
num_warnings = len( warnings.warning_lines )
|
||||
if num_warnings > 0:
|
||||
return_string = ("[PASS] [ %.2f seconds ] -- WARNING: %d compiler warnings"%(self.profile[argument][p], num_warnings))
|
||||
return_string = "[PASS] [ %.2f seconds ] [ %d warnings "%(self.profile[argument][p], num_warnings)
|
||||
warning_dict = warnings.analyze();
|
||||
for warntype,warnlines in warning_dict.iteritems():
|
||||
if len( warnlines ) > 0:
|
||||
return_string = return_string + '[ {0:d} {1} ] '.format(len(warnlines),warntype)
|
||||
return_string = return_string + ' ]'
|
||||
else:
|
||||
return_string = ("[PASS] [ %.2f seconds ]"%( self.profile[argument][p]))
|
||||
self.output_to_file(p, log_type, pstd_out, num_warnings > 0)
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
import re
|
||||
|
||||
class Warnings:
|
||||
""" Extract warnings from GCC's output
|
||||
|
||||
Analyzes compiler output and classifies warnings.
|
||||
"""
|
||||
|
||||
_warning_pattern_map = {
|
||||
'antiquated':' antiquated',
|
||||
'deprecated' : ' deprecated',
|
||||
'unused_func' : ' defined but not used',
|
||||
'isoc' : ' ISO C',
|
||||
'missing_init' : ' missing initializer',
|
||||
'out_of_bounds' : ' subscript .*? bounds',
|
||||
'unused_var' : ' unused variable'
|
||||
}
|
||||
|
||||
def __init__(self, console_output):
|
||||
self.warning_lines = [ x for x in console_output.splitlines() if x.find(" warning:") > 0 ]
|
||||
|
||||
def byType(self, warntype):
|
||||
""" Extract warning messages corresponding to warntype.
|
||||
The warntypes can be all keys of the _warning_pattern_map dictionary.
|
||||
@param warntype: The type of warning message that should be extracted.
|
||||
@type warntype: str
|
||||
@return a list of warning messages
|
||||
@rtype list
|
||||
"""
|
||||
return [ x for x in self.warning_lines if re.search(self._warning_pattern_map[warntype], x) ]
|
||||
|
||||
def analyze(self):
|
||||
""" Get dictionary of classified warnings.
|
||||
|
||||
@return A dictionary of lists of warning messages indexed by the warning type
|
||||
@rtype {str:[str]}
|
||||
"""
|
||||
return dict( [ (t,self.byType(t)) for t,p in self._warning_pattern_map.iteritems() ] )
|
Loading…
Reference in New Issue