Prior to this patch, operator-> was being handled like operator*: It was
associating a Value of type T with the expression result (where T is the
template argument of the optional<T>). This is correct for operator*, which
returns a reference (of some flavor) to T, so that the result of the
CXXOperatorCallExpr is a glvalue of type T. However, operator* returns a
T*, so the result of the CXXOperatorCallExpr is a prvalue T*, which should
therefore be associated with PointerValue that in turn refers to a T.
I noticed this issue while working on the migration to strict handling of
value categories (see https://discourse.llvm.org/t/70086). The current behavior
also seems problematic more generally because it's plausible that the framework
may at some point introduce behavior that assumes an Expr of pointer type is
always associated with a PointerValue.
As it turns out, this patch fixes an existing FIXME in the test
OptionalValueInitialization.
Depends On D150657
this function will be left with only one caller. Maybe inline it? For that matter, should the other caller be changed in some parallel way?