1
2
3 import re
4
6 """ Extract warnings from GCC's output
7
8 Analyzes compiler output and classifies warnings.
9 """
10
11 _warning_pattern_map = {
12 'antiquated':' antiquated',
13 'deprecated' : ' deprecated',
14 'unused_func' : ' defined but not used',
15 'isoc' : ' ISO C',
16 'missing_init' : ' missing initializer',
17 'out_of_bounds' : ' subscript .*? bounds',
18 'unused_var' : ' unused variable'
19 }
20
22 self.warning_lines = [ x for x in console_output.splitlines() if x.find(" warning:") > 0 ]
23
25 """ Extract warning messages corresponding to warntype.
26 The warntypes can be all keys of the _warning_pattern_map dictionary.
27 @param warntype: The type of warning message that should be extracted.
28 @type warntype: str
29 @return a list of warning messages
30 @rtype list
31 """
32 return [ x for x in self.warning_lines if re.search(self._warning_pattern_map[warntype], x) ]
33
35 """ Get dictionary of classified warnings.
36
37 @return A dictionary of lists of warning messages indexed by the warning type
38 @rtype {str:[str]}
39 """
40 return dict( [ (t,self.byType(t)) for t,p in self._warning_pattern_map.items() ] )
41