Skip to content

[Clang] Renumber TokenKey enum values to close gap left by KEYNOZOS removal#207906

Merged
cor3ntin merged 1 commit into
llvm:mainfrom
dingcyrus:fix/renumber-tokenkeys-close-gap
Jul 7, 2026
Merged

[Clang] Renumber TokenKey enum values to close gap left by KEYNOZOS removal#207906
cor3ntin merged 1 commit into
llvm:mainfrom
dingcyrus:fix/renumber-tokenkeys-close-gap

Conversation

@dingcyrus

@dingcyrus dingcyrus commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The previous commit (#207132) removed the unused KEYNOZOS flag (0x4000000) but left a gap between KEYZOS (0x2000000) and KEYHLSL (0x8000000). This patch renumbers the subsequent TokenKey values to close the gap:

KEYHLSL: 0x8000000 -> 0x4000000
KEYFIXEDPOINT: 0x10000000 -> 0x8000000
KEYDEFERTS: 0x20000000 -> 0x10000000
KEYNOHLSL: 0x40000000 -> 0x20000000

The ~0x4000000u exclusion in KEYALL and the associated reserved-bit comment are removed, since the renumbering eliminates the orphaned bit.

This is a follow-up to #207132, as suggested by @perry-ca.

AI assistance was used for code review analysis and CI failure debugging.

…emoval

The previous commit (llvm#207132) removed the unused KEYNOZOS flag
(0x4000000) but left a gap between KEYZOS (0x2000000) and KEYHLSL
(0x8000000). This patch renumbers the subsequent TokenKey values to
close the gap:

  KEYHLSL:       0x8000000  -> 0x4000000
  KEYFIXEDPOINT: 0x10000000 -> 0x8000000
  KEYDEFERTS:    0x20000000 -> 0x10000000
  KEYNOHLSL:     0x40000000 -> 0x20000000

The ~0x4000000u exclusion in KEYALL and the associated reserved-bit
comment are removed, since the renumbering eliminates the orphaned bit.

This is a follow-up to llvm#207132, as suggested by @perry-ca.

AI assistance was used for code review analysis and CI failure debugging.
@llvmorg-github-actions llvmorg-github-actions Bot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jul 7, 2026
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-clang

Author: Cyrus Ding (dingcyrus)

Changes

…emoval

The previous commit (#207132) removed the unused KEYNOZOS flag (0x4000000) but left a gap between KEYZOS (0x2000000) and KEYHLSL (0x8000000). This patch renumbers the subsequent TokenKey values to close the gap:

KEYHLSL: 0x8000000 -> 0x4000000
KEYFIXEDPOINT: 0x10000000 -> 0x8000000
KEYDEFERTS: 0x20000000 -> 0x10000000
KEYNOHLSL: 0x40000000 -> 0x20000000

The ~0x4000000u exclusion in KEYALL and the associated reserved-bit comment are removed, since the renumbering eliminates the orphaned bit.

This is a follow-up to #207132, as suggested by @perry-ca.

AI assistance was used for code review analysis and CI failure debugging.


Full diff: https://github.com/llvm/llvm-project/pull/207906.diff

1 Files Affected:

  • (modified) clang/include/clang/Basic/IdentifierTable.h (+6-12)
diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h
index d0640ee34de75..c2520618d9b96 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -74,20 +74,14 @@ enum TokenKey : unsigned {
   KEYSYCL = 0x800000,
   KEYCUDA = 0x1000000,
   KEYZOS = 0x2000000,
-  // 0x4000000 was KEYNOZOS, which was unused. The value is kept reserved
-  // so that KEYALL's bit-mask computation remains correct: keywords like
-  // 'volatile' (KEYALL|KEYNOHLSL) go through the per-bit loop in
-  // getKeywordStatus, and every bit set in KEYALL must map to a valid
-  // TokenKey with a handler in getKeywordStatusHelper.
-  KEYHLSL = 0x8000000,
-  KEYFIXEDPOINT = 0x10000000,
-  KEYDEFERTS = 0x20000000,
-  KEYNOHLSL = 0x40000000,
+  KEYHLSL = 0x4000000,
+  KEYFIXEDPOINT = 0x8000000,
+  KEYDEFERTS = 0x10000000,
+  KEYNOHLSL = 0x20000000,
   KEYMAX = KEYNOHLSL, // The maximum key
   KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX20,
-  KEYALL = (KEYMAX | (KEYMAX - 1)) & ~KEYNOMS18 & ~KEYNOOPENCL & ~0x4000000u &
-           ~KEYNOHLSL // KEYNOMS18, KEYNOOPENCL, 0x4000000 (reserved),
-                      // KEYNOHLSL excluded.
+  KEYALL = (KEYMAX | (KEYMAX - 1)) & ~KEYNOMS18 & ~KEYNOOPENCL &
+           ~KEYNOHLSL // KEYNOMS18, KEYNOOPENCL, KEYNOHLSL excluded.
 };
 
 /// How a keyword is treated in the selected standard. This enum is ordered

@zwuis zwuis changed the title [Clang] Renumber TokenKey enum values to close gap left by KEYNOZOS r… [Clang] Renumber TokenKey enum values to close gap left by KEYNOZOS removal Jul 7, 2026
@cor3ntin cor3ntin merged commit d847e2f into llvm:main Jul 7, 2026
14 checks passed
@dingcyrus

Copy link
Copy Markdown
Contributor Author

Thanks again @cor3ntin for approving and merging this follow-up PR! Really appreciate your guidance.

aobolensk pushed a commit to aobolensk/llvm-project that referenced this pull request Jul 8, 2026
…emoval (llvm#207906)

The previous commit (llvm#207132) removed the unused KEYNOZOS flag
(0x4000000) but left a gap between KEYZOS (0x2000000) and KEYHLSL
(0x8000000). This patch renumbers the subsequent TokenKey values to
close the gap:

  KEYHLSL:       0x8000000  -> 0x4000000
  KEYFIXEDPOINT: 0x10000000 -> 0x8000000
  KEYDEFERTS:    0x20000000 -> 0x10000000
  KEYNOHLSL:     0x40000000 -> 0x20000000

The ~0x4000000u exclusion in KEYALL and the associated reserved-bit
comment are removed, since the renumbering eliminates the orphaned bit.

This is a follow-up to llvm#207132, as suggested by @perry-ca.

AI assistance was used for code review analysis and CI failure
debugging.

Co-authored-by: Chenguang Ding <dingchenguang@kylinos.cn>
gandhi56 pushed a commit that referenced this pull request Jul 9, 2026
…emoval (#207906)

The previous commit (#207132) removed the unused KEYNOZOS flag
(0x4000000) but left a gap between KEYZOS (0x2000000) and KEYHLSL
(0x8000000). This patch renumbers the subsequent TokenKey values to
close the gap:

  KEYHLSL:       0x8000000  -> 0x4000000
  KEYFIXEDPOINT: 0x10000000 -> 0x8000000
  KEYDEFERTS:    0x20000000 -> 0x10000000
  KEYNOHLSL:     0x40000000 -> 0x20000000

The ~0x4000000u exclusion in KEYALL and the associated reserved-bit
comment are removed, since the renumbering eliminates the orphaned bit.

This is a follow-up to #207132, as suggested by @perry-ca.

AI assistance was used for code review analysis and CI failure
debugging.

Co-authored-by: Chenguang Ding <dingchenguang@kylinos.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants