Skip to content

Commit 433aa9e

Browse files
committed
[Support] Remove AlignedCharArrayUnion from Expected and ErrorOr, NFCI.
They were instantiated with only a single type and union-members themselves. By putting the types directly into a union, they are still left uninitialized by default.
1 parent 0c829d6 commit 433aa9e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

llvm/include/llvm/Support/Error.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "llvm-c/Error.h"
1717
#include "llvm/ADT/Twine.h"
1818
#include "llvm/Config/abi-breaking.h"
19-
#include "llvm/Support/AlignOf.h"
2019
#include "llvm/Support/Compiler.h"
2120
#include "llvm/Support/Debug.h"
2221
#include "llvm/Support/ErrorHandling.h"
@@ -727,8 +726,8 @@ template <class T> class [[nodiscard]] Expected {
727726
}
728727

729728
union {
730-
AlignedCharArrayUnion<storage_type> TStorage;
731-
AlignedCharArrayUnion<error_type> ErrorStorage;
729+
storage_type TStorage;
730+
error_type ErrorStorage;
732731
};
733732
bool HasError : 1;
734733
#if LLVM_ENABLE_ABI_BREAKING_CHECKS

llvm/include/llvm/Support/ErrorOr.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#ifndef LLVM_SUPPORT_ERROROR_H
1616
#define LLVM_SUPPORT_ERROROR_H
1717

18-
#include "llvm/Support/AlignOf.h"
1918
#include <cassert>
2019
#include <system_error>
2120
#include <type_traits>
@@ -252,8 +251,8 @@ class ErrorOr {
252251
}
253252

254253
union {
255-
AlignedCharArrayUnion<storage_type> TStorage;
256-
AlignedCharArrayUnion<std::error_code> ErrorStorage;
254+
storage_type TStorage;
255+
std::error_code ErrorStorage;
257256
};
258257
bool HasError : 1;
259258
};

0 commit comments

Comments
 (0)