[nullability] Add support for `operator->` on `std::optional`.

We've repeatedly seen the pattern where people have a pointer stored in an
optional struct, perform a null-check on the pointer ("through" the optional),
then dereference it. Introducing limited support for optionals prevents false
positives on these code patterns.

In addition to `std::optional`, we also support
[`absl::optional`](https://github.com/abseil/abseil-cpp/blob/master/absl/types/optional.h)
and
[`folly::Optional`](https://github.com/facebook/folly/blob/main/folly/Optional.h).

PiperOrigin-RevId: 609261743
Change-Id: I79a0673d1fee71071dc23338b0d67fd7b0728c3d
diff --git a/nullability/pointer_nullability_matchers.cc b/nullability/pointer_nullability_matchers.cc
index 854b68e..7ac6378 100644
--- a/nullability/pointer_nullability_matchers.cc
+++ b/nullability/pointer_nullability_matchers.cc
@@ -57,6 +57,7 @@
 using ast_matchers::isInStdNamespace;
 using ast_matchers::isMemberInitializer;
 using ast_matchers::memberExpr;
+using ast_matchers::ofClass;
 using ast_matchers::parameterCountIs;
 using ast_matchers::pointee;
 using ast_matchers::pointerType;
@@ -109,6 +110,13 @@
       callee(cxxMethodDecl(parameterCountIs(0), isConst())));
 }
 
+Matcher<Stmt> isOptionalOperatorArrowCall() {
+  return cxxOperatorCallExpr(
+      hasOverloadedOperatorName("->"),
+      callee(cxxMethodDecl(ofClass(hasAnyName(
+          "::std::optional", "::absl::optional", "::folly::Optional")))));
+}
+
 Matcher<Stmt> isNonConstMemberCall() {
   return cxxMemberCallExpr(callee(cxxMethodDecl(unless(isConst()))));
 }