[libcxx-commits] [libcxx] [libcxx][NFC] Move guards outside namespace (PR #208089)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 8 06:59:51 PDT 2026
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/208089
>From 1ebdd91a309fbdc8d7fb0d17a13b731ce5c6022d Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Tue, 7 Jul 2026 20:12:00 +0000
Subject: [PATCH] [libcxx][NFC] Move guards outside namespace
Libc++ has a warning that triggers on empty namespaces. When
_LIBCPP_BUILDING_LIBRARY is not defined, the __locale namespace was
empty. This PR moves the #ifdef to surround the namespace and fix the
warning.
---
libcxx/include/__locale_dir/support/no_locale/characters.h | 5 +++--
libcxx/include/__locale_dir/support/no_locale/conversions.h | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/libcxx/include/__locale_dir/support/no_locale/characters.h b/libcxx/include/__locale_dir/support/no_locale/characters.h
index 52e842d8f494f..ffe6697916914 100644
--- a/libcxx/include/__locale_dir/support/no_locale/characters.h
+++ b/libcxx/include/__locale_dir/support/no_locale/characters.h
@@ -24,13 +24,14 @@
# pragma GCC system_header
#endif
+#if defined(_LIBCPP_BUILDING_LIBRARY)
+
_LIBCPP_BEGIN_NAMESPACE_STD
namespace __locale {
//
// Character manipulation functions
//
-#if defined(_LIBCPP_BUILDING_LIBRARY)
inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t) { return std::toupper(__c); }
inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t) { return std::tolower(__c); }
@@ -85,9 +86,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__strftime__, 3, 0) size_t
__strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t) {
return std::strftime(__s, __max, __format, __tm);
}
-#endif // _LIBCPP_BUILDING_LIBRARY
} // namespace __locale
_LIBCPP_END_NAMESPACE_STD
+#endif // _LIBCPP_BUILDING_LIBRARY
#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CHARACTERS_H
diff --git a/libcxx/include/__locale_dir/support/no_locale/conversions.h b/libcxx/include/__locale_dir/support/no_locale/conversions.h
index 64a50df4a50b9..bb501515c4d4e 100644
--- a/libcxx/include/__locale_dir/support/no_locale/conversions.h
+++ b/libcxx/include/__locale_dir/support/no_locale/conversions.h
@@ -21,10 +21,11 @@
# pragma GCC system_header
#endif
+#if defined(_LIBCPP_BUILDING_LIBRARY)
+
_LIBCPP_BEGIN_NAMESPACE_STD
namespace __locale {
-#if defined(_LIBCPP_BUILDING_LIBRARY)
inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t) { return MB_CUR_MAX; }
# if _LIBCPP_HAS_WIDE_CHARACTERS
@@ -64,9 +65,9 @@ __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps,
return std::mbsrtowcs(__dest, __src, __len, __ps);
}
# endif // _LIBCPP_HAS_WIDE_CHARACTERS
-#endif // _LIBCPP_BUILDING_LIBRARY
} // namespace __locale
_LIBCPP_END_NAMESPACE_STD
+#endif // _LIBCPP_BUILDING_LIBRARY
#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CONVERSIONS_H
More information about the libcxx-commits
mailing list