← Back to Pull requests

Add a generator for Unicode properties. #229072

Merged
cor3ntin merged 12 files (2143 lines) on Oct 08, 2026 14:19 UTC
View on GitHub
cor3ntin cor3ntin commented on Oct 05, 2026 12:42 UTC
Author

Over the past few years, I have been maintaining the unicode tables mostly by hand with the help of an unwieldy python script that only existed on my machine, and sed.

So I figured throwing an AI at the issue would be an improvement over the status quo.
It took a lot of iteration and refinement but this is very much AI-produced code.

This introduce a C++ program that parses the UCD data (in the xml format which i find easier to read) and generate the tables.

I added some documentation.

As it stands, we have 3 different tools to update Unicode data, and some that still needs manual work.
I plan to consolidate that a bit in future PRs, whenever I have the time.

I'll also need to update other generated tables subsequently as the data changed between Unicode 18 beta and Unicode 18.

Diff: 2143 lines (+1278 / -865) across 12 files Reviewer: AaronBallman Review duration: 4417m
All Vouch review confidence checks passed
Residual risk 0.08 = Change Risk (0.59) × (1 − Review Confidence (0.86)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 2143 lines diff across 12 files
0.59
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.81 · 5 substantive comment(s)
0.81
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
86%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.400
Real PR Conversation Timeline
14 items
llvmorg-github-actions[bot] llvmorg-github-actions[bot] commented on Oct 05, 2026 12:43 UTC
Bot

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Corentin Jabot (cor3ntin)

<details>
<summary>Changes</summary>

Over the past few years, I have been maintaining the unicode tables mostly by hand with the help of an wnweidly python script rthat only existed on my machine, and sed.

So I figured throwing an AI at the issue would be an improvement over the status quo.
It took a lot of iteration and refinement but this is very much AI-produced code.

This introduce a C++ program that parses the UCD data (in the xml format which i find easier to read) and generate the tables.

I added some documentation.

As it stands, we have 3 different tools to update Unicode data, and some that still needs manual work.
I plan to consolidate that a bit in future PRs, whenever I have the time.

I'll also need to update other generated tables subsequently as the data changed between Unicode 18 beta and Unicode 18.

---

Patch is 126.68 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/229072.diff

11 Files Affected:

  • (added) clang/docs/UnicodeSupport.md (+83)

  • (modified) clang/docs/index.md (+2)

  • (modified) clang/lib/Lex/CMakeLists.txt (+1)

  • (modified) clang/lib/Lex/Lexer.cpp (+12-9)

  • (modified) clang/lib/Lex/UnicodeCharSets.h (+8-410)

  • (added) clang/lib/Lex/UnicodeCharSetsGenerated.cpp (+423)

  • (modified) llvm/lib/Support/CMakeLists.txt (+1)

  • (modified) llvm/lib/Support/Unicode.cpp (+11-445)

  • (added) llvm/lib/Support/UnicodeCharSetsGenerated.cpp (+462)

  • (modified) llvm/utils/UnicodeData/CMakeLists.txt (+16)

  • (added) llvm/utils/UnicodeData/UnicodeCharSetsGenerator.cpp (+257)
  • ``````

    diff --git a/clang/docs/UnicodeSupport.md b/clang/docs/UnicodeSupport.md
    new file mode 100644
    index 000000000000000..7aae8ce73cb6bc6
    --- /dev/null
    +++ b/clang/docs/UnicodeSupport.md
    @@ -0,0 +1,83 @@
    +# Unicode Support
    +
    +Clang uses a subset of the [Unicode Character Database](https://www.unicode.org/ucd/)
    +(UCD) for identifiers, `\N{...}` named characters, diagnostic column width,
    +and simple case folding. The corresponding tables are generated from the UCD
    +into Clang and LLVM Support.
    +
    +## Updating the Unicode Data
    +
    +Replace `N.M.0` with the Unicode version being imported. Build the generators
    +from an LLVM build directory that has utilities enabled (`LLVM_BUILD_UTILS`,
    +the default) and libxml2 (`LLVM_ENABLE_LIBXML2`, also the default):
    +
    +
    bash
    +ninja -C <build> UnicodeCharSetsGenerator UnicodeNameMappingGenerator
    +
    +
    +Then run them from the `llvm-project` root as shown below.
    +
    +### Character properties
    +
    +`UnicodeCharSetsGenerator` writes the identifier character sets used by the
    +lexer (`XID_Start`, `XID_Continue`, and the mathematical compatibility notation
    +profile) and the printable / formatting / combining / East-Asian-width sets
    +used by LLVM Support.
    +
    +Download the [flat XML UCD](https://www.unicode.org/Public/UCD/latest/ucdxml/)
    +(`ucd.nounihan.flat.zip` is enough):
    +
    +
    text
    +https://www.unicode.org/Public/N.M.0/ucdxml/ucd.nounihan.flat.zip
    +
    +
    +
    bash
    +<build>/bin/UnicodeCharSetsGenerator ucd.nounihan.flat.xml \
    + clang/lib/Lex/UnicodeCharSetsGenerated.cpp \
    + llvm/lib/Support/UnicodeCharSetsGenerated.cpp
    +clang-format -i clang/lib/Lex/UnicodeCharSetsGenerated.cpp \
    + llvm/lib/Support/UnicodeCharSetsGenerated.cpp
    +
    +
    +The C99 and C11 identifier tables and the whitespace table in
    +`clang/lib/Lex/UnicodeCharSets.h` are maintained by hand.
    +
    +### Character names
    +
    +`UnicodeNameMappingGenerator` writes the name-to-codepoint trie used by
    +`\N{...}` and `llvm::sys::unicode::nameToCodepointStrict` /
    +`nameToCodepointLooseMatching`.
    +
    +From the [UCD zip](https://www.unicode.org/Public/UCD/latest/ucd/UCD.zip), take
    +`UnicodeData.txt` and `NameAliases.txt`:
    +
    +
    text
    +https://www.unicode.org/Public/N.M.0/ucd/UnicodeData.txt
    +https://www.unicode.org/Public/N.M.0/ucd/NameAliases.txt
    +
    +
    +
    bash
    +<build>/bin/UnicodeNameMappingGenerator UnicodeData.txt NameAliases.txt \
    + llvm/lib/Support/UnicodeNameToCodepointGenerated.cpp
    +clang-format -i llvm/lib/Support/UnicodeNameToCodepointGenerated.cpp
    +
    +
    +Algorithmically derived names (`CJK UNIFIED IDEOGRAPH-*`, and so on) are not
    +in those files. Update `GeneratedNamesDataTable` in
    +`llvm/lib/Support/UnicodeNameToCodepoint.cpp` from
    +`extracted/DerivedName.txt` in the same UCD zip.
    +
    +### Case folding
    +
    +`llvm/utils/unicode-case-fold.py` fetches `CaseFolding.txt` and writes
    +`llvm/lib/Support/UnicodeCaseFold.cpp`:
    +
    +
    bash
    +llvm/utils/unicode-case-fold.py \
    + https://www.unicode.org/Public/N.M.0/ucd/CaseFolding.txt \
    + > llvm/lib/Support/UnicodeCaseFold.cpp
    +
    +
    +After regenerating the tables, update
    +`llvm/unittests/Support/UnicodeTest.cpp` and `clang/test/Lexer/unicode.c` for
    +new characters and changed name ranges.
    diff --git a/clang/docs/index.md b/clang/docs/index.md
    index a05210b8e73a0f0..9c353317fd260d1 100644
    --- a/clang/docs/index.md
    +++ b/clang/docs/index.md
    @@ -93,6 +93,7 @@ ClangSYCLLinker
     Maintainers
     InternalsManual
     DriverInternals
    +UnicodeSupport
     Multilib
     OffloadingDesign
     PCHInternals
    @@ -200,6 +201,7 @@ LLVMExceptionHandlingCodeGen
     * {doc}`Maintainers`
     * {doc}`InternalsManual`
     * {doc}`DriverInternals`
    +* {doc}`UnicodeSupport`
     * {doc}`Multilib`
     * {doc}`OffloadingDesign`
     * {doc}`PCHInternals`
    diff --git a/clang/lib/Lex/CMakeLists.txt b/clang/lib/Lex/CMakeLists.txt
    index 7b0be7249cd99ad..f333605668abce3 100644
    --- a/clang/lib/Lex/CMakeLists.txt
    +++ b/clang/lib/Lex/CMakeLists.txt
    @@ -32,6 +32,7 @@ add_clang_library(clangLex
       TextEncoding.cpp
       TokenConcatenation.cpp
       TokenLexer.cpp
    +  UnicodeCharSetsGenerated.cpp
     
       LINK_LIBS
       clangBasic
    diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
    index 4762b38e67c00af..367c7e2753d0774 100644
    --- a/clang/lib/Lex/Lexer.cpp
    +++ b/clang/lib/Lex/Lexer.cpp
    @@ -1614,9 +1614,9 @@ static bool isUnicodeWhitespace(uint32_t Codepoint) {
     static bool isMathematicalExtensionID(uint32_t C, const LangOptions &LangOpts,
                                           bool IsStart, bool &IsExtension) {
       static const llvm::sys::UnicodeCharSet MathStartChars(
    -      MathematicalNotationProfileIDStartRanges);
    +      GeneratedMathematicalNotationProfileIDStartRanges);
       static const llvm::sys::UnicodeCharSet MathContinueChars(
    -      MathematicalNotationProfileIDContinueRanges);
    +      GeneratedMathematicalNotationProfileIDContinueRanges);
       if (MathStartChars.contains(C) ||
           (!IsStart && MathContinueChars.contains(C))) {
         IsExtension = true;
    @@ -1633,11 +1633,13 @@ static bool isAllowedIDChar(uint32_t C, const LangOptions &LangOpts,
         return true;
       } else if (LangOpts.CPlusPlus || LangOpts.C23) {
         // A non-leading codepoint must have the XID_Continue property.
    -    // XIDContinueRanges doesn't contains characters also in XIDStartRanges,
    -    // so we need to check both tables.
    +    // GeneratedXIDContinueRanges doesn't contain characters also in
    +    // GeneratedXIDStartRanges, so we need to check both tables.
         // '_' doesn't have the XID_Continue property but is allowed in C and C++.
    -    static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
    -    static const llvm::sys::UnicodeCharSet XIDContinueChars(XIDContinueRanges);
    +    static const llvm::sys::UnicodeCharSet XIDStartChars(
    +        GeneratedXIDStartRanges);
    +    static const llvm::sys::UnicodeCharSet XIDContinueChars(
    +        GeneratedXIDContinueRanges);
         if (C == '_' || XIDStartChars.contains(C) || XIDContinueChars.contains(C))
           return true;
         return isMathematicalExtensionID(C, LangOpts, /*IsStart=*/false,
    @@ -1661,7 +1663,8 @@ static bool isAllowedInitiallyIDChar(uint32_t C, const LangOptions &LangOpts,
         return false;
       }
       if (LangOpts.CPlusPlus || LangOpts.C23) {
    -    static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
    +    static const llvm::sys::UnicodeCharSet XIDStartChars(
    +        GeneratedXIDStartRanges);
         if (XIDStartChars.contains(C))
           return true;
         return isMathematicalExtensionID(C, LangOpts, /*IsStart=*/true,
    @@ -1685,9 +1688,9 @@ diagnoseMathematicalNotationInIdentifier(DiagnosticsEngine &Diags,
                                              uint32_t C, CharSourceRange Range) {
     
       static const llvm::sys::UnicodeCharSet MathStartChars(
    -      MathematicalNotationProfileIDStartRanges);
    +      GeneratedMathematicalNotationProfileIDStartRanges);
       static const llvm::sys::UnicodeCharSet MathContinueChars(
    -      MathematicalNotationProfileIDContinueRanges);
    +      GeneratedMathematicalNotationProfileIDContinueRanges);
     
       (void)MathStartChars;
       (void)MathContinueChars;
    diff --git a/clang/lib/Lex/UnicodeCharSets.h b/clang/lib/Lex/UnicodeCharSets.h
    index eaee53172050fb0..186c983e2f6a562 100644
    --- a/clang/lib/Lex/UnicodeCharSets.h
    +++ b/clang/lib/Lex/UnicodeCharSets.h
    @@ -10,416 +10,14 @@
     
     #include "llvm/Support/UnicodeCharRanges.h"
     
    -// Unicode 18.0 XID_Start
    -static const llvm::sys::UnicodeCharRange XIDStartRanges[] = {
    -    {0x0041, 0x005A},   {0x0061, 0x007A},   {0x00AA, 0x00AA},
    -    {0x00B5, 0x00B5},   {0x00BA, 0x00BA},   {0x00C0, 0x00D6},
    -    {0x00D8, 0x00F6},   {0x00F8, 0x02C1},   {0x02C6, 0x02D1},
    -    {0x02E0, 0x02E4},   {0x02EC, 0x02EC},   {0x02EE, 0x02EE},
    -    {0x0370, 0x0374},   {0x0376, 0x0377},   {0x037B, 0x037D},
    -    {0x037F, 0x037F},   {0x0386, 0x0386},   {0x0388, 0x038A},
    -    {0x038C, 0x038C},   {0x038E, 0x03A1},   {0x03A3, 0x03F5},
    -    {0x03F7, 0x0481},   {0x048A, 0x052F},   {0x0531, 0x0556},
    -    {0x0558, 0x0559},   {0x0560, 0x0588},   {0x058B, 0x058C},
    -    {0x05D0, 0x05EA},   {0x05EF, 0x05F2},   {0x0620, 0x064A},
    -    {0x066E, 0x066F},   {0x0671, 0x06D3},   {0x06D5, 0x06D5},
    -    {0x06E5, 0x06E6},   {0x06EE, 0x06EF},   {0x06FA, 0x06FC},
    -    {0x06FF, 0x06FF},   {0x0710, 0x0710},   {0x0712, 0x072F},
    -    {0x074D, 0x07A5},   {0x07B1, 0x07B1},   {0x07CA, 0x07EA},
    -    {0x07F4, 0x07F5},   {0x07FA, 0x07FA},   {0x0800, 0x0815},
    -    {0x081A, 0x081A},   {0x0824, 0x0824},   {0x0828, 0x0828},
    -    {0x0840, 0x0858},   {0x0860, 0x086A},   {0x0870, 0x0887},
    -    {0x0889, 0x088F},   {0x08A0, 0x08C9},   {0x0904, 0x0939},
    -    {0x093D, 0x093D},   {0x0950, 0x0950},   {0x0958, 0x0961},
    -    {0x0971, 0x0980},   {0x0985, 0x098C},   {0x098F, 0x0990},
    -    {0x0993, 0x09A8},   {0x09AA, 0x09B0},   {0x09B2, 0x09B2},
    -    {0x09B6, 0x09B9},   {0x09BD, 0x09BD},   {0x09CE, 0x09CE},
    -    {0x09DC, 0x09DD},   {0x09DF, 0x09E1},   {0x09F0, 0x09F1},
    -    {0x09FC, 0x09FC},   {0x0A05, 0x0A0A},   {0x0A0F, 0x0A10},
    -    {0x0A13, 0x0A28},   {0x0A2A, 0x0A30},   {0x0A32, 0x0A33},
    -    {0x0A35, 0x0A36},   {0x0A38, 0x0A39},   {0x0A59, 0x0A5C},
    -    {0x0A5E, 0x0A5E},   {0x0A72, 0x0A74},   {0x0A85, 0x0A8D},
    -    {0x0A8F, 0x0A91},   {0x0A93, 0x0AA8},   {0x0AAA, 0x0AB0},
    -    {0x0AB2, 0x0AB3},   {0x0AB5, 0x0AB9},   {0x0ABD, 0x0ABD},
    -    {0x0AD0, 0x0AD0},   {0x0AE0, 0x0AE1},   {0x0AF9, 0x0AF9},
    -    {0x0B05, 0x0B0C},   {0x0B0F, 0x0B10},   {0x0B13, 0x0B28},
    -    {0x0B2A, 0x0B30},   {0x0B32, 0x0B33},   {0x0B35, 0x0B39},
    -    {0x0B3D, 0x0B3D},   {0x0B5C, 0x0B5D},   {0x0B5F, 0x0B61},
    -    {0x0B71, 0x0B71},   {0x0B83, 0x0B83},   {0x0B85, 0x0B8A},
    -    {0x0B8E, 0x0B90},   {0x0B92, 0x0B95},   {0x0B99, 0x0B9A},
    -    {0x0B9C, 0x0B9C},   {0x0B9E, 0x0B9F},   {0x0BA3, 0x0BA4},
    -    {0x0BA8, 0x0BAA},   {0x0BAE, 0x0BB9},   {0x0BD0, 0x0BD0},
    -    {0x0C05, 0x0C0C},   {0x0C0E, 0x0C10},   {0x0C12, 0x0C28},
    -    {0x0C2A, 0x0C39},   {0x0C3D, 0x0C3D},   {0x0C58, 0x0C5A},
    -    {0x0C5C, 0x0C5D},   {0x0C60, 0x0C61},   {0x0C80, 0x0C80},
    -    {0x0C85, 0x0C8C},   {0x0C8E, 0x0C90},   {0x0C92, 0x0CA8},
    -    {0x0CAA, 0x0CB3},   {0x0CB5, 0x0CB9},   {0x0CBD, 0x0CBD},
    -    {0x0CDC, 0x0CDE},   {0x0CE0, 0x0CE1},   {0x0CF1, 0x0CF2},
    -    {0x0D04, 0x0D0C},   {0x0D0E, 0x0D10},   {0x0D12, 0x0D3A},
    -    {0x0D3D, 0x0D3D},   {0x0D4E, 0x0D4E},   {0x0D54, 0x0D56},
    -    {0x0D5F, 0x0D61},   {0x0D7A, 0x0D7F},   {0x0D85, 0x0D96},
    -    {0x0D9A, 0x0DB1},   {0x0DB3, 0x0DBB},   {0x0DBD, 0x0DBD},
    -    {0x0DC0, 0x0DC6},   {0x0E01, 0x0E30},   {0x0E32, 0x0E32},
    -    {0x0E40, 0x0E46},   {0x0E81, 0x0E82},   {0x0E84, 0x0E84},
    -    {0x0E86, 0x0E8A},   {0x0E8C, 0x0EA3},   {0x0EA5, 0x0EA5},
    -    {0x0EA7, 0x0EB0},   {0x0EB2, 0x0EB2},   {0x0EBD, 0x0EBD},
    -    {0x0EC0, 0x0EC4},   {0x0EC6, 0x0EC6},   {0x0EDC, 0x0EDF},
    -    {0x0F00, 0x0F00},   {0x0F40, 0x0F47},   {0x0F49, 0x0F6C},
    -    {0x0F88, 0x0F8C},   {0x1000, 0x102A},   {0x103F, 0x103F},
    -    {0x1050, 0x1055},   {0x105A, 0x105D},   {0x1061, 0x1061},
    -    {0x1065, 0x1066},   {0x106E, 0x1070},   {0x1075, 0x1081},
    -    {0x108E, 0x108E},   {0x10A0, 0x10C5},   {0x10C7, 0x10C7},
    -    {0x10CD, 0x10CD},   {0x10D0, 0x10FA},   {0x10FC, 0x1248},
    -    {0x124A, 0x124D},   {0x1250, 0x1256},   {0x1258, 0x1258},
    -    {0x125A, 0x125D},   {0x1260, 0x1288},   {0x128A, 0x128D},
    -    {0x1290, 0x12B0},   {0x12B2, 0x12B5},   {0x12B8, 0x12BE},
    -    {0x12C0, 0x12C0},   {0x12C2, 0x12C5},   {0x12C8, 0x12D6},
    -    {0x12D8, 0x1310},   {0x1312, 0x1315},   {0x1318, 0x135A},
    -    {0x1380, 0x138F},   {0x13A0, 0x13F5},   {0x13F8, 0x13FD},
    -    {0x1401, 0x166C},   {0x166F, 0x167F},   {0x1681, 0x169A},
    -    {0x16A0, 0x16EA},   {0x16EE, 0x16F8},   {0x1700, 0x1711},
    -    {0x171F, 0x1731},   {0x1740, 0x1751},   {0x1760, 0x176C},
    -    {0x176E, 0x1770},   {0x1780, 0x17B3},   {0x17D7, 0x17D7},
    -    {0x17DC, 0x17DC},   {0x1820, 0x1878},   {0x1880, 0x18A8},
    -    {0x18AA, 0x18AA},   {0x18B0, 0x18F5},   {0x1900, 0x191E},
    -    {0x1950, 0x196D},   {0x1970, 0x1974},   {0x1980, 0x19AB},
    -    {0x19B0, 0x19C9},   {0x1A00, 0x1A16},   {0x1A20, 0x1A54},
    -    {0x1AA7, 0x1AA7},   {0x1B05, 0x1B33},   {0x1B45, 0x1B4C},
    -    {0x1B83, 0x1BA0},   {0x1BAE, 0x1BAF},   {0x1BBA, 0x1BE5},
    -    {0x1C00, 0x1C23},   {0x1C4D, 0x1C4F},   {0x1C5A, 0x1C7D},
    -    {0x1C80, 0x1C8A},   {0x1C90, 0x1CBA},   {0x1CBD, 0x1CBF},
    -    {0x1CE9, 0x1CEC},   {0x1CEE, 0x1CF3},   {0x1CF5, 0x1CF6},
    -    {0x1CFA, 0x1CFA},   {0x1D00, 0x1DBF},   {0x1E00, 0x1F15},
    -    {0x1F18, 0x1F1D},   {0x1F20, 0x1F45},   {0x1F48, 0x1F4D},
    -    {0x1F50, 0x1F57},   {0x1F59, 0x1F59},   {0x1F5B, 0x1F5B},
    -    {0x1F5D, 0x1F5D},   {0x1F5F, 0x1F7D},   {0x1F80, 0x1FB4},
    -    {0x1FB6, 0x1FBC},   {0x1FBE, 0x1FBE},   {0x1FC2, 0x1FC4},
    -    {0x1FC6, 0x1FCC},   {0x1FD0, 0x1FD3},   {0x1FD6, 0x1FDB},
    -    {0x1FE0, 0x1FEC},   {0x1FF2, 0x1FF4},   {0x1FF6, 0x1FFC},
    -    {0x2071, 0x2071},   {0x207F, 0x207F},   {0x208F, 0x209F},
    -    {0x2102, 0x2102},   {0x2107, 0x2107},   {0x210A, 0x2113},
    -    {0x2115, 0x2115},   {0x2118, 0x211D},   {0x2124, 0x2124},
    -    {0x2126, 0x2126},   {0x2128, 0x2128},   {0x212A, 0x2139},
    -    {0x213C, 0x213F},   {0x2145, 0x2149},   {0x214E, 0x214E},
    -    {0x2160, 0x2188},   {0x2C00, 0x2CE4},   {0x2CEB, 0x2CEE},
    -    {0x2CF2, 0x2CF3},   {0x2D00, 0x2D25},   {0x2D27, 0x2D27},
    -    {0x2D2D, 0x2D2D},   {0x2D30, 0x2D67},   {0x2D6F, 0x2D6F},
    -    {0x2D80, 0x2D96},   {0x2DA0, 0x2DA6},   {0x2DA8, 0x2DAE},
    -    {0x2DB0, 0x2DB6},   {0x2DB8, 0x2DBE},   {0x2DC0, 0x2DC6},
    -    {0x2DC8, 0x2DCE},   {0x2DD0, 0x2DD6},   {0x2DD8, 0x2DDE},
    -    {0x3005, 0x3007},   {0x3021, 0x3029},   {0x3031, 0x3035},
    -    {0x3038, 0x303C},   {0x3041, 0x3096},   {0x309D, 0x309F},
    -    {0x30A1, 0x30FA},   {0x30FC, 0x30FF},   {0x3105, 0x312F},
    -    {0x3131, 0x318E},   {0x31A0, 0x31BF},   {0x31F0, 0x31FF},
    -    {0x3400, 0x4DBF},   {0x4E00, 0xA48C},   {0xA4D0, 0xA4FD},
    -    {0xA500, 0xA60C},   {0xA610, 0xA61F},   {0xA62A, 0xA62B},
    -    {0xA640, 0xA66E},   {0xA67F, 0xA69D},   {0xA6A0, 0xA6EF},
    -    {0xA717, 0xA71F},   {0xA722, 0xA788},   {0xA78B, 0xA7DD},
    -    {0xA7E2, 0xA7E2},   {0xA7F1, 0xA801},   {0xA803, 0xA805},
    -    {0xA807, 0xA80A},   {0xA80C, 0xA822},   {0xA840, 0xA873},
    -    {0xA882, 0xA8B3},   {0xA8F2, 0xA8F7},   {0xA8FB, 0xA8FB},
    -    {0xA8FD, 0xA8FE},   {0xA90A, 0xA925},   {0xA930, 0xA946},
    -    {0xA960, 0xA97C},   {0xA984, 0xA9B2},   {0xA9CF, 0xA9CF},
    -    {0xA9E0, 0xA9E4},   {0xA9E6, 0xA9EF},   {0xA9FA, 0xA9FE},
    -    {0xAA00, 0xAA28},   {0xAA40, 0xAA42},   {0xAA44, 0xAA4B},
    -    {0xAA60, 0xAA76},   {0xAA7A, 0xAA7A},   {0xAA7E, 0xAAAF},
    -    {0xAAB1, 0xAAB1},   {0xAAB5, 0xAAB6},   {0xAAB9, 0xAABD},
    -    {0xAAC0, 0xAAC0},   {0xAAC2, 0xAAC2},   {0xAADB, 0xAADD},
    -    {0xAAE0, 0xAAEA},   {0xAAF2, 0xAAF4},   {0xAB01, 0xAB06},
    -    {0xAB09, 0xAB0E},   {0xAB11, 0xAB16},   {0xAB20, 0xAB26},
    -    {0xAB28, 0xAB2E},   {0xAB30, 0xAB5A},   {0xAB5C, 0xAB69},
    -    {0xAB6C, 0xAB6D},   {0xAB70, 0xABE2},   {0xAC00, 0xD7A3},
    -    {0xD7B0, 0xD7C6},   {0xD7CB, 0xD7FB},   {0xF900, 0xFA6D},
    -    {0xFA70, 0xFAD9},   {0xFB00, 0xFB06},   {0xFB13, 0xFB17},
    -    {0xFB1D, 0xFB1D},   {0xFB1F, 0xFB28},   {0xFB2A, 0xFB36},
    -    {0xFB38, 0xFB3C},   {0xFB3E, 0xFB3E},   {0xFB40, 0xFB41},
    -    {0xFB43, 0xFB44},   {0xFB46, 0xFBB1},   {0xFBD3, 0xFC5D},
    -    {0xFC64, 0xFD3D},   {0xFD50, 0xFD8F},   {0xFD92, 0xFDC7},
    -    {0xFDF0, 0xFDF9},   {0xFE71, 0xFE71},   {0xFE73, 0xFE73},
    -    {0xFE77, 0xFE77},   {0xFE79, 0xFE79},   {0xFE7B, 0xFE7B},
    -    {0xFE7D, 0xFE7D},   {0xFE7F, 0xFEFC},   {0xFF21, 0xFF3A},
    -    {0xFF41, 0xFF5A},   {0xFF66, 0xFF9D},   {0xFFA0, 0xFFBE},
    -    {0xFFC2, 0xFFC7},   {0xFFCA, 0xFFCF},   {0xFFD2, 0xFFD7},
    -    {0xFFDA, 0xFFDC},   {0x10000, 0x1000B}, {0x1000D, 0x10026},
    -    {0x10028, 0x1003A}, {0x1003C, 0x1003D}, {0x1003F, 0x1004D},
    -    {0x10050, 0x1005D}, {0x10080, 0x100FA}, {0x10140, 0x10174},
    -    {0x10280, 0x1029C}, {0x102A0, 0x102D0}, {0x10300, 0x1031F},
    -    {0x1032D, 0x1034A}, {0x10350, 0x10375}, {0x10380, 0x1039D},
    -    {0x103A0, 0x103C3}, {0x103C8, 0x103CF}, {0x103D1, 0x103D5},
    -    {0x10400, 0x1049D}, {0x104B0, 0x104D3}, {0x104D8, 0x104FB},
    -    {0x10500, 0x10527}, {0x10530, 0x10563}, {0x10570, 0x1057A},
    -    {0x1057C, 0x1058A}, {0x1058C, 0x10592}, {0x10594, 0x10595},
    -    {0x10597, 0x105A1}, {0x105A3, 0x105B1}, {0x105B3, 0x105B9},
    -    {0x105BB, 0x105BC}, {0x105C0, 0x105F3}, {0x10600, 0x10736},
    -    {0x10740, 0x10755}, {0x10760, 0x10767}, {0x10780, 0x10785},
    -    {0x10787, 0x107B0}, {0x107B2, 0x107BF}, {0x10800, 0x10805},
    -    {0x10808, 0x10808}, {0x1080A, 0x10835}, {0x10837, 0x10838},
    -    {0x1083C, 0x1083C}, {0x1083F, 0x10855}, {0x10860, 0x10876},
    -    {0x10880, 0x1089E}, {0x108E0, 0x108F2}, {0x108F4, 0x108F5},
    -    {0x10900, 0x10915}, {0x10920, 0x10939}, {0x10940, 0x10959},
    -    {0x10980, 0x109B7}, {0x109BE, 0x109BF}, {0x10A00, 0x10A00},
    -    {0x10A10, 0x10A13}, {0x10A15, 0x10A17}, {0x10A19, 0x10A35},
    -    {0x10A60, 0x10A7C}, {0x10A80, 0x10A9C}, {0x10AC0, 0x10AC7},
    -    {0x10AC9, 0x10AE4}, {0x10B00, 0x10B35}, {0x10B40, 0x10B55},
    -    {0x10B60, 0x10B72}, {0x10B80, 0x10B91}, {0x10C00, 0x10C48},
    -    {0x10C80, 0x10CB2}, {0x10CC0, 0x10CF2}, {0x10D00, 0x10D23},
    -    {0x10D4A, 0x10D65}, {0x10D6F, 0x10D85}, {0x10E80, 0x10EA9},
    -    {0x10EB0, 0x10EB1}, {0x10EC2, 0x10EC7}, {0x10ED9, 0x10EEE},
    -    {0x10F00, 0x10F1C}, {0x10F27, 0x10F27}, {0x10F30, 0x10F45},
    -    {0x10F70, 0x10F81}, {0x10FB0, 0x10FC4}, {0x10FE0, 0x10FF6},
    -    {0x11003, 0x11037}, {0x11071, 0x11072}, {0x11075, 0x11075},
    -    {0x11083, 0x110AF}, {0x110D0, 0x110E8}, {0x11103, 0x11126},
    -    {0x11144, 0x11144}, {0x11147, 0x11147}, {0x11150, 0x11172},
    -    {0x11176, 0x11176}, {0x11183, 0x111B2}, {0x111C1, 0x111C4},
    -    {0x111DA, 0x111DA}, {0x111DC, 0x111DC}, {0x11200, 0x11211},
    -    {0x11213, 0x1122B}, {0x1123F, 0x11240}, {0x11280, 0x11286},
    -    {0x11288, 0x11288}, {0x1128A, 0x1128D}, {0x1128F, 0x1129D},
    -    {0x1129F, 0x112A8}, {0x112B0, 0x112DE}, {0x11305, 0x1130C},
    -    {0x1130F, 0x11310}, {0x11313, 0x11328}, {0x1132A, 0x11330},
    -    {0x11332, 0x11333}, {0x11335, 0x11339}, {0x1133D, 0x1133D},
    -    {0x11350, 0x11350}, {0x1135D, 0x11361}, {0x11380, 0x11389},
    -    {0x1138B, 0x1138B}, {0x1138E, 0x1138E}, {0x11390, 0x113B5},
    -    {0x113B7, 0x113B7}, {0x113D1, 0x113D1}, {0x113D3, 0x113D3},
    -    {0x11400, 0x11434}, {0x11447, 0x1144A}, {0x1145F, 0x11461},
    -    {0x11480, 0x114AF}, {0x114C4, 0x114C5}, {0x114C7, 0x114C7},
    -    {0x11580, 0x115AE}, {0x115D8, 0x115DB}, {0x11600, 0x1162F},
    -    {0x11644, 0x11644}, {0x11680, 0x116AA}, {0x116B8, 0x116B8},
    -    {0x11700, 0x1171A}, {0x11740, 0x11746}, {0x11800, 0x1182B},
    -    {0x118A0, 0x118DF}, {0x118FF, 0x11906}, {0x11909, 0x11909},
    -    {0x1190C, 0x11913}, {0x11915, 0x11916}, {0x11918, 0x1192F},
    -    {0x1193F, 0x1193F}, {0x11941, 0x11941}, {0x119A0, 0x119A7},
    -    {0x119AA, 0x119D0}, {0x119E1, 0x119E1}, {0x119E3, 0x119E3},
    -    {0x11A00, 0x11A00}, {0x11A0B, 0x11A32}, {0x11A3A, 0x11A3A},
    -    {0x11A50, 0x11A50}, {0x11A5C, 0x11A89}, {0x11A9D, 0x11A9D},
    -    {0x11AB0, 0x11AF8}, {0x11B0A, 0x11B0A}, {0x11BC0, 0x11BE0},
    -    {0x11C00, 0x11C08}, {0x11C0A, 0x11C2E}, {0x11C40, 0x11C40},
    -    {0x11C72, 0x11C8F}, {0x11D00, 0x11D06}, {0x11D08, 0x11D09},
    -    {0x11D0B, 0x11D30}, {0x11D46, 0x11D46}, {0x11D60, 0x11D65},
    -    {0x11D67, 0x11D68}, {0x11D6A, 0x11D89}, {0x11D98, 0x11D98},
    -    {0x11DB0, 0x11DDB}, {0x11DF1, 0x11DF1}, {0x11EE0, 0x11EF2},
    -    {0x11F02, 0x11F02}, {0x11F04, 0x11F10}, {0x11F12, 0x11F33},
    -    {0x11FB0, 0x11FB0}, {0x12000, 0x12399}, {0x12400, 0x1246F},
    -    {0x12475, 0x12543}, {0x12550, 0x12686}, {0x12F90, 0x12FF0},
    -    {0x13000, 0x1342F}, {0x13441, 0x13446}, {0x13460, 0x143FA},
    -    {0x14400, 0x14646}, {0x16100, 0x1611D}, {0x16800, 0x16A38},
    -    {0x16A40, 0x16A5E}, {0x16A70, 0x16ABE}, {0x16AD0, 0x16AED},
    -    {0x16B00, 0x16B2F}, {0x16B40, 0x16B43}, {0x16B63, 0x16B77},
    -    {0x16B7D, 0x16B8F}, {0x16D40, 0x16D6C}, {0x16D80, 0x16D97},
    -    {0x16D99, 0x16D9C}, {0x16E40, 0x16E7F}, {0x16EA0, 0x16EB8},
    -    {0x16EBB, 0x16ED3}, {0x16F00, 0x16F4A}, {0x16F50, 0x16F50},
    -    {0x16F93, 0x16F9F}, {0x16FE0, 0x16FE1}, {0x16FE3, 0x16FE3},
    -    {0x16FF2, 0x16FF6}, {0x17000, 0x18CDA}, {0x18CFF, 0x18D20},
    -    {0x18D80, 0x18DF2}, {0x18E00, 0x19191}, {0x191A0, 0x191D2},
    -    {0x1AFF0, 0x1AFF3}, {0x1AFF5, 0x1AFFB}, {0x1AFFD, 0x1AFFE},
    -    {0x1B000, 0x1B128}, {0x1B132, 0x1B132}, {0x1B150, 0x1B152},
    -    {0x1B155, 0x1B155}, {0x1B164, 0x1B168}, {0x1B170, 0x1B2FB},
    -    {0x1BC00, 0x1BC6A}, {0x1BC70, 0x1BC7C}, {0x1BC80, 0x1BC88},
    -    {0x1BC90, 0x1BC99}, {0x1D400, 0x1D454}, {0x1D456, 0x1D49C},
    -    {0x1D49E, 0x1D49F}, {0x1D4A2, 0x1D4A2}, {0x1D4A5, 0x1D4A6},
    -    {0x1D4A9, 0x1D4AC}, {0x1D4AE, 0x1D4B9}, {0x1D4BB, 0x1D4BB},
    -    {0x1D4BD, 0x1D4C3}, {0x1D4C5, 0x1D5...
    [truncated]
    
    
    ``````

    </details>

    zwuis zwuis commented on code on Oct 05, 2026 13:06 UTC
    Code Review
    llvm/utils/UnicodeData/UnicodeCharSetsGenerator.cpp:1
    @@ -0,0 +1,257 @@
    +//===--- UnicodeCharSetsGenerator.cpp - Unicode character sets generator --===//
    +//
    +// 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
    +//
    +//===----------------------------------------------------------------------===//
    +//
    +// This file is used to generate clang/lib/Lex/UnicodeCharSetsGenerated.cpp and
    +// llvm/lib/Support/UnicodeCharSetsGenerated.cpp from the XML representation of
    +// the Unicode Character Database available at
    +// https://www.unicode.org/Public/UCD/latest/ucdxml/
    +//
    +//===----------------------------------------------------------------------===//
    +
    +#include "llvm/ADT/STLExtras.h"
    +#include "llvm/ADT/SmallVector.h"
    +#include "llvm/ADT/Twine.h"
    +#include "llvm/Support/CommandLine.h"
    +#include "llvm/Support/FileSystem.h"
    +#include "llvm/Support/FormatVariadic.h"
    +#include "llvm/Support/InitLLVM.h"
    +#include "llvm/Support/ToolOutputFile.h"
    +#include "llvm/Support/UnicodeCharRanges.h"
    +#include "llvm/Support/WithColor.h"
    +
    +#include <libxml/xmlreader.h>
    +#include <vector>
    +
    +using namespace llvm;
    +
    +static cl::opt<std::string> UCDFile(cl::Positional, cl::Required,
    +                                    cl::desc("<UCD XML file>"));
    +static cl::opt<std::string> ClangOutput(cl::Positional, cl::Required,
    +                                        cl::desc("<clang output file>"));
    +static cl::opt<std::string> LLVMOutput(cl::Positional, cl::Required,
    +                                       cl::desc("<LLVM output file>"));
    +
    +static constexpr unsigned CodePointCount = 0x110000;
    +
    +static constexpr StringLiteral FileHeader = R"(
    +//===----------------------------------------------------------------------===//
    +//
    +// 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
    +//
    +//===----------------------------------------------------------------------===//
    +//
    +// This file was generated by llvm/utils/UnicodeData/UnicodeCharSetsGenerator
    +// from the Unicode {0} Character Database. Do not edit manually.
    +//
    +//===----------------------------------------------------------------------===//
    +
    +#include "llvm/Support/UnicodeCharRanges.h"
    +
    +using llvm::sys::UnicodeCharRange;
    +using CharRanges = llvm::sys::UnicodeCharSet::CharRanges;
    +
    +namespace {1} {{
    +)";
    +
    +[[noreturn]] static void error(const Twine &Message) {
    +  WithColor::error() << Message << '\n';
    +  exit(EXIT_FAILURE);
    +}
    +
    +namespace {
    +struct Properties {
    +  unsigned XIDStart : 1;
    +  unsigned XIDContinue : 1;
    +  unsigned MathStart : 1;
    +  unsigned MathContinue : 1;
    +  unsigned Printable : 1;
    +  unsigned Format : 1;
    +  unsigned Combining : 1;
    +  unsigned DoubleWidth : 1;
    +};
    +
    +struct CharacterDatabase {
    +  std::string Version;
    +  std::vector<Properties> Chars;
    +};
    +
    +struct XmlDeleter {
    +  void operator()(xmlTextReader *Reader) { xmlFreeTextReader(Reader); }
    +  void operator()(xmlChar *Ptr) { xmlFree(Ptr); }
    +};
    +} // namespace
    +
    +static StringRef fromXmlChar(const xmlChar *S) {
    +  return S ? StringRef(reinterpret_cast<const char *>(S)) : StringRef();
    +}
    +
    +static bool isPrintableGC(StringRef GC) {
    +  return GC == "Zs" || (!GC.empty() && StringRef("LMNPS").contains(GC.front()));
    +}
    +
    +// Loads the properties we care about from the flat XML representation of the
    +// UCD, which describes each code point, or range of code points, with all of
    +// its properties, e.g.
    +//   <char cp="0041" age="1.1" na="LATIN CAPITAL LETTER A" gc="Lu" ... />
    +static CharacterDatabase loadDatabase(StringRef Path) {
    +  std::unique_ptr<xmlTextReader, XmlDeleter> Reader(xmlReaderForFile(
    +      Path.str().c_str(), /*encoding=*/nullptr, XML_PARSE_NONET));
    +  if (!Reader)
    +    error(Path + ": cannot open file");
    +
    +  CharacterDatabase Database;
    +  Database.Chars.resize(CodePointCount);
    +  int Status;
    +  while ((Status = xmlTextReaderRead(Reader.get())) == 1) {
    +    if (xmlTextReaderNodeType(Reader.get()) != XML_READER_TYPE_ELEMENT)
    +      continue;
    +    StringRef Element = fromXmlChar(xmlTextReaderConstLocalName(Reader.get()));
    +    if (Element == "description") {
    +      // <description>Unicode 18.0.0</description>
    +      std::unique_ptr<xmlChar, XmlDeleter> Description(
    +          xmlTextReaderReadString(Reader.get()));
    +      if (Description)
    +        Database.Version = fromXmlChar(Description.get())
    +                               .rsplit(' ')
    +                               .second.rsplit('.')
    +                               .first.str();
    +      continue;
    +    }
    +    if (!is_contained({"char", "reserved", "noncharacter", "surrogate"},
    +                      Element))
    +      continue;
    +
    +    unsigned First = 0, Last = 0;
    +    bool HasRange = false;
    +    unsigned Found = 0;
    +    Properties P = {};
    +    while (xmlTextReaderMoveToNextAttribute(Reader.get()) == 1) {
    +      StringRef Name = fromXmlChar(xmlTextReaderConstLocalName(Reader.get()));
    +      StringRef Value = fromXmlChar(xmlTextReaderConstValue(Reader.get()));
    +      if (Name == "cp" || Name == "first-cp") {
    +        if (Value.getAsInteger(16, First))
    +          break;
    +        if (Name == "cp")
    +          Last = First;
    +        HasRange = true;
    +      } else if (Name == "last-cp") {
    +        if (Value.getAsInteger(16, Last))
    +          HasRange = false;
    +      } else if (Name == "XIDS") {
    +        P.XIDStart = Value == "Y";
    +        ++Found;
    +      } else if (Name == "XIDC") {
    +        P.XIDContinue = Value == "Y";
    +        ++Found;
    +      } else if (Name == "ID_Compat_Math_Start") {
    +        P.MathStart = Value == "Y";
    +        ++Found;
    +      } else if (Name == "ID_Compat_Math_Continue") {
    +        P.MathContinue = Value == "Y";
    +        ++Found;
    +      } else if (Name == "gc") {
    +        P.Printable = isPrintableGC(Value);
    +        P.Format = Value == "Cf";
    +        P.Combining = Value == "Mn" || Value == "Me";
    +        ++Found;
    +      } else if (Name == "ea") {
    +        P.DoubleWidth = Value == "F" || Value == "W";
    +        ++Found;
    +      }
    +    }
    +
    +    if (!HasRange || First > Last || Last >= CodePointCount || Found != 6)
    +      error(Path + ":" + Twine(xmlTextReaderGetParserLineNumber(Reader.get())) +
    +            ": invalid <" + Element + "> element");
    +    llvm::fill(MutableArrayRef(Database.Chars).slice(First, Last - First + 1),
    +               P);
    +  }
    +  if (Status != 0)
    +    error(Path + ": failed to parse XML");
    +  if (Database.Version.empty())
    +    error(Path + ": missing Unicode version");
    +  return Database;
    +}
    +
    +template <typename Predicate>
    +static void emitTable(raw_ostream &OS, StringRef Name, StringRef Description,
    +                      ArrayRef<Properties> Chars, Predicate Pred) {
    +  SmallVector<sys::UnicodeCharRange> Ranges;
    +  for (unsigned CodePoint = 0, E = Chars.size(); CodePoint != E; ++CodePoint) {
    +    if (!Pred(Chars[CodePoint]))
    +      continue;
    +    if (!Ranges.empty() && Ranges.back().Upper + 1 == CodePoint)
    +      Ranges.back().Upper = CodePoint;
    +    else
    +      Ranges.push_back({CodePoint, CodePoint});
    +  }
    +
    +  OS << "\n// " << Description << "\nstatic constexpr UnicodeCharRange " << Name
    +     << "Data[] = {\n";
    +  for (sys::UnicodeCharRange Range : Ranges)
    +    OS << formatv("    {{{0:X4}, {1:X4}},\n", Range.Lower, Range.Upper);
    +  OS << "};\nextern const CharRanges " << Name << " = " << Name << "Data;\n";

    Nit: Use namespace qualifiers for definitions instead of opening namespaces.

    << Namespace << "::" << Name
    

    github-actions[bot] github-actions[bot] commented on Oct 05, 2026 14:45 UTC
    Bot

    <!--PREMERGE ADVISOR COMMENT: Linux-->

    :penguin: Linux x64 Test Results

    185592 tests passed
    6964 tests skipped

    :white_check_mark: The build succeeded and all tests passed.

    github-actions[bot] github-actions[bot] commented on Oct 05, 2026 14:45 UTC
    Bot

    <!--PREMERGE ADVISOR COMMENT: Windows-->

    :window: Windows x64 Test Results

    145180 tests passed
    4840 tests skipped

    :white_check_mark: The build succeeded and all tests passed.

    AaronBallman AaronBallman commented on code on Oct 06, 2026 18:30 UTC
    Code Review
    llvm/docs/HowToUpdateUnicodeTables.md:1
    @@ -0,0 +1,83 @@
    +# Unicode Support
    +
    +Clang uses a subset of the [Unicode Character Database](https://www.unicode.org/ucd/)
    +(UCD) for identifiers, `\N{...}` named characters, diagnostic column width,

    (UCD) for identifiers, `\N{...}` named characters, diagnostic column widths,
    

    AaronBallman AaronBallman commented on code on Oct 06, 2026 18:32 UTC
    Code Review
    clang/docs/UnicodeSupport.md:1
    @@ -0,0 +1,83 @@
    +# Unicode Support
    +
    +Clang uses a subset of the [Unicode Character Database](https://www.unicode.org/ucd/)
    +(UCD) for identifiers, `\N{...}` named characters, diagnostic column width,
    +and simple case folding. The corresponding tables are generated from the UCD
    +into Clang and LLVM Support.
    +
    +## Updating the Unicode Data
    +
    +Replace `N.M.0` with the Unicode version being imported. Build the generators

    What N.M.0 should be replaced where?

    AaronBallman AaronBallman commented on code on Oct 06, 2026 18:33 UTC
    Code Review
    clang/docs/UnicodeSupport.md:1
    @@ -0,0 +1,83 @@
    +# Unicode Support
    +
    +Clang uses a subset of the [Unicode Character Database](https://www.unicode.org/ucd/)
    +(UCD) for identifiers, `\N{...}` named characters, diagnostic column width,
    +and simple case folding. The corresponding tables are generated from the UCD
    +into Clang and LLVM Support.
    +
    +## Updating the Unicode Data
    +
    +Replace `N.M.0` with the Unicode version being imported. Build the generators
    +from an LLVM build directory that has utilities enabled (`LLVM_BUILD_UTILS`,
    +the default) and libxml2 (`LLVM_ENABLE_LIBXML2`, also the default):
    +
    +```bash
    +ninja -C <build> UnicodeCharSetsGenerator UnicodeNameMappingGenerator
    +```
    +
    +Then run them from the `llvm-project` root as shown below.
    +
    +### Character properties
    +
    +`UnicodeCharSetsGenerator` writes the identifier character sets used by the
    +lexer (`XID_Start`, `XID_Continue`, and the mathematical compatibility notation
    +profile) and the printable / formatting / combining / East-Asian-width sets
    +used by LLVM Support.
    +
    +Download the [flat XML UCD](https://www.unicode.org/Public/UCD/latest/ucdxml/)
    +(`ucd.nounihan.flat.zip` is enough):
    +
    +```text
    +https://www.unicode.org/Public/N.M.0/ucdxml/ucd.nounihan.flat.zip
    +```
    +
    +```bash
    +<build>/bin/UnicodeCharSetsGenerator ucd.nounihan.flat.xml \
    +    clang/lib/Lex/UnicodeCharSetsGenerated.cpp \
    +    llvm/lib/Support/UnicodeCharSetsGenerated.cpp
    +clang-format -i clang/lib/Lex/UnicodeCharSetsGenerated.cpp \
    +    llvm/lib/Support/UnicodeCharSetsGenerated.cpp
    +```
    +
    +The C99 and C11 identifier tables and the whitespace table in
    +`clang/lib/Lex/UnicodeCharSets.h` are maintained by hand.
    +
    +### Character names
    +
    +`UnicodeNameMappingGenerator` writes the name-to-codepoint trie used by
    +`\N{...}` and `llvm::sys::unicode::nameToCodepointStrict` /
    +`nameToCodepointLooseMatching`.
    +
    +From the [UCD zip](https://www.unicode.org/Public/UCD/latest/ucd/UCD.zip), take
    +`UnicodeData.txt` and `NameAliases.txt`:
    +
    +```text
    +https://www.unicode.org/Public/N.M.0/ucd/UnicodeData.txt

    Oh! This N.M.0! It may help to connect the dots a bit more explicitly above.

    AaronBallman AaronBallman commented on code on Oct 06, 2026 18:43 UTC
    Code Review
    clang/docs/UnicodeSupport.md:1
    @@ -0,0 +1,83 @@
    +# Unicode Support

    Should this documentation live in LLVM since it's updating things in LLVM's support library?

    cor3ntin cor3ntin commented on code on Oct 06, 2026 20:40 UTC
    Code Review
    clang/docs/UnicodeSupport.md:1
    @@ -0,0 +1,83 @@
    +# Unicode Support

    That's a good question - Mostly I'm more comfortable with clang and historically these tables have been maintained by clang folks - I'm happy to move it though (i.e, no strong opinion either way)

    IvyXu420 IvyXu420 commented on code on Oct 07, 2026 11:44 UTC
    Code Review
    llvm/docs/HowToUpdateUnicodeTables.md:1
    @@ -0,0 +1,81 @@
    +# How to Update Unicode Tables
    +
    +LLVM and Clang use a subset of the [Unicode Character Database](https://www.unicode.org/ucd/)
    +(UCD) for identifiers, `\N{...}` named characters, diagnostic column width,
    +and simple case folding. The corresponding tables are generated from the UCD
    +into Clang and LLVM Support.
    +
    +## Downloading the Unicode data
    +
    +Download the following files, replacing `<VERSION>` with a Unicode version such
    +as `18.0.0`:
    +
    +```text
    +https://www.unicode.org/Public/<VERSION>/ucdxml/ucd.nounihan.flat.zip
    +https://www.unicode.org/Public/<VERSION>/ucd/UnicodeData.txt
    +https://www.unicode.org/Public/<VERSION>/ucd/NameAliases.txt
    +https://www.unicode.org/Public/<VERSION>/ucd/extracted/DerivedName.txt
    +```

    Would it be better to replace these links with the actual latest ones, rather than making readers enter the version manually?
    e.g., https://www.unicode.org/Public/latest/ucdxml/ucd.nounihan.flat.zip

    AaronBallman AaronBallman approved these changes on Oct 08, 2026 12:01 UTC
    Approved Reviewer

    LGTM!

    nico nico commented on Oct 08, 2026 17:15 UTC
    Contributor

    We build our libxml2 with LIBXML2_WITH_READER=OFF. After this commit, that breaks the build:

    /b/s/w/ir/cache/builder/src/third_party/llvm/llvm/utils/UnicodeData/UnicodeCharSetsGenerator.cpp:86:19: error: unknown type name 'xmlTextReader'
       86 |   void operator()(xmlTextReader *Reader) { xmlFreeTextReader(Reader); }
          |         
    

    Is that an intentional new dependency?

    nico nico commented on Oct 08, 2026 20:08 UTC
    Contributor

    => #230254

    Reviewers
    Assignees
    cor3ntin cor3ntin
    Labels
    risk: low confidence: 86.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 59.1% (MEDIUM) · Higher = larger blast radius
    59.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 86.3% · Lower = rushed or shallow review
    86.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.1% · Safe to merge
    8.1%