[llvm] fbf7bbc - [demangler] Fix build breakage
Nathan Sidwell via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 16 08:58:19 PST 2022
Author: Nathan Sidwell
Date: 2022-02-16T08:57:37-08:00
New Revision: fbf7bbcb839929ff4eed89921191ed51a2a99777
URL: https://github.com/llvm/llvm-project/commit/fbf7bbcb839929ff4eed89921191ed51a2a99777
DIFF: https://github.com/llvm/llvm-project/commit/fbf7bbcb839929ff4eed89921191ed51a2a99777.diff
LOG: [demangler] Fix build breakage
The copy and pristine versions of Utility diverged and one didn't
include <algorithm>. As that's a rather large header, let's just open
code the comparisons.
Reviewed By:
Differential Revision: https://reviews.llvm.org/
Added:
Modified:
libcxxabi/src/demangle/Utility.h
llvm/include/llvm/Demangle/Utility.h
Removed:
################################################################################
diff --git a/libcxxabi/src/demangle/Utility.h b/libcxxabi/src/demangle/Utility.h
index 4ec821cf6da97..21e5efb18542e 100644
--- a/libcxxabi/src/demangle/Utility.h
+++ b/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 @@ class OutputBuffer {
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();
diff --git a/llvm/include/llvm/Demangle/Utility.h b/llvm/include/llvm/Demangle/Utility.h
index df520f5cbc96d..c952068a19dda 100644
--- a/llvm/include/llvm/Demangle/Utility.h
+++ b/llvm/include/llvm/Demangle/Utility.h
@@ -39,8 +39,11 @@ class OutputBuffer {
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();
More information about the llvm-commits
mailing list