[PATCH] D119951: [demangler] Fix build breakage
Nathan Sidwell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 16 08:52:52 PST 2022
urnathan updated this revision to Diff 409285.
urnathan added a comment.
Just the fix,
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119951/new/
https://reviews.llvm.org/D119951
Files:
libcxxabi/src/demangle/Utility.h
llvm/include/llvm/Demangle/Utility.h
Index: llvm/include/llvm/Demangle/Utility.h
===================================================================
--- llvm/include/llvm/Demangle/Utility.h
+++ llvm/include/llvm/Demangle/Utility.h
@@ -39,8 +39,11 @@
if (Need > BufferCapacity) {
// Avoid many reallocations during startup, with a bit of hysteresis.
constexpr size_t MinInitAlloc = 1024;
- Need = std::max(Need, MinInitAlloc);
- BufferCapacity = std::max(Need, BufferCapacity * 2);
+ if (Need < MinInitAlloc)
+ Need = MinInitAlloc;
+ BufferCapacity *= 2;
+ if (BufferCapacity < Need)
+ BufferCapacity = Need;
Buffer = static_cast<char *>(std::realloc(Buffer, BufferCapacity));
if (Buffer == nullptr)
std::terminate();
Index: libcxxabi/src/demangle/Utility.h
===================================================================
--- libcxxabi/src/demangle/Utility.h
+++ libcxxabi/src/demangle/Utility.h
@@ -17,7 +17,6 @@
#define DEMANGLE_UTILITY_H
#include "StringView.h"
-#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdlib>
@@ -40,8 +39,11 @@
if (Need > BufferCapacity) {
// Avoid many reallocations during startup, with a bit of hysteresis.
constexpr size_t MinInitAlloc = 1024;
- Need = std::max(Need, MinInitAlloc);
- BufferCapacity = std::max(Need, BufferCapacity * 2);
+ if (Need < MinInitAlloc)
+ Need = MinInitAlloc;
+ BufferCapacity *= 2;
+ if (BufferCapacity < Need)
+ BufferCapacity = Need;
Buffer = static_cast<char *>(std::realloc(Buffer, BufferCapacity));
if (Buffer == nullptr)
std::terminate();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119951.409285.patch
Type: text/x-patch
Size: 1663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220216/6ba329f2/attachment.bin>
More information about the llvm-commits
mailing list