Skip to content

Commit 894b33f

Browse files
committed
[BoundsSafety] Add script to automatically regenerate -fbound-safety codegen tests
This is to help fix the tests failures in rdar://148767987
1 parent ed0050b commit 894b33f

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
function usage() {
4+
echo "$0 --bin-dir"
5+
echo ""
6+
}
7+
8+
BIN_DIR=""
9+
10+
while [ -n "$1" ]; do
11+
case "$1" in
12+
--bin-dir)
13+
shift
14+
BIN_DIR="$1"
15+
;;
16+
--help|-h)
17+
usage
18+
exit 0
19+
;;
20+
*)
21+
echo "Unrecognized option \"${1}\""
22+
exit 1
23+
;;
24+
esac
25+
shift
26+
done
27+
28+
if [ ! -d "${BIN_DIR}" ]; then
29+
echo "BIN_DIR (${BIN_DIR}) does not exist"
30+
exit 1
31+
fi
32+
33+
LLVM_ROOT=$( cd "${BASH_SOURCE[0]%/*}/../../" ; pwd )
34+
echo "LLVM_ROOT:${LLVM_ROOT}"
35+
36+
if [ ! -d "${LLVM_ROOT}" ]; then
37+
echo "LLVM_ROOT (${LLVM_ROOT}) does not exist"
38+
exit 1
39+
fi
40+
41+
TEST_ROOT="${LLVM_ROOT}/clang/test"
42+
43+
if [ ! -d "${TEST_ROOT}" ]; then
44+
echo "TEST_ROOT (${TEST_ROOT}) does not exist"
45+
exit 1
46+
fi
47+
48+
UPDATE_SCRIPT="${LLVM_ROOT}/llvm/utils/update_cc_test_checks.py"
49+
50+
if [ ! -f "${UPDATE_SCRIPT}" ]; then
51+
echo "UPDATE_SCRIPT (${UPDATE_SCRIPT}) does not exist"
52+
exit 1
53+
fi
54+
55+
56+
# Add test paths here:
57+
# E.g:
58+
# TESTS=( \
59+
# BoundsSafety/CodeGen/constant-forge-ptr-expr.c \
60+
# )
61+
TESTS=( )
62+
63+
for t in "${TESTS[@]}"; do
64+
TEST=${TEST_ROOT}/$t
65+
echo "Processing ${TEST}"
66+
if [ ! -f "${TEST}" ]; then
67+
echo "Can't find ${TEST}"
68+
exit 1
69+
fi
70+
71+
# Skip tests that aren't automatically generated codegen tests
72+
IS_CODEGEN_TEST="$(grep -Ec 'Assertions have been autogenerated by utils/update_cc_test_checks\.py' ${TEST})"
73+
if [ "${IS_CODEGEN_TEST}" -eq 0 ]; then
74+
echo "Skipping non-codgen test"
75+
continue
76+
fi
77+
78+
# Note we assume BSD/macOS sed
79+
80+
# Disable the Objective-C RUN lines because they cause problems with the updating script because IR conflicts
81+
sed -E -n -I '' '/^\/\/ RUN:.+-fbounds-attributes-objc-experimental/s/\/\/ RUN:/\/\/ XXX_run:/;p' ${TEST}
82+
83+
# Update the codegen CHECK lines
84+
"${UPDATE_SCRIPT}" --llvm-bin "${BIN_DIR}" ${TEST}
85+
86+
# Re-enable the Objective-C RUN lines.
87+
sed -E -n -I '' '/^\/\/ XXX_run:.+-fbounds-attributes-objc-experimental/s/\/\/ XXX_run:/\/\/ RUN:/;p' ${TEST}
88+
89+
done

0 commit comments

Comments
 (0)