summaryrefslogtreecommitdiff
path: root/scripts/coccinelle
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-09-11 18:44:10 -0400
committerNick Mathewson <nickm@torproject.org>2019-09-11 18:44:10 -0400
commitc6191983e93fc9d377650555fb78649e9fe8713b (patch)
treeb84500096faeaedc166a4fdade4e90512371f353 /scripts/coccinelle
parent9a101c2c0f1e4598cd5bd2710e6021052e4ebdfa (diff)
downloadtor-c6191983e93fc9d377650555fb78649e9fe8713b.tar.gz
tor-c6191983e93fc9d377650555fb78649e9fe8713b.zip
Add a script to tell whether a file can be perfectly parsed by spatch
spatch can let us know whether a file has parsed "perfectly" or not. The more perfect it parses, the likelier any semantic patches are to apply. I've used this script to identify problem areas in our code.
Diffstat (limited to 'scripts/coccinelle')
-rwxr-xr-xscripts/coccinelle/try_parse.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/coccinelle/try_parse.sh b/scripts/coccinelle/try_parse.sh
new file mode 100755
index 0000000000..865c85570a
--- /dev/null
+++ b/scripts/coccinelle/try_parse.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Echo the name of every argument of this script that is not "perfect"
+# according to coccinelle's --parse-c.
+
+top="$(dirname "$0")/../.."
+
+for fn in "$@"; do
+
+ if spatch -macro_file_builtins "$top"/scripts/coccinelle/tor-coccinelle.h \
+ -I "$top" -I "$top"/src -I "$top"/ext --parse-c "$fn" \
+ 2>/dev/null | grep "perfect = 1" > /dev/null; then
+ : # it's perfect
+ else
+ echo "$fn"
+ fi
+
+done