[libc++] Add a few missing min/max macro push/pop
authorLouis Dionne <ldionne.2@gmail.com>
Mon, 27 Jun 2022 15:37:01 +0000 (11:37 -0400)
committerLouis Dionne <ldionne.2@gmail.com>
Mon, 27 Jun 2022 16:57:39 +0000 (12:57 -0400)
Also, improve the test for nasty macros to define min and max, so this
will be caught in the future.

Differential Revision: https://reviews.llvm.org/D128655

libcxx/include/__algorithm/ranges_minmax.h
libcxx/include/__ranges/drop_view.h
libcxx/test/libcxx/containers/associative/undef_min_max.pass.cpp [deleted file]
libcxx/test/libcxx/nasty_macros.compile.pass.cpp
libcxx/test/libcxx/numerics/c.math/undef_min_max.pass.cpp [deleted file]

index c9f49f6..2f4bba0 100644 (file)
@@ -31,6 +31,9 @@
 
 #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
 
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 namespace ranges {
@@ -123,6 +126,8 @@ inline namespace __cpo {
 
 _LIBCPP_END_NAMESPACE_STD
 
+_LIBCPP_POP_MACROS
+
 #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
 
 #endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
index 962bc4e..b2a8ee5 100644 (file)
@@ -40,6 +40,9 @@
 #  pragma GCC system_header
 #endif
 
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
@@ -298,4 +301,6 @@ inline namespace __cpo {
 
 _LIBCPP_END_NAMESPACE_STD
 
+_LIBCPP_POP_MACROS
+
 #endif // _LIBCPP___RANGES_DROP_VIEW_H
diff --git a/libcxx/test/libcxx/containers/associative/undef_min_max.pass.cpp b/libcxx/test/libcxx/containers/associative/undef_min_max.pass.cpp
deleted file mode 100644 (file)
index e28fb14..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#define min THIS IS A NASTY MACRO!
-#define max THIS IS A NASTY MACRO!
-
-#include <map>
-
-int main(int, char**) {
-  std::map<int, int> m;
-  ((void)m);
-
-  return 0;
-}
index 0874dee..162d230 100644 (file)
 #define Xp NASTY_MACRO
 #define Xs NASTY_MACRO
 
+// The classic Windows min/max macros
+#define min NASTY_MACRO
+#define max NASTY_MACRO
+
 /*
 BEGIN-SCRIPT
 
diff --git a/libcxx/test/libcxx/numerics/c.math/undef_min_max.pass.cpp b/libcxx/test/libcxx/numerics/c.math/undef_min_max.pass.cpp
deleted file mode 100644 (file)
index dc8c9c9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#define min THIS IS A NASTY MACRO!
-#define max THIS IS A NASTY MACRO!
-
-#include <cmath>
-
-int main(int, char**) { return 0; }