================ @@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix +// expected-no-diagnostics + +#include "Inputs/system-header-simulator-for-malloc.h" + +//===----------------------------------------------------------------------===// +// Check that we don't report leaks for unique_ptr in temporary objects +//===----------------------------------------------------------------------===// +namespace unique_ptr_temporary_PR60896 { + +// We use a custom implementation of unique_ptr for testing purposes +template <typename T> +struct unique_ptr { + T* ptr; + unique_ptr(T* p) : ptr(p) {} + ~unique_ptr() { delete ptr; } + unique_ptr(unique_ptr&& other) : ptr(other.ptr) { other.ptr = nullptr; } + T* get() const { return ptr; } +}; ---------------- steakhal wrote:
I'm pretty sure some header simulator already has a unique_ptr somewhere. We should use that. https://github.com/llvm/llvm-project/pull/152751 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits