From: Joel Rosdahl Date: Sat, 19 Jul 2025 09:06:56 +0000 (+0200) Subject: chore: Bump to Clang-Format 18 X-Git-Tag: v4.12~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=923db53a9248744203ea718113ccdcd7342270a6;p=thirdparty%2Fccache.git chore: Bump to Clang-Format 18 --- diff --git a/.clang-format b/.clang-format index db62f47a..33be928c 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,4 @@ -# This configuration should work with Clang-Format 11 and higher. +# This configuration should work with Clang-Format 18 and higher. --- Language: Cpp BasedOnStyle: LLVM diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 693b11c4..0b679df4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,7 +85,7 @@ format is loosely based on [LLVM's code formatting style](https://llvm.org/docs/CodingStandards.html) with some exceptions. Run `make format` (or `ninja format` if you use Ninja) to format changes according to ccache's code style. Or even better: set up your editor to run -`/misc/clang-format` (or any other Clang-Format version 11 +`/misc/clang-format` (or any other Clang-Format version 18 binary) automatically when saving. Newer Clang-Format versions likely also work fine. diff --git a/misc/clang-format b/misc/clang-format index 6db80630..2e54a11c 100755 --- a/misc/clang-format +++ b/misc/clang-format @@ -17,23 +17,23 @@ fi misc_dir="$(dirname "$0")" clang_format_exe="${misc_dir}/.clang-format-exe" -clang_format_version=11 -clang_format_release=master-1d7ec53d +clang_format_version=18 +clang_format_release=master-2da3e7b url_prefix="https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/${clang_format_release}/clang-format-${clang_format_version}_" if [ ! -x "$clang_format_exe" ]; then case "$(uname -s | tr '[:upper:]' '[:lower:]')" in *mingw*|*cygwin*|*msys*) url_suffix=windows-amd64.exe - checksum=7167f201acbd8ff06a7327d14db0d8a169393384bbc42873bb8277b788cc4469 + checksum=4c7c29320e7b17901fa39ad7068b309756c121b83e4008669711e55dd4459793 ;; *darwin*) url_suffix=macosx-amd64 - checksum=0cab857e66aa9ed9ea00eee3c94bfc91a2d72ab440327e15784852cf94b1814b + checksum=aebb3bc3f6fa286373e03c096ae0a6408d37e8f837b43cdbda6f6203ba2bbb14 ;; *linux*) url_suffix=linux-amd64 - checksum=a9d76e3275823ea308bc2e4d2a6e3cc693f38c29d891f1d74cb0e1553e698dea + checksum=d126ba919b7913cd352ca669c669024c0edac3e93311d9a52a45bffb6169f4de ;; *) echo "Error: Please set CLANG_FORMAT to clang-format version $clang_format_version" >&2 @@ -55,7 +55,7 @@ if [ ! -x "$clang_format_exe" ]; then if ! command -v sha256sum >/dev/null; then echo "Warning: sha256sum not found, not verifying clang-format integrity" >&2 elif ! echo "$checksum $clang_format_exe.tmp" | sha256sum --status -c -; then - echo "Error: Bad checksum of downloaded clang-format" >&2 + echo "Error: Bad checksum of downloaded clang-format: expected ${checksum}, actual $(sha256sum ${clang_format_exe}.tmp | awk '{print $1}')" >&2 exit 1 fi diff --git a/src/ccache/core/statistics.cpp b/src/ccache/core/statistics.cpp index 9d9aa3e4..a2723e0a 100644 --- a/src/ccache/core/statistics.cpp +++ b/src/ccache/core/statistics.cpp @@ -60,10 +60,7 @@ struct StatisticsField } // namespace -#define FIELD(id, ...) \ - { \ - Statistic::id, #id, __VA_ARGS__ \ - } +#define FIELD(id, ...) {Statistic::id, #id, __VA_ARGS__} const StatisticsField k_statistics_fields[] = { // Field "none" intentionally omitted. diff --git a/src/ccache/storage/remote/redisstorage.cpp b/src/ccache/storage/remote/redisstorage.cpp index a87395af..351fcd13 100644 --- a/src/ccache/storage/remote/redisstorage.cpp +++ b/src/ccache/storage/remote/redisstorage.cpp @@ -252,7 +252,7 @@ RedisStorageBackend::connect(const Url& url, url.port().empty() ? DEFAULT_PORT : static_cast(util::value_or_throw( - util::parse_unsigned(url.port(), 1, 65535, "port"))); + util::parse_unsigned(url.port(), 1, 65535, "port"))); ASSERT(url.path().empty() || url.path()[0] == '/'); LOG("Redis connecting to {}:{} (connect timeout {} ms)", @@ -300,8 +300,8 @@ RedisStorageBackend::select_database(const Url& url) const uint32_t db_number = !db ? 0 : static_cast( - util::value_or_throw(util::parse_unsigned( - *db, 0, std::numeric_limits::max(), "db number"))); + util::value_or_throw(util::parse_unsigned( + *db, 0, std::numeric_limits::max(), "db number"))); if (db_number != 0) { LOG("Redis SELECT {}", db_number); diff --git a/src/ccache/util/wincompat.hpp b/src/ccache/util/wincompat.hpp index f8d84060..0859608e 100644 --- a/src/ccache/util/wincompat.hpp +++ b/src/ccache/util/wincompat.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2024 Joel Rosdahl and other contributors +// Copyright (C) 2021-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -46,22 +46,22 @@ constexpr auto S_IWUSR = mode_t{_S_IWRITE}; # endif # ifndef S_ISREG -# define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) # endif # ifndef S_ISDIR -# define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) # endif # ifndef S_ISFIFO -# define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) +# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) # endif # ifndef S_ISCHR -# define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) +# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) # endif # ifndef S_ISLNK -# define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) +# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) # endif # ifndef S_ISBLK -# define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) +# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) # endif # include @@ -70,7 +70,6 @@ constexpr auto S_IWUSR = mode_t{_S_IWRITE}; # include # define NOMINMAX 1 # define WIN32_NO_STATUS -// clang-format off # include // struct timeval // windows must be included after winsock2 // https://stackoverflow.com/questions/1372480/c-redefinition-header-files-winsock2-h @@ -78,7 +77,6 @@ constexpr auto S_IWUSR = mode_t{_S_IWRITE}; // bccrypt must go after windows.h // https://stackoverflow.com/questions/57472787/compile-errors-when-using-c-and-bcrypt-header # include // NTSTATUS -// clang-format on # undef WIN32_NO_STATUS # include diff --git a/unittest/test_bsdmkstemp.cpp b/unittest/test_bsdmkstemp.cpp index 4afd22c9..01db172d 100644 --- a/unittest/test_bsdmkstemp.cpp +++ b/unittest/test_bsdmkstemp.cpp @@ -64,7 +64,8 @@ public: return *this; } - explicit operator bool() const + explicit + operator bool() const { return m_handle != INVALID_HANDLE_VALUE; } diff --git a/unittest/testutil.cpp b/unittest/testutil.cpp index d5ae90ec..8872ff8a 100644 --- a/unittest/testutil.cpp +++ b/unittest/testutil.cpp @@ -31,7 +31,7 @@ size_t TestContext::m_subdir_counter = 0; TestContext::TestContext() : m_test_dir(util::value_or_throw( - fs::current_path(), "Failed to retrieve current directory")) + fs::current_path(), "Failed to retrieve current directory")) { if (m_test_dir.parent_path().filename() != "testdir") { throw core::Error("TestContext instantiated outside test directory");