Skip to content

Commit 14ba061

Browse files
committed
test/cfg/runtests.sh: run with include-what-you-use when IWYU environment variable is specified
1 parent 8833e3e commit 14ba061

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

test/cfg/runtests.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ CXX_OPT=("-fsyntax-only" "-w" "-std=c++2a")
4646
CC=gcc
4747
CC_OPT=("-fsyntax-only" "-w" "-std=c11")
4848

49+
IWYU_OPTS=("-Xiwyu" "--no_fwd_decls" "-Xiwyu" "--update_comments")
50+
4951
function get_pkg_config_cflags {
5052
# TODO: get rid of the error enabling/disabling?
5153
set +e
@@ -63,16 +65,31 @@ function get_pkg_config_cflags {
6365
echo "$PKGCONFIG"
6466
}
6567

68+
function iwyu_run {
69+
# TODO: convert -I includes provided by pkg-config to -isystem so IWYU does not produce warnings for system headers
70+
${IWYU} "${IWYU_OPTS[@]}" "$@"
71+
}
72+
6673
function cc_syntax {
67-
${CC} "${CC_OPT[@]}" "$@"
74+
if [ -z "$IWYU" ]; then
75+
${CC} "${CC_OPT[@]}" "$@"
76+
else
77+
iwyu_run "${CC_OPT[@]}" "$@"
78+
fi
6879
}
6980

7081
function cxx_syntax {
71-
${CXX} "${CXX_OPT[@]}" "$@"
82+
if [ -z "$IWYU" ]; then
83+
${CXX} "${CXX_OPT[@]}" "$@"
84+
else
85+
iwyu_run "${CXX_OPT[@]}" "$@"
86+
fi
7287
}
7388

7489
function cppcheck_run {
75-
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" "$@"
90+
if [ -z "$IWYU" ]; then
91+
"${CPPCHECK}" "${CPPCHECK_OPT[@]}" "$@"
92+
fi
7693
}
7794

7895
# posix.c
@@ -239,6 +256,7 @@ function sqlite3_fn {
239256

240257
# openmp.c
241258
function openmp_fn {
259+
# TODO: omp.h not found with IWYU
242260
# MacOS compiler has no OpenMP by default
243261
if ! command -v sw_vers; then
244262
echo "OpenMP assumed to be present, checking syntax with ${CC} now."

0 commit comments

Comments
 (0)