Add option to disable __deallocate #warning

From r229162:
  Visual Studio's SAL extension uses a macro named __deallocate. This
  macro is used pervasively
Using -Werror when building for Windows can force the use of -Wno-#warnings
specifically because of this __deallocate #warning. Instead of forcing
builds to disable all #warnings, this option allows libc++ to be built
without this particular warning, while leaving other #warnings enabled.

Patch by Dave Lee!

llvm-svn: 275172
This commit is contained in:
Saleem Abdulrasool 2016-07-12 14:39:13 +00:00
parent 92aa427bb8
commit 6fe307334f
3 changed files with 10 additions and 0 deletions

View File

@ -135,6 +135,7 @@ option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread AP
# about #include_next which is used everywhere.
option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
option(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF)
option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF)
set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
@ -323,6 +324,9 @@ endif()
if (LIBCXX_ENABLE_PEDANTIC)
add_compile_flags_if_supported(-pedantic)
endif()
if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS)
add_definitions(-D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
endif()
# Exception flags =============================================================
if (LIBCXX_ENABLE_EXCEPTIONS)

View File

@ -9,10 +9,12 @@
//===----------------------------------------------------------------------===//
#ifdef __deallocate
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
#if defined(_MSC_VER) && !defined(__clang__)
_LIBCPP_WARNING("macro __deallocate is incompatible with C++. #undefining __deallocate")
#else
#warning: macro __deallocate is incompatible with C++. #undefining __deallocate
#endif
#endif
#undef __deallocate
#endif

View File

@ -9,21 +9,25 @@
//===----------------------------------------------------------------------===//
#ifdef min
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
#if defined(_MSC_VER) && ! defined(__clang__)
_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX "
"before any Windows header. #undefing min")
#else
#warning: macro min is incompatible with C++. #undefing min
#endif
#endif
#undef min
#endif
#ifdef max
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
#if defined(_MSC_VER) && ! defined(__clang__)
_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX "
"before any Windows header. #undefing max")
#else
#warning: macro max is incompatible with C++. #undefing max
#endif
#endif
#undef max
#endif