Skip to content

clang-format is not idempotent on certain files #107616

@winterqt

Description

@winterqt

Given this file, running the following commands:

clang-format phmap.h > phmap-1.h
clang-format phmap-1.h > phmap-2.h
diff -u phmap-1.h phmap-2.h

shows that clang-format is not idempotent:

--- phmap-1.h	2024-09-06 13:18:49.621712646 -0400
+++ phmap-2.h	2024-09-06 13:18:54.169121591 -0400
@@ -2734,7 +2734,7 @@
   parallel_hash_set() noexcept(
       std::is_nothrow_default_constructible<hasher>::value &&
       std::is_nothrow_default_constructible<key_equal>::value &&
-      std::is_nothrow_default_constructible<allocator_type>::value) {}
+      std::is_nothrow_default_constructible<allocator_type>::value){}
 
 #if (__cplusplus >= 201703L || _MSVC_LANG >= 201402) &&                        \
     (defined(_MSC_VER) || defined(__clang__) ||                                \
@@ -2745,7 +2745,8 @@
                              const allocator_type &alloc = allocator_type())
       : parallel_hash_set(
             typename Inner::Params{bucket_cnt, hash_param, eq, alloc},
-            phmap::make_index_sequence<num_tables>{}) {}
+            phmap::make_index_sequence<num_tables>{}) {
+  }
 
   template <std::size_t... i>
   parallel_hash_set(typename Inner::Params const &p,

However, running clang-format on phmap-2.h does not produce any further changes.

I am able to reproduce this on both macOS and Ubuntu, using clang-format version 18.1.8 (from Nixpkgs and the LLVM APT repo respectively).

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions