[all-commits] [llvm/llvm-project] db3814: Fix EBO on std::optional and std::variant when tar...

Eric via All-commits all-commits at lists.llvm.org
Thu Apr 27 18:05:42 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: db381405ced7b65ad1cf8fc60bbdfb505e1ed3de
      https://github.com/llvm/llvm-project/commit/db381405ced7b65ad1cf8fc60bbdfb505e1ed3de
  Author: Eric Fiselier <eric at efcs.ca>
  Date:   2023-04-27 (Thu, 27 Apr 2023)

  Changed paths:
    M libcxx/docs/DesignDocs/ABIVersioning.rst
    M libcxx/docs/index.rst
    M libcxx/include/optional
    M libcxx/include/variant
    A libcxx/test/libcxx/utilities/optional/optional.object/optional_size.pass.cpp
    M libcxx/test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp

  Log Message:
  -----------
  Fix EBO on std::optional and std::variant when targeting the MSVC ABI

Committing on behalf of davidben. Reviewed as D146190

Patch originally by Jan Dörrie in https://reviews.llvm.org/D120064. I've just updated it to include tests, and update documentation that MSVC ABI is not stable.

In the current implementation both `std::optional` and `std::variant` don't perform the EBO on MSVC's ABI. This is because both classes inherit from multiple empty base classes, which breaks the EBO for MSVC. This patch fixes this issue by applying the `empty_bases` declspec attribute, which is already used to fix a similar issue for `std::tuple`.

See https://reviews.llvm.org/D120064 for discussion on MSVC ABI stability. From the discussion, libc++ doesn't have users that expect a stable ABI on MSVC. The fix is thus applied unconditionally to benefit more users. Documentation has been updated to reflect this.

Fixes https://github.com/llvm/llvm-project/issues/61095.




More information about the All-commits mailing list