[libc-commits] [libc] [libc][wctype] Create generation script for classification lookup tables (PR #172042)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Mon Dec 22 11:36:41 PST 2025


================
@@ -0,0 +1,3726 @@
+//===-- 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
+//
+//===----------------------------------------------------------------------===//
+// DO NOT EDIT MANUALLY.
+// This file is generated by libc/utils/wctype_utils scripts.
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_WCTYPE_WCTYPE_CLASSIFICATION_UTILS_H
+#define LLVM_LIBC_SRC___SUPPORT_WCTYPE_WCTYPE_CLASSIFICATION_UTILS_H
+
+#include "hdr/stdint_proxy.h"
+#include "hdr/types/wchar_t.h"
+#include "src/__support/CPP/limits.h"
+#include "src/__support/libc_assert.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+// Property flags for Unicode categories
+enum PropertyFlag : uint8_t {
+  UPPER = 1 << 0,
+  LOWER = 1 << 1,
+  ALPHA = 1 << 2,
+  SPACE = 1 << 3,
+  PRINT = 1 << 4,
+  BLANK = 1 << 5,
+  CNTRL = 1 << 6,
+  PUNCT = 1 << 7,
+};
+
+static_assert(4352 <= cpp::numeric_limits<unsigned short>::max());
+static_assert(39168 <= cpp::numeric_limits<unsigned short>::max());
----------------
michaelrj-google wrote:

nit: These should check the `LEVEL1_SIZE` and `LEVEL2_SIZE` variables instead of just the raw constants.

https://github.com/llvm/llvm-project/pull/172042


More information about the libc-commits mailing list