[libcxx-commits] [libcxx] [libc++] Add move constructor & assignment to `exception_ptr` (PR #164281)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 20 09:37:07 PDT 2025
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 origin/main HEAD --extensions h,cpp -- libcxx/include/__exception/exception_ptr.h libcxx/test/benchmarks/exception_ptr.bench.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index 38c803611..664c72e60 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -61,7 +61,10 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
void* __ptr_;
static void __do_decrement_refcount(void* __ptr) _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI static void __decrement_refcount(void* __ptr) _NOEXCEPT { if (__ptr) __do_decrement_refcount(__ptr); }
+ _LIBCPP_HIDE_FROM_ABI static void __decrement_refcount(void* __ptr) _NOEXCEPT {
+ if (__ptr)
+ __do_decrement_refcount(__ptr);
+ }
static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;
diff --git a/libcxx/test/benchmarks/exception_ptr.bench.cpp b/libcxx/test/benchmarks/exception_ptr.bench.cpp
index a0c8e9b1d..208341f2d 100644
--- a/libcxx/test/benchmarks/exception_ptr.bench.cpp
+++ b/libcxx/test/benchmarks/exception_ptr.bench.cpp
@@ -20,14 +20,14 @@ BENCHMARK(bm_make_exception_ptr)->ThreadRange(1, 8);
static bool exception_ptr_moves_copies_swap(std::exception_ptr p1) {
// Taken from https://github.com/llvm/llvm-project/issues/44892
- std::exception_ptr p2(p1); // Copy constructor
+ std::exception_ptr p2(p1); // Copy constructor
std::exception_ptr p3(std::move(p2)); // Move constructor
- p2 = std::move(p1); // Move assignment
- p1 = p2; // Copy assignment
- swap(p1, p2); // Swap
+ p2 = std::move(p1); // Move assignment
+ p1 = p2; // Copy assignment
+ swap(p1, p2); // Swap
// Comparisons against nullptr. The overhead from creating temporary `exception_ptr`
// instances should be optimized out.
- bool is_null = p1 == nullptr && nullptr == p2;
+ bool is_null = p1 == nullptr && nullptr == p2;
bool is_equal = p1 == p2; // Comparison
return is_null && is_equal;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/164281
More information about the libcxx-commits
mailing list