[nullability] Emit a warning on array subscripts if the base is nullable.

I noticed that this was missing while preparing to add the corresponding
functionality for smart pointers.

PiperOrigin-RevId: 590861070
Change-Id: I3e16ce8107392c9632e0ab9d43fead1ed32d93d8
diff --git a/nullability/pointer_nullability_matchers.cc b/nullability/pointer_nullability_matchers.cc
index d5e9781..29c858e 100644
--- a/nullability/pointer_nullability_matchers.cc
+++ b/nullability/pointer_nullability_matchers.cc
@@ -15,6 +15,7 @@
 
 using ast_matchers::anyOf;
 using ast_matchers::argumentCountIs;
+using ast_matchers::arraySubscriptExpr;
 using ast_matchers::binaryOperator;
 using ast_matchers::booleanType;
 using ast_matchers::callee;
@@ -36,6 +37,7 @@
 using ast_matchers::hasAnyOperatorName;
 using ast_matchers::hasAnyOverloadedOperatorName;
 using ast_matchers::hasArgument;
+using ast_matchers::hasBase;
 using ast_matchers::hasBody;
 using ast_matchers::hasCanonicalType;
 using ast_matchers::hasCastKind;
@@ -77,6 +79,9 @@
 Matcher<Stmt> isPointerDereference() {
   return unaryOperator(hasOperatorName("*"), hasUnaryOperand(isPointerExpr()));
 }
+Matcher<Stmt> isPointerSubscript() {
+  return arraySubscriptExpr(hasBase(isPointerExpr()));
+}
 Matcher<Stmt> isPointerCheckBinOp() {
   return binaryOperator(hasAnyOperatorName("!=", "=="),
                         hasOperands(isPointerExpr(), isPointerExpr()));