@@ -45,36 +45,6 @@ static_assert(sizeof(SmallVector<char, 0>) ==
45
45
sizeof(void *) * 2 + sizeof(void *),
46
46
"1 byte elements have word-sized type for size and capacity");
47
47
48
- // / Report that MinSize doesn't fit into this vector's size type. Throws
49
- // / std::length_error or calls report_fatal_error.
50
- LLVM_ATTRIBUTE_NORETURN
51
- static void report_size_overflow (size_t MinSize, size_t MaxSize);
52
- static void report_size_overflow (size_t MinSize, size_t MaxSize) {
53
- std::string Reason = " SmallVector unable to grow. Requested capacity (" +
54
- std::to_string (MinSize) +
55
- " ) is larger than maximum value for size type (" +
56
- std::to_string (MaxSize) + " )" ;
57
- #ifdef LLVM_ENABLE_EXCEPTIONS
58
- throw std::length_error (Reason);
59
- #else
60
- report_fatal_error (Reason);
61
- #endif
62
- }
63
-
64
- // / Report that this vector is already at maximum capacity. Throws
65
- // / std::length_error or calls report_fatal_error.
66
- LLVM_ATTRIBUTE_NORETURN static void report_at_maximum_capacity (size_t MaxSize);
67
- static void report_at_maximum_capacity (size_t MaxSize) {
68
- std::string Reason =
69
- " SmallVector capacity unable to grow. Already at maximum size " +
70
- std::to_string (MaxSize);
71
- #ifdef LLVM_ENABLE_EXCEPTIONS
72
- throw std::length_error (Reason);
73
- #else
74
- report_fatal_error (Reason);
75
- #endif
76
- }
77
-
78
48
// Note: Moving this function into the header may cause performance regression.
79
49
template <class Size_T >
80
50
static size_t getNewCapacity (size_t MinSize, size_t TSize, size_t OldCapacity) {
@@ -83,14 +53,14 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) {
83
53
// Ensure we can fit the new capacity.
84
54
// This is only going to be applicable when the capacity is 32 bit.
85
55
if (MinSize > MaxSize)
86
- report_size_overflow (MinSize, MaxSize );
56
+ report_bad_alloc_error ( " SmallVector capacity overflow during allocation " );
87
57
88
58
// Ensure we can meet the guarantee of space for at least one more element.
89
59
// The above check alone will not catch the case where grow is called with a
90
60
// default MinSize of 0, but the current capacity cannot be increased.
91
61
// This is only going to be applicable when the capacity is 32 bit.
92
62
if (OldCapacity == MaxSize)
93
- report_at_maximum_capacity (MaxSize );
63
+ report_bad_alloc_error ( " SmallVector capacity unable to grow " );
94
64
95
65
// In theory 2*capacity can overflow if the capacity is 64 bit, but the
96
66
// original capacity would never be large enough for this to be a problem.
0 commit comments