================
@@ -2928,6 +2928,54 @@ TEST_P(UncheckedStatusOrAccessModelTest, 
PointerEqualityCheck) {
       )cc");
 }
 
+TEST_P(UncheckedStatusOrAccessModelTest, Emplace) {
+  ExpectDiagnosticsFor(R"cc(
+#include "unchecked_statusor_access_test_defs.h"
+
+    struct Foo {
+      Foo(int);
+    };
+
+    void target(absl::StatusOr<Foo> sor, int value) {
+      sor.emplace(value);
+      sor.value();
+    }
+  )cc");
+  ExpectDiagnosticsFor(R"cc(
+#include "unchecked_statusor_access_test_defs.h"
+
+    struct Foo {
+      Foo(std::initializer_list<int>, int);
+    };
+
+    void target(absl::StatusOr<Foo> sor, int value) {
+      sor.emplace({1, 2, 3}, value);
+      sor.value();
+    }
+  )cc");
+  ExpectDiagnosticsFor(R"cc(
+#include "unchecked_statusor_access_test_defs.h"
+
+    void target(bool b) {
+      STATUSOR_INT sor;
+      bool sor_ok = sor.ok();
+      if (b)
+        sor.emplace(42);
+      else if (sor_ok)
+        sor.value();
----------------
jvoung wrote:

Hmm, the `emplace` happens in a disjoint branch from the `value()` access, so 
seems like it wouldn't directly test the emplace.

Did you mean to test if there is a control flow join (if not ok, do the 
emplace, if ok, no need to emplace, then after the branches access the value)?


https://github.com/llvm/llvm-project/pull/163876
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to