osquery-1/tools/analysis/clang-analyze.sh

47 lines
789 B
Bash
Raw Normal View History

#!/bin/bash
# Copyright (c) 2014, Ruslan Baratov
# All rights reserved.
declare -a BLACKLIST=(
"logging.cc"
"logging_unittest.cc"
2015-04-17 00:40:19 +00:00
"signalhandler_unittest.cc"
2015-08-16 03:43:53 +00:00
"string_util.cc"
"sysinfo.cc"
)
for BL_ITEM in ${BLACKLIST[@]}; do
if [[ "$@" == *"${BL_ITEM}"* ]]; then
clang++ "$@"
exit 0;
fi
done
for x in "$@"; do
if [ ! "${x}" == "-c" ]; then
continue
fi
OUTPUT="`mktemp /tmp/clang-analyze.out.XXXXX`"
BINARY="`mktemp /tmp/clang-analyze.bin.XXXXX`"
# analyze
clang++ --analyze "$@" -o "${BINARY}" 2> "${OUTPUT}"
RESULT=0
[ "$?" == 0 ] || RESULT=1
[ -s "${OUTPUT}" ] && RESULT=1
cat "${OUTPUT}";
rm -f "${OUTPUT}"
rm -f "${BINARY}"
if [ "${RESULT}" == "1" ]; then
exit 1;
fi
done
# compile real code
clang++ "$@"