diff options
author | iphydf <iphydf@users.noreply.github.com> | 2020-05-02 00:34:13 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2020-05-02 22:00:09 +0100 |
commit | f8ab32aaa4efce2c9a310a14d10b19fb8544cfd9 (patch) | |
tree | 4dbc49882d6af0954c533b2482b2100d312d2bc7 /other | |
parent | 2570ddcb17fdf5bea56c6bc1c5c2d04ba2068ee7 (diff) |
Add a check that we don't have any unused functions.
This check puts all of our code in a C++ anonymous namespace, which is
effectively making all functions `static`. This allows the compiler to
determine that a function is unused, so we can delete it.
Diffstat (limited to 'other')
-rw-r--r-- | other/analysis/gen-file.sh | 35 | ||||
-rw-r--r-- | other/bootstrap_daemon/docker/tox-bootstrapd.sha256 | 2 | ||||
-rw-r--r-- | other/cpufeatures.c | 2 |
3 files changed, 23 insertions, 16 deletions
diff --git a/other/analysis/gen-file.sh b/other/analysis/gen-file.sh index 019bd8f9..ad8df3b8 100644 --- a/other/analysis/gen-file.sh +++ b/other/analysis/gen-file.sh | |||
@@ -17,20 +17,20 @@ put() { | |||
17 | if [ "$SKIP_LINES" = "" ]; then | 17 | if [ "$SKIP_LINES" = "" ]; then |
18 | echo "#line 1 \"$1\"" >> amalgamation.cc | 18 | echo "#line 1 \"$1\"" >> amalgamation.cc |
19 | fi | 19 | fi |
20 | cat $1 >> amalgamation.cc | 20 | cat "$1" >> amalgamation.cc |
21 | } | 21 | } |
22 | 22 | ||
23 | putmain() { | 23 | putmain() { |
24 | echo "namespace $(echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g') {" >> amalgamation.cc | 24 | echo "namespace $(echo "$1" | sed -e 's/[^a-zA-Z0-9_]/_/g') {" >> amalgamation.cc |
25 | if [ "$SKIP_LINES" = "" ]; then | 25 | if [ "$SKIP_LINES" = "" ]; then |
26 | echo "#line 1 \"$1\"" >> amalgamation.cc | 26 | echo "#line 1 \"$1\"" >> amalgamation.cc |
27 | fi | 27 | fi |
28 | sed -e 's/^int main(/static &/' $1 >> amalgamation.cc | 28 | sed -e 's/^int main(/static &/' "$1" >> amalgamation.cc |
29 | echo "} // namespace $(echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g')" >> amalgamation.cc | 29 | echo "} // namespace $(echo "$1" | sed -e 's/[^a-zA-Z0-9_]/_/g')" >> amalgamation.cc |
30 | } | 30 | } |
31 | 31 | ||
32 | callmain() { | 32 | callmain() { |
33 | echo " call($(echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g')::main, argc, argv);" >> amalgamation.cc | 33 | echo " call($(echo "$1" | sed -e 's/[^a-zA-Z0-9_]/_/g')::main, argc, argv);" >> amalgamation.cc |
34 | } | 34 | } |
35 | 35 | ||
36 | :> amalgamation.cc | 36 | :> amalgamation.cc |
@@ -53,25 +53,32 @@ FIND_QUERY="$FIND_QUERY -and -not -name av_test.c" | |||
53 | FIND_QUERY="$FIND_QUERY -and -not -name dht_test.c" | 53 | FIND_QUERY="$FIND_QUERY -and -not -name dht_test.c" |
54 | FIND_QUERY="$FIND_QUERY -and -not -name version_test.c" | 54 | FIND_QUERY="$FIND_QUERY -and -not -name version_test.c" |
55 | 55 | ||
56 | for i in $(eval $FIND_QUERY); do | 56 | (for i in $(eval "$FIND_QUERY"); do |
57 | if ! grep -q '^int main(' $i; then | 57 | grep -o '#include <[^>]*>' "$i" \ |
58 | put $i | 58 | | grep -E -v '<win|<ws|<iphlp|<libc|<mach/|<crypto_|<randombytes|<u.h>|<sys/filio|<linux' |
59 | done) | sort -u >> amalgamation.cc | ||
60 | |||
61 | echo 'namespace {' >> amalgamation.cc | ||
62 | for i in $(eval "$FIND_QUERY"); do | ||
63 | if ! grep -q '^int main(' "$i"; then | ||
64 | put "$i" | ||
59 | fi | 65 | fi |
60 | done | 66 | done |
61 | 67 | ||
62 | for i in $(eval $FIND_QUERY); do | 68 | for i in $(eval "$FIND_QUERY"); do |
63 | if grep -q '^int main(' $i; then | 69 | if grep -q '^int main(' "$i"; then |
64 | putmain $i | 70 | putmain "$i" |
65 | fi | 71 | fi |
66 | done | 72 | done |
67 | 73 | ||
68 | echo "static void call(int m(), int argc, char **argv) { m(); }" >> amalgamation.cc | 74 | echo "static void call(int m(), int argc, char **argv) { m(); }" >> amalgamation.cc |
69 | echo "static void call(int m(int, char **), int argc, char **argv) { m(argc, argv); }" >> amalgamation.cc | 75 | echo "static void call(int m(int, char **), int argc, char **argv) { m(argc, argv); }" >> amalgamation.cc |
76 | echo '} // namespace' >> amalgamation.cc | ||
70 | 77 | ||
71 | echo "int main(int argc, char **argv) {" >> amalgamation.cc | 78 | echo "int main(int argc, char **argv) {" >> amalgamation.cc |
72 | for i in $(eval $FIND_QUERY); do | 79 | for i in $(eval "$FIND_QUERY"); do |
73 | if grep -q '^int main(' $i; then | 80 | if grep -q '^int main(' "$i"; then |
74 | callmain $i | 81 | callmain "$i" |
75 | fi | 82 | fi |
76 | done | 83 | done |
77 | echo " return 0;" >> amalgamation.cc | 84 | echo " return 0;" >> amalgamation.cc |
diff --git a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 index 5287541b..4d02d38f 100644 --- a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 +++ b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 | |||
@@ -1 +1 @@ | |||
e7b6d31485b5e1561659be08f3e3ef003cef186042d7e0fe2ef48cf341932b5a /usr/local/bin/tox-bootstrapd | 89df21d6a19a1b6652db5b7e6e9f65ad5f8be8abdca9f58645548b9e0c9383e3 /usr/local/bin/tox-bootstrapd | ||
diff --git a/other/cpufeatures.c b/other/cpufeatures.c index 3da06e58..38c97059 100644 --- a/other/cpufeatures.c +++ b/other/cpufeatures.c | |||
@@ -3,4 +3,4 @@ | |||
3 | #include ANDROID_CPU_FEATURES | 3 | #include ANDROID_CPU_FEATURES |
4 | #endif | 4 | #endif |
5 | 5 | ||
6 | extern int unused_declaration; | 6 | typedef int unused_declaration; |