Mercurial > hg > sonic-visualiser
changeset 2123:7c30a7f20c6a fix-static-analysis
Add run-clang-tidy script
author | Chris Cannam |
---|---|
date | Thu, 22 Nov 2018 14:57:22 +0000 |
parents | 45f36811117c |
children | 124de219669f |
files | misc/run-clang-tidy.sh |
diffstat | 1 files changed, 61 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/run-clang-tidy.sh Thu Nov 22 14:57:22 2018 +0000 @@ -0,0 +1,61 @@ +#!/bin/bash + +usage() { + echo + echo " $0: run clang-tidy on a build with supplied arguments" 1>&2 + echo + echo " Run this from the root of the source tree, on a Linux system." 1>&2 + echo " Assumes that \"./configure && make clean && make\" will produce a successful" 1>&2 + echo " build using g++." 1>&2 + echo " All arguments are passed to clang-tidy." 1>&2 + echo + exit 2 +} + +if [ t"$1" = "t" ]; then + usage +fi + +ctargs="$@" + +echo "clang-tidy args: $ctargs" + +set -eu + +tmpdir=$(mktemp -d) +trap "rm -rf \$tmpdir\$" 0 + +#log="build.log" + +log="$tmpdir/make.log" +./configure +make clean +make -j3 2>&1 | tee "$log" + +list="$tmpdir/tidy.list" + +grep '^g[+][+] ' "$log" | grep ' [-]c ' > "$list" + +cat "$list" | while read line ; do + + filename=${line##* } + remainder=${line% *} + cc=${remainder%% *} + ccargs=${remainder#* } + + ccargs=$(echo "$ccargs" | sed 's/-flto //') + + echo + + case "$filename" in + bq*) echo "ignoring $filename" ;; + o/*) echo "ignoring $filename" ;; + vamp-*) echo "ignoring $filename" ;; + dataquay/*) echo "ignoring $filename" ;; + src/*) echo "ignoring $filename" ;; + *) echo "not ignoring $filename" + echo clang-tidy $ctargs "$filename" -- $ccargs ; + clang-tidy $ctargs "$filename" -- $ccargs ;; + esac +done +