-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[Support] Remove AlignedCharArrayUnion from Expected and ErrorOr, NFCI. #127407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-llvm-support Author: Jonas Hahnfeld (hahnjo) ChangesThey 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. Full diff: https://github.com/llvm/llvm-project/pull/127407.diff 3 Files Affected:
diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h
index c1b809a09bb80..ddb4f9b7eec87 100644
--- a/llvm/include/llvm/Support/Error.h
+++ b/llvm/include/llvm/Support/Error.h
@@ -16,7 +16,6 @@
#include "llvm-c/Error.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/abi-breaking.h"
-#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -727,8 +726,8 @@ template <class T> class [[nodiscard]] Expected {
}
union {
- AlignedCharArrayUnion<storage_type> TStorage;
- AlignedCharArrayUnion<error_type> ErrorStorage;
+ storage_type TStorage;
+ error_type ErrorStorage;
};
bool HasError : 1;
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
diff --git a/llvm/include/llvm/Support/ErrorOr.h b/llvm/include/llvm/Support/ErrorOr.h
index 97c7abe1f20c5..7f2b0fbce05fd 100644
--- a/llvm/include/llvm/Support/ErrorOr.h
+++ b/llvm/include/llvm/Support/ErrorOr.h
@@ -15,7 +15,6 @@
#ifndef LLVM_SUPPORT_ERROROR_H
#define LLVM_SUPPORT_ERROROR_H
-#include "llvm/Support/AlignOf.h"
#include <cassert>
#include <system_error>
#include <type_traits>
@@ -252,8 +251,8 @@ class ErrorOr {
}
union {
- AlignedCharArrayUnion<storage_type> TStorage;
- AlignedCharArrayUnion<std::error_code> ErrorStorage;
+ storage_type TStorage;
+ std::error_code ErrorStorage;
};
bool HasError : 1;
};
diff --git a/llvm/include/llvm/Support/TrailingObjects.h b/llvm/include/llvm/Support/TrailingObjects.h
index 9f7c421a87f4e..07cf08df45a6a 100644
--- a/llvm/include/llvm/Support/TrailingObjects.h
+++ b/llvm/include/llvm/Support/TrailingObjects.h
@@ -46,7 +46,6 @@
#ifndef LLVM_SUPPORT_TRAILINGOBJECTS_H
#define LLVM_SUPPORT_TRAILINGOBJECTS_H
-#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MathExtras.h"
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove the reinterpret_casts on these members that are now redundant as well?
✅ With the latest revision this PR passed the C/C++ code formatter. |
fd8b3eb
to
30c6ee2
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/6789 Here is the relevant piece of the build log for the reference
|
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.