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: | run: |
set -e 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 :( # Note: gn isn't available in homebrew :(
# Corresponds to https://gn.googlesource.com/gn/+/225e90c5025bf74f41dbee60d9cde4512c846fe7 # 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:** **Do:**
* Write in idiomatic project-style C++23, using the `AK` containers in all code. * 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. * 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). * 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. * 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. 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. This document describes the coding style used for C++ code in the Ladybird Browser project. All new code should conform to this style.
@ -505,7 +505,7 @@ wrapping or to insert necessary punctuation such as adding `**` when a number is
done using elements like `<sup>` which do not appear in the copied text. done using elements like `<sup>` which do not appear in the copied text.
Please wrap long comments onto multiple lines so that they are easier to read. Generally, 120 characters is a good width Please wrap long comments onto multiple lines so that they are easier to read. Generally, 120 characters is a good width
to aim for. to aim for.
Use FIXME: (without attribution) to denote items that need to be addressed in the future. Use FIXME: (without attribution) to denote items that need to be addressed in the future.
TODO: (without attribution) is also permitted. TODO: (without attribution) is also permitted.

View file

@ -36,7 +36,7 @@ Qt Creator should be set up correctly now, go ahead and explore the project and
## Auto-Formatting ## 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…" - In QtCreator, go to "Help > About Plugins…"
- Find the `Beautifier (experimental)` row (for example, by typing `beau` into the search) - Find the `Beautifier (experimental)` row (for example, by typing `beau` into the search)

View file

@ -28,21 +28,21 @@ fi
if (( ${#files[@]} )); then if (( ${#files[@]} )); then
TOOLCHAIN_DIR=Toolchain/Local/clang/bin TOOLCHAIN_DIR=Toolchain/Local/clang/bin
CLANG_FORMAT=false CLANG_FORMAT=false
if command -v clang-format-18 >/dev/null 2>&1 ; then if command -v clang-format-19 >/dev/null 2>&1 ; then
CLANG_FORMAT=clang-format-18 CLANG_FORMAT=clang-format-19
elif command -v brew >/dev/null 2>&1 && command -v "$(brew --prefix llvm@18)"/bin/clang-format >/dev/null 2>&1 ; then 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@18)"/bin/clang-format 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 ' 18.' ; then 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 CLANG_FORMAT=$TOOLCHAIN_DIR/clang-format
elif command -v clang-format >/dev/null 2>&1 ; then elif command -v clang-format >/dev/null 2>&1 ; then
CLANG_FORMAT=clang-format CLANG_FORMAT=clang-format
if ! "${CLANG_FORMAT}" --version | awk '{ if (substr($NF, 1, index($NF, ".") - 1) != 18) exit 1; }'; then 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 18." 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." echo "It is very likely that the resulting changes are not what you wanted."
fi fi
else 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 "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 18.)" echo "(If you install a package 'clang-format', please make sure it's version 19.)"
exit 1 exit 1
fi fi