[libcxx] r275172 - Add option to disable __deallocate #warning

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 12 07:39:13 PDT 2016


Author: compnerd
Date: Tue Jul 12 09:39:13 2016
New Revision: 275172

URL: http://llvm.org/viewvc/llvm-project?rev=275172&view=rev
Log:
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!

Modified:
    libcxx/trunk/CMakeLists.txt
    libcxx/trunk/include/__undef___deallocate
    libcxx/trunk/include/__undef_min_max

Modified: libcxx/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=275172&r1=275171&r2=275172&view=diff
==============================================================================
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Jul 12 09:39:13 2016
@@ -135,6 +135,7 @@ option(LIBCXX_HAS_PTHREAD_API "Ignore au
 # 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)

Modified: libcxx/trunk/include/__undef___deallocate
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__undef___deallocate?rev=275172&r1=275171&r2=275172&view=diff
==============================================================================
--- libcxx/trunk/include/__undef___deallocate (original)
+++ libcxx/trunk/include/__undef___deallocate Tue Jul 12 09:39:13 2016
@@ -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

Modified: libcxx/trunk/include/__undef_min_max
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__undef_min_max?rev=275172&r1=275171&r2=275172&view=diff
==============================================================================
--- libcxx/trunk/include/__undef_min_max (original)
+++ libcxx/trunk/include/__undef_min_max Tue Jul 12 09:39:13 2016
@@ -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




More information about the cfe-commits mailing list