From 385f9ed3ad01a915a8a1696b9da8289d669ed7b0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 17 May 2023 15:02:57 -0400 Subject: [PATCH] any: Tell clang-analyzer a pointer is not nullptr (#107) Previously, clang-analyzer warned: /.../any.h:146:5: warning: Called C++ object pointer is null [core.CallAndMessage] --- include/dap/any.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/dap/any.h b/include/dap/any.h index 4a6444c..7e6553f 100644 --- a/include/dap/any.h +++ b/include/dap/any.h @@ -143,6 +143,9 @@ any& any::operator=(const T& val) { alloc(type->size(), type->alignment()); type->copyConstruct(value, &val); } else { +#ifdef __clang_analyzer__ + assert(value != nullptr); +#endif *reinterpret_cast(value) = val; } return *this;