[libcxx-commits] [libcxx] b3e6e6d - [libcxx][NFC] Move guards outside namespace (#208089)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 8 07:06:23 PDT 2026


Author: Michael Jones
Date: 2026-07-08T14:06:18Z
New Revision: b3e6e6dabdc02153552a64fc74ff5c7532447eed

URL: https://github.com/llvm/llvm-project/commit/b3e6e6dabdc02153552a64fc74ff5c7532447eed
DIFF: https://github.com/llvm/llvm-project/commit/b3e6e6dabdc02153552a64fc74ff5c7532447eed.diff

LOG: [libcxx][NFC] Move guards outside namespace (#208089)

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.

Added: 
    

Modified: 
    libcxx/include/__locale_dir/support/no_locale/characters.h
    libcxx/include/__locale_dir/support/no_locale/conversions.h

Removed: 
    


################################################################################
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