Last active
August 21, 2017 14:36
-
-
Save coord-e/baf3ae2075c15167ee29663eb3b404f3 to your computer and use it in GitHub Desktop.
Extract llvm function declarations from c header
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
#!/bin/bash | |
# EXAMPLE: ./lldecl.sh /usr/include/stdio.h | |
INFILE=$1 | |
TMPFILE1=$(mktemp)".h" | |
TMPFILE2=$(mktemp)".c" | |
clang -E $INFILE -o $TMPFILE1 | |
echo '#include "'$TMPFILE1'"' >> $TMPFILE2 | |
echo 'int main() {' >> $TMPFILE2 | |
ctags -x --c-kinds=fp $TMPFILE1 | awk '{ print "auto v"NR" = &"$1";" }' >> $TMPFILE2 | |
echo '}' >> $TMPFILE2 | |
clang $TMPFILE2 -c -S -emit-llvm -o- 2> /dev/null | grep 'declare' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment