[llvm] 5781d4b - [llvm] Updates case folding rules to Unicode 18 (#223716)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 01:41:47 PDT 2026
Author: Charlie Lin
Date: 2026-09-17T08:41:42Z
New Revision: 5781d4bde68ea4fb604b398aaf731d682412d158
URL: https://github.com/llvm/llvm-project/commit/5781d4bde68ea4fb604b398aaf731d682412d158
DIFF: https://github.com/llvm/llvm-project/commit/5781d4bde68ea4fb604b398aaf731d682412d158.diff
LOG: [llvm] Updates case folding rules to Unicode 18 (#223716)
This PR updates other Unicode tables started by
https://github.com/llvm/llvm-project/pull/198255
Co-authored-by: Claude Sonnet 4.6 <noreply at anthropic.com>
Added:
Modified:
llvm/lib/Support/UnicodeCaseFold.cpp
llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
llvm/utils/unicode-case-fold.py
Removed:
################################################################################
diff --git a/llvm/lib/Support/UnicodeCaseFold.cpp b/llvm/lib/Support/UnicodeCaseFold.cpp
index abf6df8d1e3c3..5f1b1be013bd7 100644
--- a/llvm/lib/Support/UnicodeCaseFold.cpp
+++ b/llvm/lib/Support/UnicodeCaseFold.cpp
@@ -2,11 +2,11 @@
//
// This file was generated by utils/unicode-case-fold.py from the Unicode
// case folding database at
-// http://www.unicode.org/Public/15.1.0/ucd/CaseFolding.txt
+// https://www.unicode.org/Public/18.0.0/ucd/CaseFolding.txt
//
// To regenerate this file, run:
// utils/unicode-case-fold.py \
-// "http://www.unicode.org/Public/15.1.0/ucd/CaseFolding.txt" \
+// "https://www.unicode.org/Public/18.0.0/ucd/CaseFolding.txt" \
// > lib/Support/UnicodeCaseFold.cpp
//
//===----------------------------------------------------------------------===//
@@ -411,6 +411,9 @@ int llvm::sys::unicode::foldCharSimple(int C) {
// CYRILLIC SMALL LETTER UNBLENDED UK
if (C == 0x1c88)
return 0xa64b;
+ // CYRILLIC CAPITAL LETTER TJE
+ if (C == 0x1c89)
+ return 0x1c8a;
if (C < 0x1c90)
return C;
// 43 characters
@@ -732,16 +735,30 @@ int llvm::sys::unicode::foldCharSimple(int C) {
// 2 characters
if (C <= 0xa7c9 && C % 2 == 1)
return C + 1;
- if (C < 0xa7d0)
+ // LATIN CAPITAL LETTER RAMS HORN
+ if (C == 0xa7cb)
+ return 0x0264;
+ if (C < 0xa7cc)
+ return C;
+ // 8 characters
+ if (C <= 0xa7da)
+ return C | 1;
+ // LATIN CAPITAL LETTER LAMBDA WITH STROKE
+ if (C == 0xa7dc)
+ return 0x019b;
+ if (C < 0xa7dd)
return C;
// 2 characters
- if (C <= 0xa7d6 && C % 6 == 0)
- return C + 1;
- if (C < 0xa7d8)
+ if (C <= 0xa7e2 && C % 5 == 3)
+ return C + -42342;
+ // LATIN CAPITAL LETTER REVERSED HALF H
+ if (C == 0xa7f5)
+ return 0xa7f6;
+ if (C < 0xab6c)
return C;
// 2 characters
- if (C <= 0xa7f5 && C % 29 == 19)
- return C + 1;
+ if (C <= 0xab6d)
+ return C + -33;
if (C < 0xab70)
return C;
// 80 characters
@@ -790,6 +807,11 @@ int llvm::sys::unicode::foldCharSimple(int C) {
// 51 characters
if (C <= 0x10cb2)
return C + 64;
+ if (C < 0x10d50)
+ return C;
+ // 22 characters
+ if (C <= 0x10d65)
+ return C + 32;
if (C < 0x118a0)
return C;
// 32 characters
@@ -800,6 +822,39 @@ int llvm::sys::unicode::foldCharSimple(int C) {
// 32 characters
if (C <= 0x16e5f)
return C + 32;
+ if (C < 0x16ea0)
+ return C;
+ // 25 characters
+ if (C <= 0x16eb8)
+ return C + 27;
+ if (C < 0x1df40)
+ return C;
+ // 2 characters
+ if (C <= 0x1df48 && C % 8 == 0)
+ return C + 1;
+ if (C < 0x1df4a)
+ return C;
+ // 2 characters
+ if (C <= 0x1df4d && C % 3 == 1)
+ return C + 1;
+ if (C < 0x1df51)
+ return C;
+ // 2 characters
+ if (C <= 0x1df68 && C % 23 == 0)
+ return C + 1;
+ if (C < 0x1df6a)
+ return C;
+ // 3 characters
+ if (C <= 0x1df6e)
+ return C | 1;
+ if (C < 0x1df72)
+ return C;
+ // 7 characters
+ if (C <= 0x1df7e)
+ return C | 1;
+ // LATIN SMALL LIGATURE LONG S WITH DESCENDER S
+ if (C == 0x1df95)
+ return 0x00df;
if (C < 0x1e900)
return C;
// 34 characters
diff --git a/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp b/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
index 3e5cf97a2b3a4..55bed16521f18 100644
--- a/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
+++ b/llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
@@ -8,7 +8,7 @@
//
// This file is used to generate lib/Support/UnicodeNameToCodepointGenerated.cpp
// using UnicodeData.txt and NameAliases.txt available at
-// https://unicode.org/Public/draft/ucd/
+// https://unicode.org/Public/18.0.0/ucd/
//===----------------------------------------------------------------------===//
#include "llvm/ADT/DenseMap.h"
@@ -349,9 +349,9 @@ int main(int argc, char **argv) {
"Usage: %s UnicodeData.txt NameAliases.txt output\n\n",
argv[0]);
printf("NameAliases.txt can be found at "
- "https://unicode.org/Public/draft/ucd/NameAliases.txt\n"
+ "https://unicode.org/Public/18.0.0/ucd/NameAliases.txt\n"
"UnicodeData.txt can be found at "
- "https://unicode.org/Public/draft/ucd/UnicodeData.txt\n\n");
+ "https://unicode.org/Public/18.0.0/ucd/UnicodeData.txt\n\n");
if (argc != 4)
return EXIT_FAILURE;
diff --git a/llvm/utils/unicode-case-fold.py b/llvm/utils/unicode-case-fold.py
index 4afb41d4060f0..61d113b26835e 100755
--- a/llvm/utils/unicode-case-fold.py
+++ b/llvm/utils/unicode-case-fold.py
@@ -36,9 +36,15 @@ def mappings(f):
m = expr.match(line)
if not m:
continue
- from_char = int(m.group(1), 16)
+ group_1 = m.group(1)
+ if "b" in group_1:
+ group_1 = group_1[2:]
+ from_char = int(group_1, 16)
to_char = int(m.group(2), 16)
- from_name = m.group(3)
+ group_3 = m.group(3)
+ if "\\n" in group_3:
+ group_3 = group_3[:-3]
+ from_name = group_3
if from_char <= previous_from:
raise Exception("Duplicate or unsorted characters in input")
@@ -66,7 +72,6 @@ def stride(block):
# shift and the stride between adjecant mappings (if any) is constant.
def dump_block(b):
global body
-
if len(b) == 1:
# Special case for handling blocks of length 1. We don't even need to
# emit the "if (C < X) return C" check below as all characters in this
@@ -101,28 +106,28 @@ def dump_block(b):
current_block = []
-f = urlopen(sys.argv[1])
-for m in mappings(f):
- if len(current_block) == 0:
- current_block.append(m)
- continue
-
- if shift(current_block[0]) != shift(m):
- # Incompatible shift, start a new block.
+with urlopen(sys.argv[1]) as f:
+ g = [str(x) for x in f.readlines()]
+ for m in mappings(g):
+ if len(current_block) == 0:
+ current_block.append(m)
+ continue
+
+ if shift(current_block[0]) != shift(m):
+ # Incompatible shift, start a new block.
+ dump_block(current_block)
+ current_block = [m]
+ continue
+
+ if len(current_block) == 1 or stride(current_block) == stride2(
+ current_block[-1], m
+ ):
+ current_block.append(m)
+ continue
+
+ # Incompatible stride, start a new block.
dump_block(current_block)
current_block = [m]
- continue
-
- if len(current_block) == 1 or stride(current_block) == stride2(
- current_block[-1], m
- ):
- current_block.append(m)
- continue
-
- # Incompatible stride, start a new block.
- dump_block(current_block)
- current_block = [m]
-f.close()
dump_block(current_block)
More information about the llvm-commits
mailing list