]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
ci: Bump Clang-Tidy job to Clang-Tidy 12
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 8 Jun 2022 13:54:04 +0000 (15:54 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 8 Jun 2022 14:49:12 +0000 (16:49 +0200)
.github/workflows/build.yaml
src/.clang-tidy
src/Hash.cpp
src/InodeCache.cpp
src/storage/Storage.cpp
unittest/.clang-tidy

index 82a13618c23123dc77ce5e6559600164421204cf..fe0e3a39f0603641505517d515783fba19e793d5 100644 (file)
@@ -255,12 +255,12 @@ jobs:
             apt_get: libzstd-dev pkg-config libhiredis-dev asciidoctor
 
           - name: Clang-Tidy
-            os: ubuntu-18.04
-            CC: clang-9
-            CXX: clang++-9
+            os: ubuntu-20.04
+            CC: clang-12
+            CXX: clang++-12
             RUN_TESTS: none
-            CMAKE_PARAMS: -DENABLE_CLANG_TIDY=ON -DCLANGTIDY=/usr/bin/clang-tidy-9
-            apt_get: libzstd-dev pkg-config libhiredis-dev clang-9 clang-tidy-9
+            CMAKE_PARAMS: -DENABLE_CLANG_TIDY=ON -DCLANGTIDY=/usr/bin/clang-tidy-12
+            apt_get: libzstd-dev pkg-config libhiredis-dev clang-12 clang-tidy-12
 
     steps:
       - name: Get source
index 35c8668be1fc651a8d3e5acbe3a5a584bc1a4a1a..8d4f31b0abc6d9d450661c3668c57561a626602c 100644 (file)
@@ -13,6 +13,7 @@ Checks:          '-*,
                   -readability-implicit-bool-conversion,
                   -readability-magic-numbers,
                   -readability-else-after-return,
+                  -readability-function-cognitive-complexity,
                   -readability-named-parameter,
                   -readability-qualified-auto,
                   -readability-redundant-declaration,
index ecd19e303772b4b75fd08ba8eb51556b6340e09a..93df21b1eeab8aea6311a8d3be26ea02c01b0924 100644 (file)
@@ -67,7 +67,7 @@ Hash::hash_delimiter(std::string_view type)
 {
   hash_buffer(HASH_DELIMITER);
   hash_buffer(type);
-  hash_buffer(std::string_view("", 1)); // NUL
+  hash_buffer(std::string_view("\x00", 1));
   add_debug_text("### ");
   add_debug_text(type);
   add_debug_text("\n");
index 15a3392804f456840202448bf919f85515b94bbd..9b0562552803075970c1dea43ceec832d8f5bcb6 100644 (file)
@@ -82,6 +82,8 @@ static_assert(
   static_cast<int>(InodeCache::ContentType::precompiled_header) == 3,
   "Numeric value is part of key, increment version number if changed.");
 
+const void* MMAP_FAILED = reinterpret_cast<void*>(-1); // NOLINT: Must cast here
+
 } // namespace
 
 struct InodeCache::Key
@@ -148,7 +150,7 @@ InodeCache::mmap_file(const std::string& inode_cache_file)
   SharedRegion* sr = reinterpret_cast<SharedRegion*>(mmap(
     nullptr, sizeof(SharedRegion), PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0));
   fd.close();
-  if (sr == reinterpret_cast<void*>(-1)) {
+  if (sr == MMAP_FAILED) {
     LOG("Failed to mmap {}: {}", inode_cache_file, strerror(errno));
     return false;
   }
@@ -280,7 +282,7 @@ InodeCache::create_new_file(const std::string& filename)
                                          MAP_SHARED,
                                          *tmp_file.fd,
                                          0));
-  if (sr == reinterpret_cast<void*>(-1)) {
+  if (sr == MMAP_FAILED) {
     LOG("Failed to mmap new inode cache: {}", strerror(errno));
     return false;
   }
index d1aa4fb30e7682166474025463e72516d1b49743..3a9ab09f19582ed8b12c82af23a05c0391a92d17 100644 (file)
@@ -235,7 +235,7 @@ Storage::get(const Digest& key,
   MTR_SCOPE("storage", "get");
 
   if (mode != Mode::secondary_only) {
-    const auto path = primary.get(key, type);
+    auto path = primary.get(key, type);
     primary.increment_statistic(path ? core::Statistic::primary_storage_hit
                                      : core::Statistic::primary_storage_miss);
     if (path) {
index 978237e36ef5c0b433ceac8e7a8435ae97f9501e..de6a65844e46175896a7fc68712e80684d9101fc 100644 (file)
@@ -2,6 +2,7 @@
 Checks:          '-*,
                   readability-*,
                   -readability-implicit-bool-conversion,
+                  -readability-function-cognitive-complexity,
                   -readability-magic-numbers,
                   -readability-else-after-return,
                   -readability-named-parameter,