summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Grasman <kim.grasman@gmail.com>2017-01-08 12:51:34 +0100
committerKim Gräsman <kim.grasman@gmail.com>2017-01-25 20:31:17 +0100
commit79ef6948e74aa6f6ec1fff38372a271362aef44f (patch)
tree602f797ce2ff518a8e672a7e6cbdda97cfb8bc55
parentb5d3e7250a96df6627530b6d8e79c7945a95dcbb (diff)
Add dev script for log scrubbing
-rwxr-xr-xscrub-logs.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/scrub-logs.py b/scrub-logs.py
new file mode 100755
index 0000000..f159992
--- /dev/null
+++ b/scrub-logs.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+##===---------- scrub-logs.py - generate README from Wiki sources ---------===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+"""Scrub irrelevant details from IWYU/Clang logs.
+
+When Clang changes upstream, we usually look for differences in the AST to
+explain the new behavior. This script makes that easier by scrubbing pointer
+values and path prefixes from ast-dump output, so they can be diffed directly.
+"""
+
+import re
+import sys
+
+
+def strip_path_prefix(line):
+ line = re.sub(r'<.*(llvm[\\/]tools[\\/].*):', r'<\1:', line)
+ return line
+
+
+def strip_addrs(line):
+ line = re.sub('\s(0x)?[0-9A-Fa-f]{6,9}', '', line)
+ return line
+
+
+def main(args):
+ with open(args[1]) as fd:
+ for line in fd:
+ line = line.strip()
+ line = strip_addrs(line)
+ line = strip_path_prefix(line)
+ print(line)
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))