Skip to content

Commit

Permalink
clang-format: Enable --Wno-error=unknown for compat with older vers…
Browse files Browse the repository at this point in the history
…ions

This prevents errors when encountering options which have been defined in newer
versions of clang-format, and are invalid in the YAML for the old version.

Bump minimum supported clang-format version to 12 (where `--Wno-error=unknown`
was added).

Use clang-format 12 on CI (13 is not available yet on the Ubuntu 20.04 images).

(cherry picked from commit 55d0556)
  • Loading branch information
akien-mga committed Oct 25, 2021
1 parent fe0cbe6 commit d09b33d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get install -qq dos2unix recode clang-format-11
sudo apt-get install -qq dos2unix recode clang-format-12
sudo update-alternatives --remove-all clang-format
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 100
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-12 100
sudo pip3 install black==20.8b1 pygments
- name: File formatting checks (file_format.sh)
Expand Down
4 changes: 2 additions & 2 deletions misc/hooks/pre-commit-clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fi

# To get consistent formatting, we recommend contributors to use the same
# clang-format version as CI.
RECOMMENDED_CLANG_FORMAT_MAJOR_MIN="11"
RECOMMENDED_CLANG_FORMAT_MAJOR_MIN="12"
RECOMMENDED_CLANG_FORMAT_MAJOR_MAX="13"

if [ ! -x "$CLANG_FORMAT" ] ; then
Expand Down Expand Up @@ -146,7 +146,7 @@ do
# +++ - timestamp
# to both lines working on the same file and having a/ and b/ prefix.
# Else it can not be applied with 'git apply'.
"$CLANG_FORMAT" -style=file "$file" | \
"$CLANG_FORMAT" -style=file "$file" --Wno-error=unknown | \
diff -u "$file" - | \
sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch"
done
Expand Down
2 changes: 1 addition & 1 deletion misc/scripts/clang_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ while IFS= read -rd '' f; do
for extension in ${CLANG_FORMAT_FILE_EXTS[@]}; do
if [[ "$f" == *"$extension" ]]; then
# Run clang-format.
clang-format -i "$f"
clang-format --Wno-error=unknown -i "$f"
# Fix copyright headers, but not all files get them.
if [[ "$f" == *"inc" ]]; then
continue 2
Expand Down

0 comments on commit d09b33d

Please sign in to comment.