[Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows

Summary:
This patch improves how libc++ handles min/max macros within the headers. Previously libc++ would undef them and emit a warning.
This patch changes libc++ to use `#pragma push_macro`  to save the macro before undefining it, and `#pragma pop_macro` to restore the macros and the end of the header.

Reviewers: mclow.lists, bcraig, compnerd, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits, krytarowski

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

llvm-svn: 304357
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: a016efb1dcda61e606e527b73791fbacf1bc9c86
diff --git a/include/limits b/include/limits
index 4755c57..675cfc4 100644
--- a/include/limits
+++ b/include/limits
@@ -102,15 +102,8 @@
 
 */
 #include <__config>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
 #include <type_traits>
 
-#include <__undef_min_max>
-
 #if defined(_LIBCPP_COMPILER_MSVC)
 #include "support/win32/limits_msvc_win32.h"
 #endif // _LIBCPP_MSVCRT
@@ -119,6 +112,14 @@
 #include "support/ibm/limits.h"
 #endif // __IBMCPP__
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 enum float_round_style
@@ -811,4 +812,6 @@
 
 _LIBCPP_END_NAMESPACE_STD
 
+_LIBCPP_POP_MACROS
+
 #endif  // _LIBCPP_LIMITS