[libc-commits] [libc] [libc][wctype] Create generation script for classification lookup tables (PR #172042)
via libc-commits
libc-commits at lists.llvm.org
Fri Dec 12 08:30:10 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r origin/main...HEAD libc/utils/wctype_utils/classification/__init__.py libc/utils/wctype_utils/classification/gen_classification_data.py libc/utils/wctype_utils/gen.py
``````````
: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 darker here.
</summary>
``````````diff
--- classification/gen_classification_data.py 2025-12-12 16:17:55.000000 +0000
+++ classification/gen_classification_data.py 2025-12-12 16:29:42.806169 +0000
@@ -221,11 +221,12 @@
# Generate the main header with lookup function
with open(
f"{llvm_project_root_path}/libc/src/__support/wctype/wctype_classification_utils.h",
"w",
) as f:
- f.write(f"""//===-- Utils for wctype classification functions ---------------*- C++ -*-===//
+ f.write(
+ f"""//===-- Utils for wctype classification functions ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
@@ -261,31 +262,35 @@
inline constexpr uint16_t LEVEL1_SIZE = {len(level1)};
inline constexpr uint16_t LEVEL2_SIZE = {len(level2)};
// Level 1 table: indexed by (codepoint >> 8), stores level2 block offsets
inline constexpr uint16_t level1[LEVEL1_SIZE] = {{
-""")
+"""
+ )
for i in range(0, len(level1), 11):
f.write(" ")
for j in range(i, min(i + 11, len(level1))):
f.write(f"{level1[j]:7d}")
if j + 1 < len(level1):
f.write(",")
f.write("\n")
- f.write(f"""}};
+ f.write(
+ f"""}};
// Level 2 table: blocks of 256 property flags
inline constexpr uint8_t level2[LEVEL2_SIZE] = {{
-""")
+"""
+ )
for i in range(0, len(level2), 11):
f.write(" ")
for j in range(i, min(i + 11, len(level2))):
f.write(f"0x{level2[j]:02x}")
if j + 1 < len(level2):
f.write(", ")
f.write("\n")
- f.write(f"""}};
+ f.write(
+ f"""}};
// Returns the Unicode property flag for a given wide character.
inline constexpr uint8_t lookup_properties(const wchar_t wc) {{
// Out of Unicode range
if (static_cast<uint32_t>(wc) > 0x10FFFF) {{
@@ -304,6 +309,7 @@
}} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC___SUPPORT_WCTYPE_WCTYPE_CLASSIFICATION_UTILS_H
-""")
+"""
+ )
``````````
</details>
https://github.com/llvm/llvm-project/pull/172042
More information about the libc-commits
mailing list