mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
AK: Add abstraction for forcing empty base optimization on Windows
Without this annotation, the MSVC ABI is reluctant to apply EBO even in cases that are basically guaranteed on the Itanium ABI by modern compilers. This fixes an UBSAN issue with Variant on Windows.
This commit is contained in:
parent
75b0e9a199
commit
3fd05306fc
Notes:
github-actions[bot]
2025-06-17 21:35:02 +00:00
Author: https://github.com/ayeteadoe
Commit: 3fd05306fc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4962
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/R-Goc
3 changed files with 10 additions and 3 deletions
|
@ -249,6 +249,13 @@
|
|||
# define NO_UNIQUE_ADDRESS [[no_unique_address]]
|
||||
#endif
|
||||
|
||||
#if defined(AK_OS_WINDOWS)
|
||||
// https://learn.microsoft.com/en-us/cpp/cpp/empty-bases?view=msvc-170
|
||||
# define AK_COMPACT_EMPTY_BASES __declspec(empty_bases)
|
||||
#else
|
||||
# define AK_COMPACT_EMPTY_BASES
|
||||
#endif
|
||||
|
||||
// GCC doesn't have __has_feature but clang does
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(...) 0
|
||||
|
|
|
@ -59,7 +59,7 @@ private:
|
|||
};
|
||||
|
||||
template<typename T, typename... TRest>
|
||||
struct Tuple<T, TRest...> : Tuple<TRest...> {
|
||||
struct AK_COMPACT_EMPTY_BASES Tuple<T, TRest...> : Tuple<TRest...> {
|
||||
|
||||
template<typename FirstT, typename... RestT>
|
||||
Tuple(FirstT&& first, RestT&&... rest)
|
||||
|
@ -113,7 +113,7 @@ private:
|
|||
namespace AK {
|
||||
|
||||
template<typename... Ts>
|
||||
struct Tuple : Detail::Tuple<Ts...> {
|
||||
struct AK_COMPACT_EMPTY_BASES Tuple : Detail::Tuple<Ts...> {
|
||||
using Types = TypeList<Ts...>;
|
||||
using Detail::Tuple<Ts...>::Tuple;
|
||||
using Indices = MakeIndexSequence<sizeof...(Ts)>;
|
||||
|
|
|
@ -478,7 +478,7 @@ private:
|
|||
}
|
||||
|
||||
template<typename... Fs>
|
||||
struct Visitor : Fs... {
|
||||
struct AK_COMPACT_EMPTY_BASES Visitor : Fs... {
|
||||
using Types = TypeList<Fs...>;
|
||||
|
||||
Visitor(Fs&&... args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue