================
@@ -1126,4 +1126,47 @@ TEST_F(PointerFlowTest, NestedLambdaAssign) {
ASSERT_NE(Sum, nullptr);
EXPECT_EQ(*Sum, makeEdges(__LINE__, {{{"y", 1U}, {"x", 1U}}}));
}
+
+//////////////////////////////////////////////////////////////
+// Robustness Tests (No Crash Tests) //
+//////////////////////////////////////////////////////////////
+
+TEST_F(PointerFlowTest, StructuredBindingWithPointers) {
+ StringRef Code = R"cpp(
+ void foo() {
+ int *a[2];
+ auto [ptr1, ptr2] = a;
+ ptr1[5];
+ ptr2[3];
+ }
+ )cpp";
+
+ // BindingDecl may not be fully supported, but should not crash
+ llvm::SaveAndRestore<bool> DebugFlag(llvm::DebugFlag, true);
+ llvm::setCurrentDebugType("ssaf-analyses");
+ testing::internal::CaptureStderr();
+
+ ASSERT_TRUE(setUpTest(Code));
+ // Verify the warning was logged
+ ASSERT_TRUE(StringRef(testing::internal::GetCapturedStderr())
+ .contains("failed to create EntityId for Decomposition"));
+}
+
+TEST_F(PointerFlowTest, RHSResultsInNoEntityPointerLevel) {
+ ASSERT_EQ(setUpTest(R"cpp(
+ void f() {
+ int *p = new int[10];
+ const char *q = "hello";
+ }
+ struct S {
+ int *p;
+ void g() { p = (int *)this; }
+ };
+ )cpp"),
+ true);
+ auto *Sum = getEntitySummary<FunctionDecl>("f");
+ ASSERT_FALSE(Sum);
+ Sum = getEntitySummary<CXXMethodDecl>("g");
+ ASSERT_FALSE(Sum);
----------------
steakhal wrote:
```suggestion
ASSERT_FALSE(getEntitySummary<FunctionDecl>("f"));
ASSERT_FALSE(getEntitySummary<CXXMethodDecl>("g"));
```
https://github.com/llvm/llvm-project/pull/201953
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits