[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
Loading
Please sign in to comment