[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)
Ivan Murashko via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 30 17:09:21 PDT 2025
================
@@ -0,0 +1,232 @@
+// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \
+// RUN: -analyzer-checker=core \
+// RUN: -analyzer-checker=cplusplus \
+// RUN: -analyzer-checker=unix \
+// RUN: -analyzer-checker=unix.Malloc
+
+#include "Inputs/system-header-simulator-for-malloc.h"
+
+//===----------------------------------------------------------------------===//
+// unique_ptr test cases
+//===----------------------------------------------------------------------===//
+namespace unique_ptr_tests {
+
+// Custom unique_ptr implementation for testing
+template <typename T>
+struct unique_ptr {
+ T* ptr;
+ unique_ptr(T* p) : ptr(p) {}
+ ~unique_ptr() { delete ptr; }
----------------
ivanmurashko wrote:
Commit ee1c3ab5ec6afd83e105c69dc09b3eb54790783f added the same for shared_ptr
https://github.com/llvm/llvm-project/pull/152751
More information about the cfe-commits
mailing list