[libcxx-commits] [libcxx] [libcxx] retain a version of basic_string::reserve(0) that shrinks (PR #74168)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 1 19:08:31 PST 2023
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 28eead018d80a5384b8be6f259c3d2e2b849e8cf 379dc1721fdb20365a6a40a0cf490dc0bffeb2f6 -- libcxx/src/string_compat.cpp libcxx/test/libcxx/strings/basic.string/string.modifiers/reserve_with_shrink.pass.cpp libcxx/include/__config libcxx/include/string
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/src/string_compat.cpp b/libcxx/src/string_compat.cpp
index 84fd991859..5d4ab69233 100644
--- a/libcxx/src/string_compat.cpp
+++ b/libcxx/src/string_compat.cpp
@@ -10,15 +10,15 @@
// Instantiate a copy of the shrinking reserve implementation to maintain ABI compatibility for older versions of
// basic_string which relied on this behavior in move assignment.
-#define _LIBCPP_ENABLE_RESERVE_SHRINKING_ABI
-#include <string>
+# define _LIBCPP_ENABLE_RESERVE_SHRINKING_ABI
+# include <string>
_LIBCPP_BEGIN_NAMESPACE_STD
template _LIBCPP_EXPORTED_FROM_ABI void basic_string<char>::reserve(size_type);
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template _LIBCPP_EXPORTED_FROM_ABI void basic_string<wchar_t >::reserve(size_type);
-# endif
+# endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/reserve_with_shrink.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/reserve_with_shrink.pass.cpp
index ceac830c1a..a8718567fd 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/reserve_with_shrink.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/reserve_with_shrink.pass.cpp
@@ -10,16 +10,16 @@
// Check reserve(0) with old mangling shrinks for compatibility if it exists.
#if !defined(_LIBCPP_ABI_DO_NOT_RETAIN_SHRINKING_RESERVE)
-#define _LIBCPP_ENABLE_RESERVE_SHRINKING_ABI
-#include <string>
-#include <cassert>
+# define _LIBCPP_ENABLE_RESERVE_SHRINKING_ABI
+# include <string>
+# include <cassert>
-#include "test_macros.h"
-#include "min_allocator.h"
+# include "test_macros.h"
+# include "min_allocator.h"
bool test() {
std::string l = "Long string so that allocation definitely, for sure, absolutely happens. Probably.";
- const char *c = l.c_str();
+ const char* c = l.c_str();
assert(l.__invariants());
``````````
</details>
https://github.com/llvm/llvm-project/pull/74168
More information about the libcxx-commits
mailing list