Access correct arguments for CXXOperatorCallExprs when collecting nullability evidence.

Also, skip only the parameter if unable to emit evidence, rather than the whole function call.

PiperOrigin-RevId: 550532560
Change-Id: Ia4b34023d6fa126f230ca0357c1f3a2f2ac0b890
diff --git a/nullability/inference/collect_evidence_test.cc b/nullability/inference/collect_evidence_test.cc
index d6b3fb2..a1de037 100644
--- a/nullability/inference/collect_evidence_test.cc
+++ b/nullability/inference/collect_evidence_test.cc
@@ -373,6 +373,51 @@
                                     functionNamed("target"))));
 }
 
+TEST(CollectEvidenceFromImplementationTest, MemberOperatorCall) {
+  static constexpr llvm::StringRef Src = R"cc(
+    struct S {
+      bool operator+(int*);
+    };
+    void target() { S{} + nullptr; }
+  )cc";
+  EXPECT_THAT(collectEvidenceFromTargetFunction(Src),
+              Contains(evidence(paramSlot(0), Evidence::NULLABLE_ARGUMENT,
+                                functionNamed("operator+"))));
+}
+
+TEST(CollectEvidenceFromImplementationTest, NonMemberOperatorCall) {
+  static constexpr llvm::StringRef Src = R"cc(
+    struct S {};
+    bool operator+(const S&, int*);
+    void target() { S{} + nullptr; }
+  )cc";
+  EXPECT_THAT(collectEvidenceFromTargetFunction(Src),
+              Contains(evidence(paramSlot(1), Evidence::NULLABLE_ARGUMENT,
+                                functionNamed("operator+"))));
+}
+
+TEST(CollectEvidenceFromImplementationTest, VarArgs) {
+  static constexpr llvm::StringRef Src = R"cc(
+    void callee(int*...);
+    void target() { callee(nullptr, nullptr); }
+  )cc";
+  EXPECT_THAT(collectEvidenceFromTargetFunction(Src),
+              Contains(evidence(paramSlot(0), Evidence::NULLABLE_ARGUMENT,
+                                functionNamed("callee"))));
+}
+
+TEST(CollectEvidenceFromImplementationTest, MemberOperatorCallVarArgs) {
+  static constexpr llvm::StringRef Src = R"cc(
+    struct S {
+      bool operator()(int*...);
+    };
+    void target() { S{}(nullptr, nullptr); }
+  )cc";
+  EXPECT_THAT(collectEvidenceFromTargetFunction(Src),
+              Contains(evidence(paramSlot(0), Evidence::NULLABLE_ARGUMENT,
+                                functionNamed("operator()"))));
+}
+
 TEST(CollectEvidenceFromDeclarationTest, VariableDeclIgnored) {
   llvm::StringLiteral Src = "Nullable<int *> target;";
   EXPECT_THAT(collectEvidenceFromTargetDecl(Src), IsEmpty());