summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/dist/s_clang-scan
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/dist/s_clang-scan')
-rw-r--r--src/third_party/wiredtiger/dist/s_clang-scan70
1 files changed, 36 insertions, 34 deletions
diff --git a/src/third_party/wiredtiger/dist/s_clang-scan b/src/third_party/wiredtiger/dist/s_clang-scan
index 33d6f3e7d9e..72616f9e9d4 100644
--- a/src/third_party/wiredtiger/dist/s_clang-scan
+++ b/src/third_party/wiredtiger/dist/s_clang-scan
@@ -1,50 +1,52 @@
#! /bin/sh
t=__wt.$$
-trap 'rm -rf $t /tmp/scan-build-*' 0 1 2 3 13 15
+trap 'rm -rf $t' 0 1 2 3 13 15
-# Installation of the clang development package isn't standard, list a
-# couple of the places we're using.
-export PATH=$PATH:/usr/local/clang50/bin:/usr/local/llvm-devel/bin
-
-# Remove old reports.
-rm -rf /tmp/scan-build-*
+set -e
# Find the top-level WiredTiger directory and move to there.
-p="$PWD"
-while test "$p" != "/" ; do
- if test -d "$p/build_posix"; then
- break;
- fi
- p=`dirname $p`
-done
-test "$p" != "/" || {
- echo "$0: cannot find the WiredTiger top-level directory"
+top=`git rev-parse --show-toplevel` && cd $top || exit 1
+echo "$0: running scan-build in $PWD"
+
+# Clang isn't installed in any standard place, find a binary we can use.
+# If the caller gives us $SCANBUILD, check for $SCANCOMPILER and default
+# to "clang".
+scan="$SCANBUILD"
+test -z "$scan" || compiler="${SCANCOMPILER:-clang}"
+
+if test -z "$scan" &&
+ test -x /usr/bin/clang &&
+ test -x /usr/lib/llvm-3.9/bin/scan-build; then
+ compiler="/usr/bin/clang"
+ scan="/usr/lib/llvm-3.9/bin/scan-build"
+fi
+
+if test -z "$scan"; then
+ echo "$0: no clang compiler and scan-build programs found"
+ echo "$0: set \$SCANCOMPILER=/path/clang and \$SCANBUILD=/path/scan-build to continue"
exit 1
-}
+fi
+echo "$0: compiler: $compiler"
+echo "$0: scan-build: $scan"
-cd $p || exit 1
-echo "$0: running scan-build in $p..."
+# Remove old reports.
+rm -rf clangScanBuildReports && mkdir clangScanBuildReports
sh autogen.sh > /dev/null || exit 1
-args="--use-cc=clang40 -no-failure-reports"
+args="-o clangScanBuildReports"
+args="$args --use-cc=$compiler"
args="$args -disable-checker core.NullDereference"
-scan-build $args ./configure 'CFLAGS=-g -Wall' \
+$scan $args ./configure 'CFLAGS=-g' \
--disable-shared --enable-diagnostic --enable-strict > /dev/null
-scan-build $args make -j 8 wt 2>&1 > $t
+$scan $args make -j 8 wt 1>/dev/null 2>$t
make -j 8 distclean > /dev/null
-grep 'No bugs found' $t > /dev/null || {
- echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
- echo 'unexpected scan-build output'
- echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
- sed -e '/^--- /d' \
- -e '/^\/bin\/sh /d' \
- -e '/^depbase=/d' \
- -e '/^libtool: /d' < $t
- exit 1
-}
-
-exit 0
+grep 'No bugs found' $t > /dev/null && exit 0
+echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
+echo 'scan-build output:'
+echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
+cat $t
+exit 1