================
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits