#!/bin/sh
#
# Run clang-tidy in fix mode and verify the result.

INPUT_FILE=$1
CHECK_TO_RUN=$2
TEMPORARY_FILE=$3.cpp

grep -Ev "// *[A-Z-]+:" ${INPUT_FILE} > ${TEMPORARY_FILE}
clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" -- --std=c++11 > ${TEMPORARY_FILE}.msg 2>&1
FileCheck -input-file=${TEMPORARY_FILE} ${INPUT_FILE} -strict-whitespace || exit $?
if grep CHECK-MESSAGES ${INPUT_FILE}; then
  FileCheck -input-file=${TEMPORARY_FILE}.msg ${INPUT_FILE} -check-prefix=CHECK-MESSAGES || exit $?
fi

#!/bin/sh
#
# Run clang-tidy in fix mode and verify the result.

INPUT_FILE=$1
CHECK_TO_RUN=$2
TEMPORARY_FILE=$3.cpp

grep -Ev "// *[A-Z-]+:" ${INPUT_FILE} > ${TEMPORARY_FILE}
clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" -- --std=c++11 > ${TEMPORARY_FILE}.msg 2>&1
FileCheck -input-file=${TEMPORARY_FILE} ${INPUT_FILE} -strict-whitespace
not grep CHECK-MESSAGES ${INPUT_FILE} || FileCheck -input-file=${TEMPORARY_FILE}.msg ${INPUT_FILE} -check-prefix=CHECK-MESSAGES

--- 
+++ 
@@ -8,5 +8,7 @@
 
 grep -Ev "// *[A-Z-]+:" ${INPUT_FILE} > ${TEMPORARY_FILE}
 clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" -- --std=c++11 > ${TEMPORARY_FILE}.msg 2>&1
-FileCheck -input-file=${TEMPORARY_FILE} ${INPUT_FILE} -strict-whitespace
-not grep CHECK-MESSAGES ${INPUT_FILE} || FileCheck -input-file=${TEMPORARY_FILE}.msg ${INPUT_FILE} -check-prefix=CHECK-MESSAGES
+FileCheck -input-file=${TEMPORARY_FILE} ${INPUT_FILE} -strict-whitespace || exit $?
+if grep CHECK-MESSAGES ${INPUT_FILE}; then
+  FileCheck -input-file=${TEMPORARY_FILE}.msg ${INPUT_FILE} -check-prefix=CHECK-MESSAGES || exit $?
+fi
Use explicit if and restore lost FileCheck error code checking.

git-svn-id: a34e9779ed74578ad5922b3306b3d80a0c825546@212546 91177308-0d34-0410-b5e6-96231b3b80d8
