================
@@ -1126,4 +1127,51 @@ 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::DebugFlag = true;
+  llvm::setCurrentDebugType("ssaf-analyses");
+  testing::internal::CaptureStderr();
+
+  ASSERT_EQ(setUpTest(Code), true);
+
+  std::string Output = testing::internal::GetCapturedStderr();
+  llvm::DebugFlag = false;
----------------
steakhal wrote:

Use a scope-exit to ensure that DebugFlag is unset even if the test fails (and 
basically aborts at `ASSERT_EQ(setUpTest(Code), true);` Same applies to the 
other test case.

That said, you should use `ASSERT_TRUE(setUpTest(Code))` instead.

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

Reply via email to