[libcxx-commits] [libcxx] [libc++] Introduce a standalone __scope_guard and use it in <string> (PR #114867)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 4 12:56:34 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 7c69491e486a93e8b86a390a0d5d580eeca7f7d5 bb0e22afbbdfe0128bc16dba16c86a305b679afd --extensions ,h -- libcxx/include/__utility/scope_guard.h libcxx/include/__flat_map/flat_map.h libcxx/include/__utility/exception_guard.h libcxx/include/string
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/__flat_map/flat_map.h b/libcxx/include/__flat_map/flat_map.h
index 076c14f640..a3041a7ac9 100644
--- a/libcxx/include/__flat_map/flat_map.h
+++ b/libcxx/include/__flat_map/flat_map.h
@@ -50,8 +50,8 @@
 #include <__type_traits/is_nothrow_constructible.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/maybe_const.h>
-#include <__utility/scope_guard.h>
 #include <__utility/pair.h>
+#include <__utility/scope_guard.h>
 #include <initializer_list>
 #include <stdexcept>
 #include <string>
diff --git a/libcxx/include/string b/libcxx/include/string
index caea2707fb..f81b17f5c1 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -2177,7 +2177,7 @@ private:
         __alloc_ = __str.__alloc_;
       } else {
         __annotate_delete();
-        auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
+        auto __guard       = std::__make_scope_guard(__annotate_new_size(*this));
         allocator_type __a = __str.__alloc_;
         auto __allocation  = std::__allocate_at_least(__a, __str.__get_long_cap());
         __begin_lifetime(__allocation.ptr, __allocation.count);
@@ -3375,7 +3375,7 @@ template <class _CharT, class _Traits, class _Allocator>
 inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void
 basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) {
   __annotate_delete();
-  auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
+  auto __guard    = std::__make_scope_guard(__annotate_new_size(*this));
   size_type __cap = capacity();
   size_type __sz  = size();
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/114867


More information about the libcxx-commits mailing list