Meta: Switch to clang-format-20 as the standard formatter

This commit is contained in:
Lucas CHOLLET authored and Tim Schumacher committed 2025-10-10 00:02:50 +02:00
1 parent 27e8dc5cbf
commit 8a3f29fe9e
7 files changed
+25 -23

No files matched your search

@@ -11,9 +11,11 @@
16,
17,
18,
19,
20,
"trunk"
],
"default": 18,
"default": 20,
"description": "Select LLVM compiler version to use"
},
"enable_ladybird": {
+8 -8
View File
@@ -24,18 +24,18 @@ runs:
set -e
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main'
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main'
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install ccache clang-18 clang++-18 clang-format-18 lld-18 gcc-13 g++-13 libstdc++-13-dev ninja-build unzip qt6-base-dev qt6-tools-dev-tools libqt6svg6-dev qt6-multimedia-dev libgl1-mesa-dev libpulse-dev libssl-dev libegl1-mesa-dev libclang-18-dev
sudo apt-get install ccache clang-20 clang++-20 clang-format-20 lld-20 gcc-13 g++-13 libstdc++-13-dev ninja-build unzip qt6-base-dev qt6-tools-dev-tools libqt6svg6-dev qt6-multimedia-dev libgl1-mesa-dev libpulse-dev libssl-dev libegl1-mesa-dev libclang-20-dev
sudo apt-get remove clang-{13,14,15} clang++-{13,14,15} libclang-{13,14,15}-dev llvm-{13,14,15}
sudo apt-get install clang-18 clang++-18 llvm-18 llvm-18-dev
sudo apt-get install clang-20 clang++-20 llvm-20 llvm-20-dev
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100
@@ -63,14 +63,14 @@ runs:
set -e
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main'
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main'
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get remove clang-{13,14,15} clang++-{13,14,15} libclang-{13,14,15}-dev llvm-{13,14,15}
sudo apt-get install clang-format-18 ccache e2fsprogs gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build optipng qemu-utils qemu-system-i386 unzip generate-ninja libegl1-mesa-dev
sudo apt-get install clang-18 clang++-18 llvm-18 llvm-18-dev
sudo apt-get install clang-format-20 ccache e2fsprogs gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build optipng qemu-utils qemu-system-i386 unzip generate-ninja libegl1-mesa-dev
sudo apt-get install clang-20 clang++-20 llvm-20 llvm-20-dev
- name: Enable KVM group perms
if: ${{ inputs.os == 'Serenity' }}
+2 -2
View File
@@ -64,8 +64,8 @@ jobs:
run: |
if ${{ inputs.os_name == 'Linux' }} ; then
if ${{ inputs.toolchain == 'Clang' }} ; then
echo "host_cc=clang-18" >> "$GITHUB_OUTPUT"
echo "host_cxx=clang++-18" >> "$GITHUB_OUTPUT"
echo "host_cc=clang-20" >> "$GITHUB_OUTPUT"
echo "host_cxx=clang++-20" >> "$GITHUB_OUTPUT"
elif ${{ inputs.toolchain == 'GNU' }} ; then
echo "host_cc=gcc-13" >> "$GITHUB_OUTPUT"
echo "host_cxx=g++-13" >> "$GITHUB_OUTPUT"
+1 -1
View File
@@ -44,7 +44,7 @@ Nobody is perfect, and sometimes we mess things up. That said, here are some goo
**Do:**
- Write in idiomatic SerenityOS C++23, using the `AK` containers in all code.
- Conform to the project coding style found in [CodingStyle.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/CodingStyle.md). Use `clang-format` (version 18 or later) to automatically format C++ files. See [AdvancedBuildInstructions.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/AdvancedBuildInstructions.md#clang-format-updates) for instructions on how to get an up-to-date version if your OS distribution does not ship clang-format-18.
- Conform to the project coding style found in [CodingStyle.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/CodingStyle.md). Use `clang-format` (version 20 or later) to automatically format C++ files. See [AdvancedBuildInstructions.md](https://github.com/SerenityOS/serenity/blob/master/Documentation/AdvancedBuildInstructions.md#clang-format-updates) for instructions on how to get an up-to-date version if your OS distribution does not ship clang-format-20.
- Choose expressive variable, function and class names. Make it as obvious as possible what the code is doing.
- Split your changes into separate, atomic commits (i.e. A commit per feature or fix, where the build, tests and the system are all functioning).
- Make sure your commits are rebased on the master branch.
+1 -1
View File
@@ -2,7 +2,7 @@
For low-level styling (spaces, parentheses, brace placement, etc), all code should follow the format specified in `.clang-format` in the project root.
**Important: Make sure you use `clang-format` version 18 or later!**
**Important: Make sure you use `clang-format` version 20 or later!**
This document describes the coding style used for C++ code in the Serenity Operating System project. All new code should conform to this style.
+1 -1
View File
@@ -51,7 +51,7 @@ Qt Creator should be set up correctly now, go ahead and explore the project and
## Auto-Formatting
You can use `clang-format` to help you with the [style guide](CodingStyle.md). Before you proceed, check that you're actually using clang-format version 18, as some OSes will ship older clang-format versions by default.
You can use `clang-format` to help you with the [style guide](CodingStyle.md). Before you proceed, check that you're actually using clang-format version 20, as some OSes will ship older clang-format versions by default.
- In QtCreator, go to "Help > About Plugins…"
- Find the `Beautifier (experimental)` row (for example, by typing `beau` into the search)
+9 -9
View File
@@ -30,21 +30,21 @@ fi
if (( ${#files[@]} )); then
TOOLCHAIN_DIR=Toolchain/Local/clang/bin
CLANG_FORMAT=false
if command -v clang-format-18 >/dev/null 2>&1 ; then
CLANG_FORMAT=clang-format-18
elif command -v brew >/dev/null 2>&1 && command -v "$(brew --prefix llvm@18)"/bin/clang-format >/dev/null 2>&1 ; then
CLANG_FORMAT="$(brew --prefix llvm@18)"/bin/clang-format
elif command -v $TOOLCHAIN_DIR/clang-format >/dev/null 2>&1 && $TOOLCHAIN_DIR/clang-format --version | grep -qF ' 18.' ; then
if command -v clang-format-20 >/dev/null 2>&1 ; then
CLANG_FORMAT=clang-format-20
elif command -v brew >/dev/null 2>&1 && command -v "$(brew --prefix llvm@20)"/bin/clang-format >/dev/null 2>&1 ; then
CLANG_FORMAT="$(brew --prefix llvm@20)"/bin/clang-format
elif command -v $TOOLCHAIN_DIR/clang-format >/dev/null 2>&1 && $TOOLCHAIN_DIR/clang-format --version | grep -qF ' 20.' ; then
CLANG_FORMAT=$TOOLCHAIN_DIR/clang-format
elif command -v clang-format >/dev/null 2>&1 ; then
CLANG_FORMAT=clang-format
if ! "${CLANG_FORMAT}" --version | awk '{ if (substr($NF, 1, index($NF, ".") - 1) < 18) exit 1; }'; then
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 18 or later."
if ! "${CLANG_FORMAT}" --version | awk '{ if (substr($NF, 1, index($NF, ".") - 1) < 20) exit 1; }'; then
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format-20 or later."
echo "It is very likely that the resulting changes are not what you wanted."
fi
else
echo "clang-format-18 is not available, but C or C++ files need linting! Either skip this script, or install clang-format-18."
echo "(If you install a package 'clang-format', please make sure it's version 18 or later.)"
echo "clang-format-20 is not available, but C or C++ files need linting! Either skip this script, or install clang-format-20."
echo "(If you install a package 'clang-format', please make sure it's version 20 or later.)"
exit 1
fi