[libc-commits] [libc] [libc][CPP] make the string trap on OOM (PR #172260)

via libc-commits libc-commits at lists.llvm.org
Mon Dec 15 00:12:43 PST 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 -- libc/src/__support/CPP/string.h --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/libc/src/__support/CPP/string.h b/libc/src/__support/CPP/string.h
index d4cf3b89b..04f0e9538 100644
--- a/libc/src/__support/CPP/string.h
+++ b/libc/src/__support/CPP/string.h
@@ -132,7 +132,7 @@ public:
     // by 8 is cheap. We guard the extension so the operation doesn't overflow.
     if (new_capacity < SIZE_MAX / 11)
       new_capacity = new_capacity * 11 / 8;
-    
+
     if (void *Ptr = ::realloc(buffer_ == get_empty_string() ? nullptr : buffer_,
                               new_capacity)) {
       buffer_ = static_cast<char *>(Ptr);

``````````

</details>


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


More information about the libc-commits mailing list