Improve optional formatter

As suggested by @labath in https://reviews.llvm.org/D114403, we should
make the formatter more resilient to corrupted data. The Libcxx version
explicitly checks for engaged = 1, so we can do that as well for safety.

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

GitOrigin-RevId: 4ba5da8e3d38f38ed7845c22baadd8908729c520
3 files changed