Skip to content

Commit 9506c5f

Browse files
committed
initial commit
1 parent 83251a2 commit 9506c5f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/include/llvm/ADT/FunctionExtras.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ using EnableIfCallable = std::enable_if_t<std::disjunction<
8080
template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
8181
protected:
8282
static constexpr size_t InlineStorageSize = sizeof(void *) * 3;
83+
static constexpr size_t InlineStorageAlign = alignof(void *);
8384

8485
template <typename T, class = void>
8586
struct IsSizeLessThanThresholdT : std::false_type {};
@@ -161,7 +162,8 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
161162
// provide three pointers worth of storage here.
162163
// This is mutable as an inlined `const unique_function<void() const>` may
163164
// still modify its own mutable members.
164-
alignas(void *) mutable std::byte InlineStorage[InlineStorageSize];
165+
alignas(InlineStorageAlign) mutable std::byte
166+
InlineStorage[InlineStorageSize];
165167
} StorageUnion;
166168

167169
// A compressed pointer to either our dispatching callback or our table of
@@ -262,7 +264,7 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
262264
bool IsInlineStorage = true;
263265
void *CallableAddr = getInlineStorage();
264266
if (sizeof(CallableT) > InlineStorageSize ||
265-
alignof(CallableT) > alignof(decltype(StorageUnion.InlineStorage))) {
267+
alignof(CallableT) > InlineStorageAlign) {
266268
IsInlineStorage = false;
267269
// Allocate out-of-line storage. FIXME: Use an explicit alignment
268270
// parameter in C++17 mode.

0 commit comments

Comments
 (0)