https://github.com/dingcyrus updated 
https://github.com/llvm/llvm-project/pull/207132

>From ddf8b06d4b49fc84a47f5320cf31cc305aeb6add Mon Sep 17 00:00:00 2001
From: Chenguang Ding <[email protected]>
Date: Thu, 2 Jul 2026 14:28:26 +0800
Subject: [PATCH] [Clang] Remove unused TokenKey::KEYNOZOS

KEYNOZOS was defined as a TokenKey flag to mark keywords not supported
on z/OS, but no keyword in TokenKinds.def actually uses it. This patch
removes the dead handling code while keeping the bit value (0x4000000)
excluded from KEYALL.

This exclusion is necessary because keywords like 'volatile'
(KEYALL|KEYNOHLSL) and '_Atomic' (KEYALL|KEYNOOPENCL) go through the
per-bit loop in getKeywordStatus rather than the KEYALL fast path.
If the orphaned bit were included in KEYALL, the loop would pass it
to getKeywordStatusHelper, which has no handler for it, hitting
llvm_unreachable.

Fixes #206877
---
 clang/include/clang/Basic/IdentifierTable.h | 12 +++++++++---
 clang/lib/Basic/IdentifierTable.cpp         |  3 ---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/IdentifierTable.h 
b/clang/include/clang/Basic/IdentifierTable.h
index 9e80c3fb7079d..d53d050b32df8 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -74,15 +74,21 @@ enum TokenKey : unsigned {
   KEYSYCL = 0x800000,
   KEYCUDA = 0x1000000,
   KEYZOS = 0x2000000,
-  KEYNOZOS = 0x4000000,
+  // 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,
   KEYMAX = KEYNOHLSL, // The maximum key
   KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX20,
-  KEYALL = (KEYMAX | (KEYMAX - 1)) & ~KEYNOMS18 & ~KEYNOOPENCL & ~KEYNOZOS &
-           ~KEYNOHLSL // KEYNOMS18, KEYNOOPENCL, KEYNOZOS, KEYNOHLSL excluded.
+  KEYALL = (KEYMAX | (KEYMAX - 1)) & ~KEYNOMS18 & ~KEYNOOPENCL &
+           ~0x4000000u &
+           ~KEYNOHLSL // KEYNOMS18, KEYNOOPENCL, 0x4000000 (reserved),
+                      // KEYNOHLSL excluded.
 };
 
 /// How a keyword is treated in the selected standard. This enum is ordered
diff --git a/clang/lib/Basic/IdentifierTable.cpp 
b/clang/lib/Basic/IdentifierTable.cpp
index a2e9316e4e372..68cd02a623351 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -159,7 +159,6 @@ static KeywordStatus getKeywordStatusHelper(const 
LangOptions &LangOpts,
     return LangOpts.CPlusPlus ? KS_Unknown : KS_Enabled;
   case KEYNOOPENCL:
   case KEYNOMS18:
-  case KEYNOZOS:
   case KEYNOHLSL:
     // The disable behavior for this is handled in getKeywordStatus.
     return KS_Unknown;
@@ -184,8 +183,6 @@ KeywordStatus clang::getKeywordStatus(const LangOptions 
&LangOpts,
   if (LangOpts.MSVCCompat && (Flags & KEYNOMS18) &&
       !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015))
     return KS_Disabled;
-  if (LangOpts.ZOSExt && (Flags & KEYNOZOS))
-    return KS_Disabled;
   KeywordStatus CurStatus = KS_Unknown;
 
   while (Flags != 0) {

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to