[libcxx-commits] [PATCH] D140117: [libc++][format] Renames __null_sentinel.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 15 10:06:14 PST 2022


Mordante created this revision.
Mordante added a reviewer: emaste.
Herald added subscribers: krytarowski, arichardson.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

While the FreeBSD CI was enabled in D128084 <https://reviews.llvm.org/D128084> it was discovered libc++
uses the name of a system macro on FreeBSD. This renames the macro to
fix the issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140117

Files:
  libcxx/include/__format/formatter_output.h
  libcxx/test/libcxx/nasty_macros.compile.pass.cpp


Index: libcxx/test/libcxx/nasty_macros.compile.pass.cpp
===================================================================
--- libcxx/test/libcxx/nasty_macros.compile.pass.cpp
+++ libcxx/test/libcxx/nasty_macros.compile.pass.cpp
@@ -59,6 +59,11 @@
 # undef _M
 #endif
 
+// Test that libc++ doesn't use names that collide with FreeBSD system macros.
+#ifdef __FreeBSD__
+#  define __null_sentinel NASTY_MACRO
+#endif
+
 // tchar.h defines these macros on Windows
 #ifndef _WIN32
 # define _UI   NASTY_MACRO
Index: libcxx/include/__format/formatter_output.h
===================================================================
--- libcxx/include/__format/formatter_output.h
+++ libcxx/include/__format/formatter_output.h
@@ -373,10 +373,10 @@
 
 #  if _LIBCPP_STD_VER > 20
 
-struct __null_sentinel {};
+struct __nul_terminator {};
 
 template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI bool operator==(const _CharT* __cstr, __null_sentinel) {
+_LIBCPP_HIDE_FROM_ABI bool operator==(const _CharT* __cstr, __nul_terminator) {
   return *__cstr == _CharT('\0');
 }
 
@@ -384,7 +384,7 @@
 _LIBCPP_HIDE_FROM_ABI void
 __write_escaped_code_unit(basic_string<_CharT>& __str, char32_t __value, const _CharT* __prefix) {
   back_insert_iterator __out_it{__str};
-  std::ranges::copy(__prefix, __null_sentinel{}, __out_it);
+  std::ranges::copy(__prefix, __nul_terminator{}, __out_it);
 
   char __buffer[8];
   to_chars_result __r = std::to_chars(std::begin(__buffer), std::end(__buffer), __value, 16);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140117.483223.patch
Type: text/x-patch
Size: 1489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221215/a0013e69/attachment.bin>


More information about the libcxx-commits mailing list