iwyu: Add patch to prefer angled brackets over quotes for includes

This commit is contained in:
Hennadii Stepanov
2025-12-17 20:28:42 +00:00
parent fe0e31f1ef
commit 7a65437e23
4 changed files with 17 additions and 1 deletions

1
.gitignore vendored
View File

@@ -12,6 +12,7 @@
# Only ignore unexpected patches
*.patch
!ci/test/*.patch
!contrib/guix/patches/*.patch
!depends/patches/**/*.patch

View File

@@ -81,6 +81,7 @@ fi
if [[ "${RUN_TIDY}" == "true" ]]; then
${CI_RETRY_EXE} git clone --depth=1 https://github.com/include-what-you-use/include-what-you-use -b clang_"${TIDY_LLVM_V}" /include-what-you-use
(cd /include-what-you-use && patch -p1 < /ci_container_base/ci/test/01_iwyu.patch)
cmake -B /iwyu-build/ -G 'Unix Makefiles' -DCMAKE_PREFIX_PATH=/usr/lib/llvm-"${TIDY_LLVM_V}" -S /include-what-you-use
make -C /iwyu-build/ install "$MAKEJOBS"
fi

14
ci/test/01_iwyu.patch Normal file
View File

@@ -0,0 +1,14 @@
Prefer angled brackets over quotes for include directives.
See: https://en.cppreference.com/w/cpp/preprocessor/include.html.
--- a/iwyu_path_util.cc
+++ b/iwyu_path_util.cc
@@ -211,7 +211,7 @@ bool IsQuotedInclude(const string& s) {
}
string AddQuotes(string include_name, bool angled) {
- if (angled) {
+ if (true) {
return "<" + include_name + ">";
}
return "\"" + include_name + "\"";

View File

@@ -15,7 +15,7 @@ ARG BASE_ROOT_DIR
ENV BASE_ROOT_DIR=${BASE_ROOT_DIR}
COPY ./ci/retry/retry /usr/bin/retry
COPY ./ci/test/00_setup_env.sh ./${FILE_ENV} ./ci/test/01_base_install.sh /ci_container_base/ci/test/
COPY ./ci/test/00_setup_env.sh ./${FILE_ENV} ./ci/test/01_base_install.sh ./ci/test/01_iwyu.patch /ci_container_base/ci/test/
# Bash is required, so install it when missing
RUN sh -c "bash -c 'true' || ( apk update && apk add --no-cache bash )"