summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/dist/s_clang_scan
diff options
context:
space:
mode:
authorChenhao Qu <chenhao.qu@mongodb.com>2022-12-14 17:01:29 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-12-14 06:31:43 +0000
commit8edf44dfc61517bd9a7a3c10561b73777ab996cd (patch)
treed8142dab9f4d30cc10d399ef04f7343a6f385629 /src/third_party/wiredtiger/dist/s_clang_scan
parentf6cf5e93e5f19b4b177bfe061c07c24a2592491f (diff)
downloadmongo-8edf44dfc61517bd9a7a3c10561b73777ab996cd.tar.gz
Import wiredtiger: 13e6e4b7b6f39d0a82ea4928eb16f662c8c0fb72 from branch mongodb-master
ref: 2b8094ae06..13e6e4b7b6 for: 6.3.0-rc0 WT-10295 Rename dist clang-format, clang-scan, and clang-tidy scripts
Diffstat (limited to 'src/third_party/wiredtiger/dist/s_clang_scan')
-rw-r--r--src/third_party/wiredtiger/dist/s_clang_scan64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/third_party/wiredtiger/dist/s_clang_scan b/src/third_party/wiredtiger/dist/s_clang_scan
new file mode 100644
index 00000000000..a0e941a309a
--- /dev/null
+++ b/src/third_party/wiredtiger/dist/s_clang_scan
@@ -0,0 +1,64 @@
+#! /bin/sh
+
+t_out=__wt.$$.out
+t_err=__wt.$$.err
+a=__wt.$$.a
+b=__wt.$$.b
+t_build=__s_clang_scan_tmp_build
+trap 'rm -rf $a $b $t_out $t_err $t_build' 0 1 2 3 13 15
+
+# Find the top-level WiredTiger directory and move to there.
+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/bin/scan-build; then
+ compiler="/usr/bin/clang"
+ scan="/usr/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"
+
+# Remove old reports.
+rm -rf clangScanBuildReports && mkdir clangScanBuildReports
+rm -rf ${t_build} && mkdir ${t_build}
+
+cd ${t_build}
+args="-o clangScanBuildReports"
+args="$args --use-cc=$compiler"
+args="$args -disable-checker core.NullDereference"
+$scan $args cmake CMAKE_C_FLAGS=-g \
+ -DENABLE_STATIC=1 -DENABLE_SHARED=0 -DHAVE_DIAGNOSTIC=1 -DENABLE_STRICT=1 ../.> /dev/null
+$scan $args make -j 8 wt 1>../$t_out 2>../$t_err
+cd ..
+
+grep 'No bugs found' $t_out > /dev/null && exit 0
+
+# Compare the set of errors/warnings and exit success when they're expected.
+# clang_scan outputs errors/warnings with a leading file path followed by a
+# colon, followed by the string "error:" or "warning:".
+cat dist/s_clang_scan.diff |
+ egrep '^[a-z\./].*error: |^[a-z\./].*warning: ' | sed -e 's/:.*:.*://' | sort > $a
+cat $t_err |
+ egrep '^[a-z\./].*error: |^[a-z\./].*warning: ' | sed -e 's/:.*:.*://' | sort > $b
+diff $a $b > /dev/null && exit 0
+
+echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
+echo 'scan-build output differs from expected:'
+echo '<<<<<<<<<< Expected >>>>>>>>>> Current'
+echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
+diff dist/s_clang_scan.diff $t_err
+exit 1