[clang] [SSAF][PointerFlowExtractor] Handle empty initializer lists for scalars and unions (PR #201968)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 8 00:58:20 PDT 2026
================
@@ -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
More information about the cfe-commits
mailing list