[libcxx-commits] [PATCH] D120478: [libcxx] [test] Make filesystem tests not rely on libc++ internals

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 24 05:46:25 PST 2022


mstorsjo created this revision.
mstorsjo added a reviewer: ldionne.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

As part of https://reviews.llvm.org/D119036
(506cf6dc048835c598b654e43ed8f723a42e39ba <https://reviews.llvm.org/rG506cf6dc048835c598b654e43ed8f723a42e39ba>), `-DNOMINMAX` was
dropped from the Windows CI configurations, replaced with a
block with `_LIBCPP_PUSH_MACROS`, `#include <__undef_macros>`
and `_LIBCPP_POP_MACROS` (and
`ADDITIONAL_COMPILE_FLAGS: -DNOMINMAX` left in two tests).

However, this workaround breaks the running the libc++ tests
against a different C++ standard library than libc++, as those
macros and that header are libc++ internals.

This works around it by simply doing `#undef min` and `#undef max`
(when on Windows), making the tests work on other C++ standard
libraries again.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120478

Files:
  libcxx/test/support/filesystem_test_helper.h


Index: libcxx/test/support/filesystem_test_helper.h
===================================================================
--- libcxx/test/support/filesystem_test_helper.h
+++ libcxx/test/support/filesystem_test_helper.h
@@ -31,8 +31,12 @@
 # include <sys/un.h>
 #endif
 
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
+#ifdef _WIN32
+// If built without -DNOMINMAX, Windows system headers can pollute the
+// namespace with min/max defines that break standard C++.
+#undef min
+#undef max
+#endif
 
 namespace utils {
 #ifdef _WIN32
@@ -736,6 +740,4 @@
   return fs::path();
 }
 
-_LIBCPP_POP_MACROS
-
 #endif /* FILESYSTEM_TEST_HELPER_H */


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120478.411102.patch
Type: text/x-patch
Size: 640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220224/b21747bf/attachment.bin>


More information about the libcxx-commits mailing list