================
@@ -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);
+}
+
+TEST_F(PointerFlowTest, EmptyInitsUnion) {
+ ASSERT_EQ(setUpTest(R"cpp(
+ union U { int x; int *p; };
+ void foo() {
+ U u{};
+ U uu = {};
+ }
+ )cpp"),
+ true);
+
+ auto *Sum = getEntitySummary("foo");
+
+ ASSERT_EQ(Sum, nullptr);
+}
----------------
steakhal wrote:
Could you also demonstrate this empty init for structs and classes?
https://github.com/llvm/llvm-project/pull/201968
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits