================
@@ -967,6 +967,53 @@ TEST_F(PointerFlowTest, ArrayOfStructInitList) {
                                       }));
 }
 
+TEST_F(PointerFlowTest, ScalarPointerBraceInit) {
+  ASSERT_EQ(setUpTest(R"cpp(
+    int *q;
+    void foo() {
+      int *p{q};
+    }
+  )cpp"),
+            true);
+
+  auto *Sum = getEntitySummary("foo");
+
+  ASSERT_NE(Sum, nullptr);
+  EXPECT_EQ(*Sum, makeEdges(__LINE__, {{{"p", 1U}, {"q", 1U}}}));
+}
+
+TEST_F(PointerFlowTest, EmptyInitsScalarInt) {
+  ASSERT_EQ(setUpTest(R"cpp(
+    void foo() {
+      int x{};
+      int y = {};
+      int *p{};
+      int *q = {};
+    }
+  )cpp"),
+            true);
+
+  auto *Sum = getEntitySummary("foo");
+
+  // No pointer-flow edge for 0-initialized scalar.
+  ASSERT_EQ(Sum, nullptr);
----------------
steakhal wrote:

I'd also open the discussion for changing this pattern (here and in the future, 
and also cleaning up what we currently have in the long future) to:

```suggestion
  // No pointer-flow edge for 0-initialized scalar.
  ASSERT_FALSE(getEntitySummary("foo"));
```

Feel free to challenge this, but right now I don't see a compelling reason 
against this, and my goal is to align now, to avoid review friction in the 
future.

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

Reply via email to