[libcxx-commits] [libcxx] a2c1603 - [libc++] Add a few missing min/max macro push/pop
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 27 09:57:50 PDT 2022
Author: Louis Dionne
Date: 2022-06-27T12:57:39-04:00
New Revision: a2c1603206a49affafeba3d1b6b0ee0f4e1592e6
URL: https://github.com/llvm/llvm-project/commit/a2c1603206a49affafeba3d1b6b0ee0f4e1592e6
DIFF: https://github.com/llvm/llvm-project/commit/a2c1603206a49affafeba3d1b6b0ee0f4e1592e6.diff
LOG: [libc++] Add a few missing min/max macro push/pop
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
Added:
Modified:
libcxx/include/__algorithm/ranges_minmax.h
libcxx/include/__ranges/drop_view.h
libcxx/test/libcxx/nasty_macros.compile.pass.cpp
Removed:
libcxx/test/libcxx/containers/associative/undef_min_max.pass.cpp
libcxx/test/libcxx/numerics/c.math/undef_min_max.pass.cpp
################################################################################
diff --git a/libcxx/include/__algorithm/ranges_minmax.h b/libcxx/include/__algorithm/ranges_minmax.h
index c9f49f676cf57..2f4bba0e7cc08 100644
--- a/libcxx/include/__algorithm/ranges_minmax.h
+++ b/libcxx/include/__algorithm/ranges_minmax.h
@@ -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
diff --git a/libcxx/include/__ranges/drop_view.h b/libcxx/include/__ranges/drop_view.h
index 962bc4e900db1..b2a8ee5814756 100644
--- a/libcxx/include/__ranges/drop_view.h
+++ b/libcxx/include/__ranges/drop_view.h
@@ -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
index e28fb14c11a68..0000000000000
--- a/libcxx/test/libcxx/containers/associative/undef_min_max.pass.cpp
+++ /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;
-}
diff --git a/libcxx/test/libcxx/nasty_macros.compile.pass.cpp b/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
index 0874deeec9d45..162d230b67836 100644
--- a/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
+++ b/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
@@ -136,6 +136,10 @@
#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
index dc8c9c9d1df4e..0000000000000
--- a/libcxx/test/libcxx/numerics/c.math/undef_min_max.pass.cpp
+++ /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; }
More information about the libcxx-commits
mailing list