llvm.org GIT mirror llvm / 7f53d59
Add options to enable each individual level for the show-diagnostics tool. rdar://9683410 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142856 91177308-0d34-0410-b5e6-96231b3b80d8 Chad Rosier 9 years ago
1 changed file(s) with 30 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
44 def main():
55 from optparse import OptionParser, OptionGroup
66 parser = OptionParser("""\
7 usage: %prog [options]
7 Usage: %prog [options]
88
99 Utility for dumping Clang-style logged diagnostics.\
1010 """)
11 parser.add_option("-a", "--all", action="store_true", dest="all",
12 default=False, help="dump all messages.")
13 parser.add_option("-e", "--error", action="store_true", dest="error",
14 default=False, help="dump 'error' messages.")
15 parser.add_option("-f", "--fatal", action="store_true", dest="fatal",
16 default=False, help="dump 'fatal error' messages.")
17 parser.add_option("-i", "--ignored", action="store_true", dest="ignored",
18 default=False, help="dump 'ignored' messages.")
19 parser.add_option("-n", "--note", action="store_true", dest="note",
20 default=False, help="dump 'note' messages.")
21 parser.add_option("-w", "--warning", action="store_true", dest="warning",
22 default=False, help="dump 'warning' messages.")
1123 (opts, args) = parser.parse_args()
1224
1325 if len(args) != 1:
1426 parser.error("invalid number of arguments")
27
28 levels = {'error': False, 'fatal error': False, 'ignored': False,
29 'note': False, 'warning': False}
30 if opts.error:
31 levels['error'] = True
32 if opts.fatal:
33 levels['fatal error'] = True
34 if opts.ignored:
35 levels['ignored'] = True
36 if opts.note:
37 levels['note'] = True
38 if opts.warning:
39 levels['warning'] = True
1540
1641 path, = args
1742
4368 file = file_diags.get('main-file')
4469 print "*** %s ***" % file
4570 for d in file_diags.get('diagnostics', ()):
46 print "%s:%s:%s: %s: %s" % (
47 d.get('filename'), d.get('line'), d.get('column'),
48 d.get('level'), d.get('message'))
71 if levels[d.get('level')] or opts.all:
72 print " %s:%s:%s: %s: %s" % (
73 d.get('filename'), d.get('line'), d.get('column'),
74 d.get('level'), d.get('message'))
4975
5076 if __name__ == "__main__":
5177 main()