[all-commits] [llvm/llvm-project] 7d06f5: [libc] Extend optional to support non trivially de...

Mikhail R. Gadelha via All-commits all-commits at lists.llvm.org
Mon Aug 14 15:33:16 PDT 2023


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

  Changed paths:
    M libc/src/__support/CPP/optional.h
    M libc/src/__support/CPP/type_traits.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




More information about the All-commits mailing list