From c1981f28ad98e933d5a89ca1ae36ff7008175d08 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 18 Apr 2019 18:50:52 +0000 Subject: [PATCH] build: +OPENCV_ENABLE_MEMORY_SANITIZER flag --- CMakeLists.txt | 1 + cmake/OpenCVCompilerOptions.cmake | 3 +++ modules/core/include/opencv2/core/utility.hpp | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 759de6ece6..d177730006 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -470,6 +470,7 @@ OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) ) OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CV_GCC ) OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CV_GCC ) +OCV_OPTION(OPENCV_ENABLE_MEMORY_SANITIZER "Better support for memory/address sanitizers" OFF) OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CV_GCC ) OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CV_GCC AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) ) OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CV_GCC AND (X86 OR X86_64)) ) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index ee67599053..fc29d279c4 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -381,4 +381,7 @@ macro(ocv_add_modules_compiler_options) string(REPLACE "/W3" "/W4" ${flags} "${${flags}}") endforeach() endif() + if(OPENCV_ENABLE_MEMORY_SANITIZER) + add_definitions(-DOPENCV_ENABLE_MEMORY_SANITIZER=1) + endif() endmacro() diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp index 7a7158f5f9..cbec10b41b 100644 --- a/modules/core/include/opencv2/core/utility.hpp +++ b/modules/core/include/opencv2/core/utility.hpp @@ -116,7 +116,11 @@ CV_EXPORTS void setUseCollection(bool flag); // set implementation collection st } \endcode */ +#ifdef OPENCV_ENABLE_MEMORY_SANITIZER +template class AutoBuffer +#else template class AutoBuffer +#endif { public: typedef _Tp value_type;