summaryrefslogtreecommitdiff
path: root/other/analysis
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-07-17 01:18:04 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-07-22 02:34:30 +0000
commitf627a26a7b1c3619ba66f84b87092ff8ba7a95b6 (patch)
treec72c950fab473dc9bec4b5329d251b790e55443d /other/analysis
parent7245ac11ef9be2420c8356c12acc79f93ea211bb (diff)
Run Clang global static analysis on Travis.
This uses a single .cc file containing almost all the code in the repository to perform whole program analysis.
Diffstat (limited to 'other/analysis')
-rw-r--r--other/analysis/gen-file.sh116
-rwxr-xr-xother/analysis/run-clang22
-rwxr-xr-xother/analysis/run-clang-analyze8
-rwxr-xr-xother/analysis/run-cppcheck4
-rwxr-xr-xother/analysis/run-gcc23
-rwxr-xr-xother/analysis/run-infer4
-rwxr-xr-xother/analysis/run-sparse9
7 files changed, 110 insertions, 76 deletions
diff --git a/other/analysis/gen-file.sh b/other/analysis/gen-file.sh
index 710e20d7..89144eff 100644
--- a/other/analysis/gen-file.sh
+++ b/other/analysis/gen-file.sh
@@ -1,48 +1,80 @@
1CPPFLAGS="-DMIN_LOGGER_LEVEL=LOG_TRACE -Iauto_tests -Itoxcore -Itoxav -Itoxencryptsave `pkg-config --cflags libsodium opus vpx`" 1#!/bin/sh
2
3CPPFLAGS="$CPPFLAGS -DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE"
4CPPFLAGS="$CPPFLAGS -isystem /usr/include/opus"
5CPPFLAGS="$CPPFLAGS -Iauto_tests"
6CPPFLAGS="$CPPFLAGS -Iother"
7CPPFLAGS="$CPPFLAGS -Iother/bootstrap_daemon/src"
8CPPFLAGS="$CPPFLAGS -Iother/fun"
9CPPFLAGS="$CPPFLAGS -Itesting"
10CPPFLAGS="$CPPFLAGS -Itoxcore"
11CPPFLAGS="$CPPFLAGS -Itoxav"
12CPPFLAGS="$CPPFLAGS -Itoxencryptsave"
13
14LDFLAGS="$LDFLAGS -lopus -lsodium -lvpx -lpthread -lconfig"
2 15
3put() { 16put() {
4 if [ "$SKIP_LINES" = "" ]; then 17 if [ "$SKIP_LINES" = "" ]; then
5 echo "#line 1 \"$1\"" >> test.c 18 echo "#line 1 \"$1\"" >> amalgamation.cc
19 fi
20 cat $1 >> amalgamation.cc
21}
22
23putmain() {
24 echo "namespace $(echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g') {" >> amalgamation.cc
25 if [ "$SKIP_LINES" = "" ]; then
26 echo "#line 1 \"$1\"" >> amalgamation.cc
6 fi 27 fi
7 cat $1 >> test.c 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
30}
31
32callmain() {
33 echo " call($(echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g')::main, argc, argv);" >> amalgamation.cc
8} 34}
9 35
10:> test.c 36:> amalgamation.cc
11 37
12put toxcore/tox.c 38echo "#include <algorithm>" >> amalgamation.cc
13 39echo "#include <cstdio>" >> amalgamation.cc
14put toxcore/DHT.c 40echo "#include <memory>" >> amalgamation.cc
15put toxcore/LAN_discovery.c 41echo "#include <random>" >> amalgamation.cc
16put toxcore/Messenger.c 42
17put toxcore/TCP_client.c 43echo "#define TOX_DEFINED" >> amalgamation.cc
18put toxcore/TCP_connection.c 44echo "typedef struct Messenger Tox;" >> amalgamation.cc
19put toxcore/TCP_server.c 45
20put toxcore/crypto_core.c 46put auto_tests/check_compat.h
21put toxcore/crypto_core_mem.c 47
22put toxcore/friend_connection.c 48FIND_QUERY="find . '-(' -name '*.cc' -or -name '*.c' '-)'"
23put toxcore/friend_requests.c 49FIND_QUERY="$FIND_QUERY -and -not -wholename './super_donators/*'"
24put toxcore/group.c 50FIND_QUERY="$FIND_QUERY -and -not -wholename './toxav/*.cc'"
25put toxcore/list.c 51FIND_QUERY="$FIND_QUERY -and -not -wholename './toxcore/*.cc'"
26put toxcore/logger.c 52FIND_QUERY="$FIND_QUERY -and -not -wholename './toxencryptsave/*.cc'"
27put toxcore/network.c 53FIND_QUERY="$FIND_QUERY -and -not -name amalgamation.cc"
28put toxcore/net_crypto.c 54FIND_QUERY="$FIND_QUERY -and -not -name av_test.c"
29put toxcore/onion.c 55FIND_QUERY="$FIND_QUERY -and -not -name dht_test.c"
30put toxcore/onion_announce.c 56FIND_QUERY="$FIND_QUERY -and -not -name version_test.c"
31put toxcore/onion_client.c 57
32put toxcore/ping.c 58for i in $(eval $FIND_QUERY); do
33put toxcore/ping_array.c 59 if ! grep -q '^int main(' $i; then
34put toxcore/tox_api.c 60 put $i
35put toxcore/util.c 61 fi
36 62done
37# Not included yet, since there are too many issues with this code. 63
38#put toxav/audio.c 64for i in $(eval $FIND_QUERY); do
39#put toxav/bwcontroller.c 65 if grep -q '^int main(' $i; then
40#put toxav/groupav.c 66 putmain $i
41#put toxav/msi.c 67 fi
42#put toxav/ring_buffer.c 68done
43#put toxav/rtp.c 69
44#put toxav/toxav.c 70echo "static void call(int m(), int argc, char **argv) { m(); }" >> amalgamation.cc
45#put toxav/toxav_old.c 71echo "static void call(int m(int, char **), int argc, char **argv) { m(argc, argv); }" >> amalgamation.cc
46#put toxav/video.c 72
47 73echo "int main(int argc, char **argv) {" >> amalgamation.cc
48put toxencryptsave/toxencryptsave.c 74for i in $(eval $FIND_QUERY); do
75 if grep -q '^int main(' $i; then
76 callmain $i
77 fi
78done
79echo " return 0;" >> amalgamation.cc
80echo "}" >> amalgamation.cc
diff --git a/other/analysis/run-clang b/other/analysis/run-clang
index 1c8da7ea..60e59eab 100755
--- a/other/analysis/run-clang
+++ b/other/analysis/run-clang
@@ -2,6 +2,22 @@
2 2
3. other/analysis/gen-file.sh 3. other/analysis/gen-file.sh
4 4
5put auto_tests/lan_discovery_test.c 5echo "Running Clang compiler"
6 6clang++ -o /dev/null amalgamation.cc \
7clang --analyze test.c $CPPFLAGS 7 $CPPFLAGS \
8 $LDFLAGS \
9 -std=c++11 \
10 -Weverything \
11 -Wno-c++98-compat-pedantic \
12 -Wno-c99-extensions \
13 -Wno-cast-align \
14 -Wno-conversion \
15 -Wno-covered-switch-default \
16 -Wno-documentation-deprecated-sync \
17 -Wno-missing-field-initializers \
18 -Wno-old-style-cast \
19 -Wno-padded \
20 -Wno-sign-compare \
21 -Wno-unreachable-code-return \
22 -Wno-unused-parameter \
23 -Wno-used-but-marked-unused \
diff --git a/other/analysis/run-clang-analyze b/other/analysis/run-clang-analyze
new file mode 100755
index 00000000..0e6d9af0
--- /dev/null
+++ b/other/analysis/run-clang-analyze
@@ -0,0 +1,8 @@
1#!/bin/sh
2
3. other/analysis/gen-file.sh
4
5echo "Running Clang static analyzer"
6clang++ --analyze amalgamation.cc \
7 $CPPFLAGS \
8 -std=c++11
diff --git a/other/analysis/run-cppcheck b/other/analysis/run-cppcheck
index 9e928c9a..dc369840 100755
--- a/other/analysis/run-cppcheck
+++ b/other/analysis/run-cppcheck
@@ -2,6 +2,4 @@
2 2
3. other/analysis/gen-file.sh 3. other/analysis/gen-file.sh
4 4
5put auto_tests/lan_discovery_test.c 5cppcheck amalgamation.cc $CPPFLAGS
6
7cppcheck test.c $CPPFLAGS
diff --git a/other/analysis/run-gcc b/other/analysis/run-gcc
index ffd42f4e..3ea32782 100755
--- a/other/analysis/run-gcc
+++ b/other/analysis/run-gcc
@@ -2,12 +2,14 @@
2 2
3. other/analysis/gen-file.sh 3. other/analysis/gen-file.sh
4 4
5put auto_tests/lan_discovery_test.c 5echo "Running GCC"
6
7# TODO(iphydf): Get rid of all VLAs, then enable -fstack-protector -Wstack-protector 6# TODO(iphydf): Get rid of all VLAs, then enable -fstack-protector -Wstack-protector
8gcc -O3 -c -o /dev/null test.c $CPPFLAGS \ 7g++ -O3 -o /dev/null amalgamation.cc \
9 -std=c99 \ 8 $CPPFLAGS \
9 $LDFLAGS \
10 -std=c++11 \
10 -pedantic \ 11 -pedantic \
12 -fdiagnostics-color=always \
11 -Wall \ 13 -Wall \
12 -Wextra \ 14 -Wextra \
13 -Wno-aggregate-return \ 15 -Wno-aggregate-return \
@@ -22,18 +24,9 @@ gcc -O3 -c -o /dev/null test.c $CPPFLAGS \
22 -Wno-unused-parameter \ 24 -Wno-unused-parameter \
23 -Wstrict-aliasing=0 \ 25 -Wstrict-aliasing=0 \
24 -Wstrict-overflow=1 \ 26 -Wstrict-overflow=1 \
25 \ 27 \
26 -Wbad-function-cast \
27 -Wmissing-declarations \ 28 -Wmissing-declarations \
28 -Wmissing-parameter-type \
29 -Wmissing-prototypes \
30 -Wnested-externs \
31 -Wold-style-declaration \
32 -Wold-style-definition \
33 -Wstrict-prototypes \
34 -Wbool-compare \ 29 -Wbool-compare \
35 -Wc99-c11-compat \
36 -Wc++-compat \
37 -Wcast-align \ 30 -Wcast-align \
38 -Wcast-qual \ 31 -Wcast-qual \
39 -Wchar-subscripts \ 32 -Wchar-subscripts \
@@ -45,10 +38,8 @@ gcc -O3 -c -o /dev/null test.c $CPPFLAGS \
45 -Wformat=2 \ 38 -Wformat=2 \
46 -Wframe-address \ 39 -Wframe-address \
47 -Wframe-larger-than=133168 \ 40 -Wframe-larger-than=133168 \
48 -Wjump-misses-init \
49 -Wignored-qualifiers \ 41 -Wignored-qualifiers \
50 -Wignored-attributes \ 42 -Wignored-attributes \
51 -Wincompatible-pointer-types \
52 -Winit-self \ 43 -Winit-self \
53 -Winline \ 44 -Winline \
54 -Wlarger-than=133120 \ 45 -Wlarger-than=133120 \
diff --git a/other/analysis/run-infer b/other/analysis/run-infer
index 942d0cfd..2a897227 100755
--- a/other/analysis/run-infer
+++ b/other/analysis/run-infer
@@ -5,6 +5,4 @@ SKIP_LINES=1
5 5
6. other/analysis/gen-file.sh 6. other/analysis/gen-file.sh
7 7
8put auto_tests/lan_discovery_test.c 8infer -- clang++ -fsyntax-only amalgamation.cc $CPPFLAGS
9
10infer -- clang -fsyntax-only test.c $CPPFLAGS
diff --git a/other/analysis/run-sparse b/other/analysis/run-sparse
deleted file mode 100755
index b4d0f736..00000000
--- a/other/analysis/run-sparse
+++ /dev/null
@@ -1,9 +0,0 @@
1#!/bin/sh
2
3. other/analysis/gen-file.sh
4
5put auto_tests/lan_discovery_test.c
6
7sparse test.c $CPPFLAGS \
8 -Wsparse-all \
9 -Wno-declaration-after-statement