[libcxx-commits] [PATCH] D126073: [libc++] Assume that push_macro and pop_macro are available

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 20 08:14:31 PDT 2022


philnik created this revision.
philnik added reviewers: ldionne, Mordante, var-const.
Herald added a subscriber: mgorny.
Herald added a project: All.
philnik requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

All compilers that libc++ supports support `push_macro` and `pop_macro`. So let's remove it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126073

Files:
  libcxx/CMakeLists.txt
  libcxx/include/__config
  libcxx/include/__undef_macros


Index: libcxx/include/__undef_macros
===================================================================
--- libcxx/include/__undef_macros
+++ libcxx/include/__undef_macros
@@ -7,27 +7,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 #ifdef min
-#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
-#if defined(_LIBCPP_WARNING)
-_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
+#  undef min
 #endif
 
 #ifdef max
-#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
-#if defined(_LIBCPP_WARNING)
-_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
+#  undef max
 #endif
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -1235,35 +1235,8 @@
 #define _LIBCPP_HAS_NO_CXX20_COROUTINES
 #endif
 
-#if defined(_LIBCPP_COMPILER_IBM)
-#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO
-#endif
-
-#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
-#  define _LIBCPP_PUSH_MACROS
-#  define _LIBCPP_POP_MACROS
-#else
-  // Don't warn about macro conflicts when we can restore them at the
-  // end of the header.
-#  ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
-#    define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS
-#  endif
-#  if defined(_LIBCPP_COMPILER_MSVC)
-#    define _LIBCPP_PUSH_MACROS    \
-       __pragma(push_macro("min")) \
-       __pragma(push_macro("max"))
-#    define _LIBCPP_POP_MACROS     \
-       __pragma(pop_macro("min"))  \
-       __pragma(pop_macro("max"))
-#  else
-#    define _LIBCPP_PUSH_MACROS        \
-       _Pragma("push_macro(\"min\")")  \
-       _Pragma("push_macro(\"max\")")
-#    define _LIBCPP_POP_MACROS         \
-       _Pragma("pop_macro(\"min\")")   \
-       _Pragma("pop_macro(\"max\")")
-#  endif
-#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
+#  define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")
+#  define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")")
 
 #ifndef _LIBCPP_NO_AUTO_LINK
 #  if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -634,9 +634,6 @@
   if (LIBCXX_ENABLE_PEDANTIC)
     target_add_compile_flags_if_supported(${target} PRIVATE -pedantic)
   endif()
-  if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS)
-    target_compile_definitions(${target} PRIVATE -D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
-  endif()
 endfunction()
 
 # Exception flags =============================================================


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126073.430980.patch
Type: text/x-patch
Size: 3047 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220520/8e0f5768/attachment-0001.bin>


More information about the libcxx-commits mailing list