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

This commit is contained in:
Timothy Flynn 2024-12-27 18:40:32 -05:00 committed by Tim Flynn
parent 2ec97b4548
commit 66732d2203
Notes: github-actions[bot] 2024-12-28 13:40:44 +00:00
5 changed files with 14 additions and 14 deletions

View file

@ -15,7 +15,7 @@ jobs:
run: |
set -e
brew install curl flake8 llvm@18 ninja shellcheck swift-format unzip
brew install curl flake8 llvm@19 ninja shellcheck swift-format unzip
# Note: gn isn't available in homebrew :(
# Corresponds to https://gn.googlesource.com/gn/+/225e90c5025bf74f41dbee60d9cde4512c846fe7

View file

@ -66,7 +66,7 @@ Nobody is perfect, and sometimes we mess things up. That said, here are some goo
**Do:**
* Write in idiomatic project-style C++23, using the `AK` containers in all code.
* Conform to the project coding style found in [CodingStyle.md](https://github.com/LadybirdBrowser/ladybird/blob/master/Documentation/CodingStyle.md). Use `clang-format` (version 18) to automatically format C++ files. See [AdvancedBuildInstructions.md](https://github.com/LadybirdBrowser/ladybird/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/LadybirdBrowser/ladybird/blob/master/Documentation/CodingStyle.md). Use `clang-format` (version 19) to automatically format C++ files. See [AdvancedBuildInstructions.md](https://github.com/LadybirdBrowser/ladybird/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-19.
* 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.

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!**
**Important: Make sure you use `clang-format` version 19!**
This document describes the coding style used for C++ code in the Ladybird Browser project. All new code should conform to this style.

View file

@ -36,7 +36,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 other 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 the clang-format version specified in the style guide, as some OSes will ship other 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)

View file

@ -28,21 +28,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-19 >/dev/null 2>&1 ; then
CLANG_FORMAT=clang-format-19
elif command -v brew >/dev/null 2>&1 && command -v "$(brew --prefix llvm@19)"/bin/clang-format >/dev/null 2>&1 ; then
CLANG_FORMAT="$(brew --prefix llvm@19)"/bin/clang-format
elif command -v $TOOLCHAIN_DIR/clang-format >/dev/null 2>&1 && $TOOLCHAIN_DIR/clang-format --version | grep -qF ' 19.' ; 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."
if ! "${CLANG_FORMAT}" --version | awk '{ if (substr($NF, 1, index($NF, ".") - 1) != 19) exit 1; }'; then
echo "You are using '$("${CLANG_FORMAT}" --version)', which appears to not be clang-format 19."
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.)"
echo "clang-format-19 is not available, but C or C++ files need linting! Either skip this script, or install clang-format-19."
echo "(If you install a package 'clang-format', please make sure it's version 19.)"
exit 1
fi