[all-commits] [llvm/llvm-project] 56ce75: [libc][NFC] Add new is_trivially_destructible chec...

Mikhail R. Gadelha via All-commits all-commits at lists.llvm.org
Thu Aug 17 10:27:14 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 56ce7522d9b116f51578532f7855f9323338fbac
      https://github.com/llvm/llvm-project/commit/56ce7522d9b116f51578532f7855f9323338fbac
  Author: Mikhail R. Gadelha <mikhail at igalia.com>
  Date:   2023-08-17 (Thu, 17 Aug 2023)

  Changed paths:
    M libc/src/__support/CPP/type_traits.h

  Log Message:
  -----------
  [libc][NFC] Add new is_trivially_destructible check to libc's type_traits

This patch adds new code to check if a given object is trivially
destructible. The ifdefs where necessary to implement it in gcc, as it
doesn't have the __is_trivially_destructible builtin like clang.

In gcc, it's not enough to only call __has_trivial_destructor, see:
https://stackoverflow.com/questions/20181702/which-type-traits-cannot-be-implemented-without-compiler-hooks

This patch only adds the new check, it will be used in D150211.

Reviewed By: michaelrj, sivachandra

Differential Revision: https://reviews.llvm.org/D158033


  Commit: c86a0dd134bf66caded2429834d824f16c2a39f0
      https://github.com/llvm/llvm-project/commit/c86a0dd134bf66caded2429834d824f16c2a39f0
  Author: Mikhail R. Gadelha <mikhail at igalia.com>
  Date:   2023-08-17 (Thu, 17 Aug 2023)

  Changed paths:
    M libc/src/__support/CPP/optional.h

  Log Message:
  -----------
  [libc] Extend optional to support non trivially destructible objects

This patch moves the storage from inside the libc's optional class to
its own set of class, so we can support non-trivially destructible
objects.

These new classes check if the class is or isn't non trivially
destructible and instantiate the correct base class, i.e., we explicitly
call the destructor if an object is not trivially destructible.

The motivation is to support cpp::optional<UInt<128>> (used by
UInt<T>::div), which is used when a platform does not support native
int128_t types (e.g., riscv32).

The code here is a trimmed-down version of llvm::optional.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D150211


Compare: https://github.com/llvm/llvm-project/compare/ada2a455fca4...c86a0dd134bf


More information about the All-commits mailing list