From 296dda9b0c8b56431b9ba527c7090458e649382e Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 28 Jul 2023 19:47:12 +0200 Subject: [PATCH] fixed #13201 - removed usage of `_CRTDBG_MAP_ALLOC` and related code --- cli/main.cpp | 5 ----- cmake/compilerDefinitions.cmake | 4 ---- cmake/findDependencies.cmake | 9 --------- cmake/options.cmake | 1 - cmake/printInfo.cmake | 1 - cppcheckpremium-suppressions | 3 --- gui/CMakeLists.txt | 4 ---- lib/config.h | 6 ------ releasenotes.txt | 1 + test/main.cpp | 5 ----- 10 files changed, 1 insertion(+), 38 deletions(-) diff --git a/cli/main.cpp b/cli/main.cpp index d2a8417560e..7c3a865a302 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -76,11 +76,6 @@ */ int main(int argc, char* argv[]) { - // MS Visual C++ memory leak debug tracing -#if defined(_MSC_VER) && defined(_DEBUG) - _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); -#endif - CppCheckExecutor exec; // *INDENT-OFF* diff --git a/cmake/compilerDefinitions.cmake b/cmake/compilerDefinitions.cmake index 4f62e411046..4967c282336 100644 --- a/cmake/compilerDefinitions.cmake +++ b/cmake/compilerDefinitions.cmake @@ -54,10 +54,6 @@ if(DISALLOW_PROCESS_EXECUTOR) add_definitions(-DDISALLOW_PROCESS_EXECUTOR) endif() -if(MSVC AND DISABLE_CRTDBG_MAP_ALLOC) - add_definitions(-DDISABLE_CRTDBG_MAP_ALLOC) -endif() - if(NO_UNIX_SIGNAL_HANDLING) add_definitions(-DNO_UNIX_SIGNAL_HANDLING) endif() diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index 3fffa420a5e..61458ced051 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -13,15 +13,6 @@ if(BUILD_GUI) message(WARNING "'Qt6Core_VERSION' is not set - using 6.0.0 as fallback") set(QT_VERSION "6.0.0") endif() - if(MSVC) - # disable Visual Studio C++ memory leak detection since it causes compiler errors with Qt 6 - # D:\a\cppcheck\Qt\6.2.4\msvc2019_64\include\QtCore/qhash.h(179,15): warning C4003: not enough arguments for function-like macro invocation 'free' [D:\a\cppcheck\cppcheck\build\gui\cppcheck-gui.vcxproj] - # D:\a\cppcheck\Qt\6.2.4\msvc2019_64\include\QtCore/qhash.h(179,15): error C2059: syntax error: ',' [D:\a\cppcheck\cppcheck\build\gui\cppcheck-gui.vcxproj] - # this is supposed to be fixed according to the following tickets but it still happens - # https://bugreports.qt.io/browse/QTBUG-40575 - # https://bugreports.qt.io/browse/QTBUG-86395 - set(DISABLE_CRTDBG_MAP_ALLOC ON) - endif() if(BUILD_ONLINE_HELP) find_program(QHELPGENERATOR qhelpgenerator) diff --git a/cmake/options.cmake b/cmake/options.cmake index 3c093bd7eaa..7de7cb360f6 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -104,7 +104,6 @@ if (NOT USE_BOOST AND USE_BOOST_INT128) endif() option(USE_LIBCXX "Use libc++ instead of libstdc++" OFF) -option(DISABLE_CRTDBG_MAP_ALLOC "Disable usage of Visual Studio C++ memory leak detection in Debug build" OFF) option(NO_UNIX_SIGNAL_HANDLING "Disable usage of Unix Signal Handling" OFF) option(NO_UNIX_BACKTRACE_SUPPORT "Disable usage of Unix Backtrace support" OFF) option(NO_WINDOWS_SEH "Disable usage of Windows SEH" OFF) diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake index 8315e414485..6ea93bed207 100644 --- a/cmake/printInfo.cmake +++ b/cmake/printInfo.cmake @@ -38,7 +38,6 @@ message(STATUS) message(STATUS "USE_MATCHCOMPILER = ${USE_MATCHCOMPILER}") message(STATUS "USE_MATCHCOMPILER_OPT = ${USE_MATCHCOMPILER_OPT}") message(STATUS) -message(STATUS "DISABLE_CRTDBG_MAP_ALLOC = ${DISABLE_CRTDBG_MAP_ALLOC}") message(STATUS "NO_UNIX_SIGNAL_HANDLING = ${NO_UNIX_SIGNAL_HANDLING}") message(STATUS "NO_UNIX_BACKTRACE_SUPPORT = ${NO_UNIX_BACKTRACE_SUPPORT}") message(STATUS "NO_WINDOWS_SEH = ${NO_WINDOWS_SEH}") diff --git a/cppcheckpremium-suppressions b/cppcheckpremium-suppressions index f4c472f0671..6d3f16782bc 100644 --- a/cppcheckpremium-suppressions +++ b/cppcheckpremium-suppressions @@ -25,9 +25,6 @@ premium-cert-str34-c # we intentionally pass structs premium-cert-dcl39-c-* -# we need to declare reserved identifier _CRTDBG_MAP_ALLOC -premium-cert-dcl51-cpp - # we don't want to check the return values of fclose/sprintf/etc premium-cert-err33-c diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index ff329ad1163..493c6a482d0 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -40,10 +40,6 @@ CheckOptions: if(WITH_QCHART) target_link_libraries(cppcheck-gui ${QT_CHARTS_LIB}) endif() - if(MSVC) - # compilation will fail as e.g. QList::realloc would be replaced by MSVC's macro definition - target_compile_definitions(cppcheck-gui PRIVATE $<$:DISABLE_CRTDBG_MAP_ALLOC>) - endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(QT_VERSION VERSION_LESS "6.4.0") # caused by Qt generated moc code - see https://bugreports.qt.io/browse/QTBUG-100915 diff --git a/lib/config.h b/lib/config.h index 34d426eb162..1b217e4546d 100644 --- a/lib/config.h +++ b/lib/config.h @@ -35,12 +35,6 @@ # define CPPCHECKLIB #endif -// MS Visual C++ memory leak debug tracing -#if !defined(DISABLE_CRTDBG_MAP_ALLOC) && defined(_MSC_VER) && defined(_DEBUG) -# define _CRTDBG_MAP_ALLOC -# include -#endif - // compatibility macros #ifndef __has_builtin #define __has_builtin(x) 0 diff --git a/releasenotes.txt b/releasenotes.txt index 919e355fb1b..f130e957aec 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -14,6 +14,7 @@ GUI: - Changed interface: +- removed CMake option "DISABLE_CRTDBG_MAP_ALLOC" - Infrastructure & dependencies: diff --git a/test/main.cpp b/test/main.cpp index 571b126922d..afe3e3b4171 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -25,11 +25,6 @@ int main(int argc, char *argv[]) { - // MS Visual C++ memory leak debug tracing -#if defined(_MSC_VER) && defined(_DEBUG) - _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); -#endif - Preprocessor::macroChar = '$'; // While macroChar is char(1) per default outside test suite, we require it to be a human-readable character here. gDisableColors = true;