[clang] [SSAF][Extractor] Make hard errors in Extractors quiet (PR #201953)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 8 00:44:44 PDT 2026


================
@@ -570,4 +571,28 @@ TEST_F(UnsafeBufferUsageTest, NestedDefinitions2) {
   EXPECT_EQ(Sum, nullptr);
 }
 
+// Robustness test: unsupported constructs will not cause crash
+TEST_F(UnsafeBufferUsageTest, DirectNewExpressionArrayAccess) {
+  // 'new' not yet supported, but should not crash and should log warning
+  llvm::DebugFlag = true;
+  llvm::setCurrentDebugType("ssaf-analyses");
+  testing::internal::CaptureStderr();
+
+  ASSERT_TRUE(setUpTest(R"cpp(
+    void foo(int i) {
+      (new int[2])[i];
+    }
+  )cpp"));
+
+  std::string Output = testing::internal::GetCapturedStderr();
+  llvm::DebugFlag = false;
+
+  // The only unsafe pointer is unsupported, so no summary should be produced.
+  EXPECT_EQ(getEntitySummary("foo"), nullptr);
+  // Verify the warning was logged
+  EXPECT_NE(
+      Output.find("attempt to translate CXXNewExpr to EntityPointerLevels"),
+      std::string::npos);
----------------
steakhal wrote:

Have you though of using `StringRef::contains`?

https://github.com/llvm/llvm-project/pull/201953


More information about the cfe-commits mailing list