]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
chore: Bump to Clang-Format 18
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 19 Jul 2025 09:06:56 +0000 (11:06 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 21 Jul 2025 12:36:56 +0000 (14:36 +0200)
.clang-format
CONTRIBUTING.md
misc/clang-format
src/ccache/core/statistics.cpp
src/ccache/storage/remote/redisstorage.cpp
src/ccache/util/wincompat.hpp
unittest/test_bsdmkstemp.cpp
unittest/testutil.cpp

index db62f47a3b65ba8db26eef783186e30e46b55d49..33be928c7004c216e6064cd41385b77ac096adc9 100644 (file)
@@ -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
index 693b11c44ce687b53137748b50f468e7e8f8e9c4..0b679df4c527ee89fa84145653dc9976ed461949 100644 (file)
@@ -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
-`<ccache-top-dir>/misc/clang-format` (or any other Clang-Format version 11
+`<ccache-top-dir>/misc/clang-format` (or any other Clang-Format version 18
 binary) automatically when saving. Newer Clang-Format versions likely also work
 fine.
 
index 6db806306bb854300386ee6499d6d64ad8c765b3..2e54a11caf6778566ed58ca070cd36d4e3ccccd9 100755 (executable)
@@ -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
 
index 9d9aa3e4bfb9855ab71c7747ec22aace0f8140ae..a2723e0ace3be0df169e779d24b0788624b7d401 100644 (file)
@@ -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.
index a87395af7b8516d205d3f0205a7f40d3c3ecd43d..351fcd138fffa25d5a988b0c070cf9ffbf4a7c22 100644 (file)
@@ -252,7 +252,7 @@ RedisStorageBackend::connect(const Url& url,
       url.port().empty()
         ? DEFAULT_PORT
         : static_cast<uint32_t>(util::value_or_throw<core::Fatal>(
-          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<uint32_t>(
-          util::value_or_throw<core::Fatal>(util::parse_unsigned(
-            *db, 0, std::numeric_limits<uint32_t>::max(), "db number")));
+            util::value_or_throw<core::Fatal>(util::parse_unsigned(
+              *db, 0, std::numeric_limits<uint32_t>::max(), "db number")));
 
   if (db_number != 0) {
     LOG("Redis SELECT {}", db_number);
index f8d840607fee70ebd06328ee6a9b6d1f457822fc..0859608e6fed99bca677232b5a7732d1ea2a6f99 100644 (file)
@@ -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 <direct.h>
@@ -70,7 +70,6 @@ constexpr auto S_IWUSR = mode_t{_S_IWRITE};
 #  include <process.h>
 #  define NOMINMAX 1
 #  define WIN32_NO_STATUS
-// clang-format off
 #  include <winsock2.h> // 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 <bcrypt.h> // NTSTATUS
-// clang-format on
 #  undef WIN32_NO_STATUS
 #  include <ntstatus.h>
 
index 4afd22c945616a5751c50c7dd34b3d06a3883115..01db172dc60ed9c17a758547eeb703cfdb74049b 100644 (file)
@@ -64,7 +64,8 @@ public:
     return *this;
   }
 
-  explicit operator bool() const
+  explicit
+  operator bool() const
   {
     return m_handle != INVALID_HANDLE_VALUE;
   }
index d5ae90ec7c3137ee8b822d49c038ccad5a3b8659..8872ff8ac2d357980060cbb8c212707698c7c2f5 100644 (file)
@@ -31,7 +31,7 @@ size_t TestContext::m_subdir_counter = 0;
 
 TestContext::TestContext()
   : m_test_dir(util::value_or_throw<core::Error>(
-    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");