[libc-commits] [libc] [libc][wctype] Create generation script for classification lookup tables (PR #172042)
Marcell Leleszi via libc-commits
libc-commits at lists.llvm.org
Tue Dec 30 09:33:32 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());
----------------
mleleszi wrote:
I'm intentionally checking the raw constants themselves, if they were assigned and larger than the max they would wrap and the assert would always be true
https://github.com/llvm/llvm-project/pull/172042
More information about the libc-commits
mailing list