Mercurial > hg > sonic-visualiser
comparison misc/run-clang-tidy.sh @ 2123:7c30a7f20c6a fix-static-analysis
Add run-clang-tidy script
author | Chris Cannam |
---|---|
date | Thu, 22 Nov 2018 14:57:22 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2122:45f36811117c | 2123:7c30a7f20c6a |
---|---|
1 #!/bin/bash | |
2 | |
3 usage() { | |
4 echo | |
5 echo " $0: run clang-tidy on a build with supplied arguments" 1>&2 | |
6 echo | |
7 echo " Run this from the root of the source tree, on a Linux system." 1>&2 | |
8 echo " Assumes that \"./configure && make clean && make\" will produce a successful" 1>&2 | |
9 echo " build using g++." 1>&2 | |
10 echo " All arguments are passed to clang-tidy." 1>&2 | |
11 echo | |
12 exit 2 | |
13 } | |
14 | |
15 if [ t"$1" = "t" ]; then | |
16 usage | |
17 fi | |
18 | |
19 ctargs="$@" | |
20 | |
21 echo "clang-tidy args: $ctargs" | |
22 | |
23 set -eu | |
24 | |
25 tmpdir=$(mktemp -d) | |
26 trap "rm -rf \$tmpdir\$" 0 | |
27 | |
28 #log="build.log" | |
29 | |
30 log="$tmpdir/make.log" | |
31 ./configure | |
32 make clean | |
33 make -j3 2>&1 | tee "$log" | |
34 | |
35 list="$tmpdir/tidy.list" | |
36 | |
37 grep '^g[+][+] ' "$log" | grep ' [-]c ' > "$list" | |
38 | |
39 cat "$list" | while read line ; do | |
40 | |
41 filename=${line##* } | |
42 remainder=${line% *} | |
43 cc=${remainder%% *} | |
44 ccargs=${remainder#* } | |
45 | |
46 ccargs=$(echo "$ccargs" | sed 's/-flto //') | |
47 | |
48 echo | |
49 | |
50 case "$filename" in | |
51 bq*) echo "ignoring $filename" ;; | |
52 o/*) echo "ignoring $filename" ;; | |
53 vamp-*) echo "ignoring $filename" ;; | |
54 dataquay/*) echo "ignoring $filename" ;; | |
55 src/*) echo "ignoring $filename" ;; | |
56 *) echo "not ignoring $filename" | |
57 echo clang-tidy $ctargs "$filename" -- $ccargs ; | |
58 clang-tidy $ctargs "$filename" -- $ccargs ;; | |
59 esac | |
60 done | |
61 |