aboutsummaryrefslogtreecommitdiff
path: root/utils/clang-parse-diagnostics-file
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2011-11-02 00:44:16 +0000
committerChad Rosier <mcrosier@apple.com>2011-11-02 00:44:16 +0000
commit3eae0c2fa627b6f6466f6ef843f380b84d6145ed (patch)
tree020097eb66da480de8646baa7a053ca1f982ca3a /utils/clang-parse-diagnostics-file
parent9af37a3de8c8688adae383471379f0216287ce28 (diff)
Rename show-diagnostics to something less ambiguous.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/clang-parse-diagnostics-file')
-rwxr-xr-xutils/clang-parse-diagnostics-file78
1 files changed, 78 insertions, 0 deletions
diff --git a/utils/clang-parse-diagnostics-file b/utils/clang-parse-diagnostics-file
new file mode 100755
index 0000000000..b8ea8eae31
--- /dev/null
+++ b/utils/clang-parse-diagnostics-file
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+
+import plistlib
+
+def main():
+ from optparse import OptionParser, OptionGroup
+ parser = OptionParser("""\
+Usage: %prog [options] <path>
+
+Utility for dumping Clang-style logged diagnostics.\
+""")
+ parser.add_option("-a", "--all", action="store_true", dest="all",
+ default=False, help="dump all messages.")
+ parser.add_option("-e", "--error", action="store_true", dest="error",
+ default=False, help="dump 'error' messages.")
+ parser.add_option("-f", "--fatal", action="store_true", dest="fatal",
+ default=False, help="dump 'fatal error' messages.")
+ parser.add_option("-i", "--ignored", action="store_true", dest="ignored",
+ default=False, help="dump 'ignored' messages.")
+ parser.add_option("-n", "--note", action="store_true", dest="note",
+ default=False, help="dump 'note' messages.")
+ parser.add_option("-w", "--warning", action="store_true", dest="warning",
+ default=False, help="dump 'warning' messages.")
+ (opts, args) = parser.parse_args()
+
+ if len(args) != 1:
+ parser.error("invalid number of arguments")
+
+ levels = {'error': False, 'fatal error': False, 'ignored': False,
+ 'note': False, 'warning': False}
+ if opts.error:
+ levels['error'] = True
+ if opts.fatal:
+ levels['fatal error'] = True
+ if opts.ignored:
+ levels['ignored'] = True
+ if opts.note:
+ levels['note'] = True
+ if opts.warning:
+ levels['warning'] = True
+
+ path, = args
+
+ # Read the diagnostics log.
+ f = open(path)
+ try:
+ data = f.read()
+ finally:
+ f.close()
+
+ # Complete the plist (the log itself is just the chunks).
+ data = """\
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
+ "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+%s
+</array>
+</plist>""" % data
+
+ # Load the diagnostics.
+ diags = plistlib.readPlistFromString(data)
+
+ # Print out the diagnostics.
+ print
+ print "**** BUILD DIAGNOSTICS ****"
+ for i, file_diags in enumerate(diags):
+ file = file_diags.get('main-file')
+ print "*** %s ***" % file
+ for d in file_diags.get('diagnostics', ()):
+ if levels[d.get('level')] or opts.all:
+ print " %s:%s:%s: %s: %s" % (
+ d.get('filename'), d.get('line'), d.get('column'),
+ d.get('level'), d.get('message'))
+
+if __name__ == "__main__":
+ main()