Last active
April 10, 2021 21:07
-
-
Save aaronpuchert/5f8c08347f6fb1cb4020e9561b5ccbc5 to your computer and use it in GitHub Desktop.
Remove some clutter from Clang's AST dump
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sed -f | |
# Remove hard-coded typedefs in the beginning. | |
2,+13d | |
# Remove addresses from Stmts, Attrs, Comments. | |
s/\o033\[0m\o033\[0;1;35m\([A-Za-z]*\)\o033\[0m\o033\[0;33m 0x[0-9a-f]*/\o033[0m\o033[0;1;35m\1\o033[0m\o033[0;33m/g | |
s/\o033\[0m\o033\[0;1;34m\([A-Za-z]*\)\o033\[0m\o033\[0;33m 0x[0-9a-f]*/\o033[0m\o033[0;1;34m\1\o033[0m\o033[0;33m/g | |
s/\o033\[0m\o033\[0;34m\([A-Za-z]*\)\o033\[0m\o033\[0;33m 0x[0-9a-f]*/\o033[0m\o033[0;34m\1\o033[0m\o033[0;33m/g | |
# Remove source locations and ranges. | |
s/ <\o033\[0;33m[^\o033]*\o033\[0m>//g | |
s/ <\o033\[0;33m[^\o033]*\o033\[0m, \o033\[0;33m[^\o033]*\o033\[0m>//g | |
s/ \o033\[0;33m[^\o033]*\o033\[0m//g | |
# Write types italic instead of in '', use → instead of : for canonicalization. | |
s/\o033\[0;32m'\([^']*\)'\o033\[0m/\o033[0;3;32m\1\o033[0m/g | |
s/\o033\[0;32m'\([^']*\)':'\([^']*\)'\o033\[0m/\o033[0;3;32m\1\o033[23m → \o033[3m\2\o033[0m/g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The addresses are mostly useful on declarations, and source ranges are often not needed.