Skip to content

Commit b0bbcff

Browse files
authored
fixed #13201 - removed usage of _CRTDBG_MAP_ALLOC and related code (danmar#6886)
it was never fully implemented and also does not work with Qt 6
1 parent 7abb484 commit b0bbcff

File tree

10 files changed

+1
-38
lines changed

10 files changed

+1
-38
lines changed

cli/main.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@
7676
*/
7777
int main(int argc, char* argv[])
7878
{
79-
// MS Visual C++ memory leak debug tracing
80-
#if defined(_MSC_VER) && defined(_DEBUG)
81-
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
82-
#endif
83-
8479
CppCheckExecutor exec;
8580

8681
// *INDENT-OFF*

cmake/compilerDefinitions.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ if(DISALLOW_PROCESS_EXECUTOR)
5454
add_definitions(-DDISALLOW_PROCESS_EXECUTOR)
5555
endif()
5656

57-
if(MSVC AND DISABLE_CRTDBG_MAP_ALLOC)
58-
add_definitions(-DDISABLE_CRTDBG_MAP_ALLOC)
59-
endif()
60-
6157
if(NO_UNIX_SIGNAL_HANDLING)
6258
add_definitions(-DNO_UNIX_SIGNAL_HANDLING)
6359
endif()

cmake/findDependencies.cmake

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ if(BUILD_GUI)
1313
message(WARNING "'Qt6Core_VERSION' is not set - using 6.0.0 as fallback")
1414
set(QT_VERSION "6.0.0")
1515
endif()
16-
if(MSVC)
17-
# disable Visual Studio C++ memory leak detection since it causes compiler errors with Qt 6
18-
# 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]
19-
# 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]
20-
# this is supposed to be fixed according to the following tickets but it still happens
21-
# https://bugreports.qt.io/browse/QTBUG-40575
22-
# https://bugreports.qt.io/browse/QTBUG-86395
23-
set(DISABLE_CRTDBG_MAP_ALLOC ON)
24-
endif()
2516

2617
if(BUILD_ONLINE_HELP)
2718
find_program(QHELPGENERATOR qhelpgenerator)

cmake/options.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ if (NOT USE_BOOST AND USE_BOOST_INT128)
104104
endif()
105105
option(USE_LIBCXX "Use libc++ instead of libstdc++" OFF)
106106

107-
option(DISABLE_CRTDBG_MAP_ALLOC "Disable usage of Visual Studio C++ memory leak detection in Debug build" OFF)
108107
option(NO_UNIX_SIGNAL_HANDLING "Disable usage of Unix Signal Handling" OFF)
109108
option(NO_UNIX_BACKTRACE_SUPPORT "Disable usage of Unix Backtrace support" OFF)
110109
option(NO_WINDOWS_SEH "Disable usage of Windows SEH" OFF)

cmake/printInfo.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ message(STATUS)
3838
message(STATUS "USE_MATCHCOMPILER = ${USE_MATCHCOMPILER}")
3939
message(STATUS "USE_MATCHCOMPILER_OPT = ${USE_MATCHCOMPILER_OPT}")
4040
message(STATUS)
41-
message(STATUS "DISABLE_CRTDBG_MAP_ALLOC = ${DISABLE_CRTDBG_MAP_ALLOC}")
4241
message(STATUS "NO_UNIX_SIGNAL_HANDLING = ${NO_UNIX_SIGNAL_HANDLING}")
4342
message(STATUS "NO_UNIX_BACKTRACE_SUPPORT = ${NO_UNIX_BACKTRACE_SUPPORT}")
4443
message(STATUS "NO_WINDOWS_SEH = ${NO_WINDOWS_SEH}")

cppcheckpremium-suppressions

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ premium-cert-str34-c
2525
# we intentionally pass structs
2626
premium-cert-dcl39-c-*
2727

28-
# we need to declare reserved identifier _CRTDBG_MAP_ALLOC
29-
premium-cert-dcl51-cpp
30-
3128
# we don't want to check the return values of fclose/sprintf/etc
3229
premium-cert-err33-c
3330

gui/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ CheckOptions:
4040
if(WITH_QCHART)
4141
target_link_libraries(cppcheck-gui ${QT_CHARTS_LIB})
4242
endif()
43-
if(MSVC)
44-
# compilation will fail as e.g. QList::realloc would be replaced by MSVC's macro definition
45-
target_compile_definitions(cppcheck-gui PRIVATE $<$<CONFIG:Debug>:DISABLE_CRTDBG_MAP_ALLOC>)
46-
endif()
4743
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
4844
if(QT_VERSION VERSION_LESS "6.4.0")
4945
# caused by Qt generated moc code - see https://bugreports.qt.io/browse/QTBUG-100915

lib/config.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@
3535
# define CPPCHECKLIB
3636
#endif
3737

38-
// MS Visual C++ memory leak debug tracing
39-
#if !defined(DISABLE_CRTDBG_MAP_ALLOC) && defined(_MSC_VER) && defined(_DEBUG)
40-
# define _CRTDBG_MAP_ALLOC
41-
# include <crtdbg.h>
42-
#endif
43-
4438
// compatibility macros
4539
#ifndef __has_builtin
4640
#define __has_builtin(x) 0

releasenotes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ GUI:
1414
-
1515

1616
Changed interface:
17+
- removed CMake option "DISABLE_CRTDBG_MAP_ALLOC"
1718
-
1819

1920
Infrastructure & dependencies:

test/main.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525

2626
int main(int argc, char *argv[])
2727
{
28-
// MS Visual C++ memory leak debug tracing
29-
#if defined(_MSC_VER) && defined(_DEBUG)
30-
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
31-
#endif
32-
3328
Preprocessor::macroChar = '$'; // While macroChar is char(1) per default outside test suite, we require it to be a human-readable character here.
3429
gDisableColors = true;
3530

0 commit comments

Comments
 (0)