[libcxx-commits] [libcxx] [libcxx] proper guarding for locale usage in filesystem on Windows (PR #165470)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 29 06:32:43 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h -- libcxx/include/__filesystem/path.h libcxx/include/__filesystem/u8path.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index 990833116..fc27414ea 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -376,7 +376,7 @@ struct _PathExport<char8_t> {
   }
 };
 #      endif // _LIBCPP_HAS_CHAR8_T
-#    endif // _LIBCPP_HAS_LOCALIZATION
+#    endif   // _LIBCPP_HAS_LOCALIZATION
 #  endif   /* _LIBCPP_WIN32API */
 
 class _LIBCPP_EXPORTED_FROM_ABI path {
diff --git a/libcxx/include/__filesystem/u8path.h b/libcxx/include/__filesystem/u8path.h
index bbf7723c3..e08d4d824 100644
--- a/libcxx/include/__filesystem/u8path.h
+++ b/libcxx/include/__filesystem/u8path.h
@@ -15,7 +15,7 @@
 #include <__filesystem/path.h>
 
 #if _LIBCPP_HAS_LOCALIZATION
-  #include <__locale>
+#  include <__locale>
 #endif
 #include <string>
 
@@ -32,20 +32,20 @@ template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _InputIt __l) {
   static_assert(
 #    if _LIBCPP_HAS_CHAR8_T
-        is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
+      is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
 #    endif
-            is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
-        "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"
-        " or 'char8_t'");
+          is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
+      "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"
+      " or 'char8_t'");
 #    if defined(_LIBCPP_WIN32API)
-    string __tmp(__f, __l);
-    using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
-    std::wstring __w;
-    __w.reserve(__tmp.size());
-    _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
-    return path(__w);
+  string __tmp(__f, __l);
+  using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
+  std::wstring __w;
+  __w.reserve(__tmp.size());
+  _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
+  return path(__w);
 #    else
-    return path(__f, __l);
+  return path(__f, __l);
 #    endif /* !_LIBCPP_WIN32API */
 }
 #  endif /* !_LIBCPP_WIN32API || _LIBCPP_HAS_LOCALIZATION */

``````````

</details>


https://github.com/llvm/llvm-project/pull/165470


More information about the libcxx-commits mailing list