[AA] Pass query info.
[llvm-project.git] / libc / src / ctype / ctype_utils.h
blob6238bd32d9f8cce2d3200624874d0128503b30e6
1 //===-- Collection of utils for implementing ctype functions-------*-C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC_CTYPE_CTYPE_UTILS_H
10 #define LLVM_LIBC_SRC_CTYPE_CTYPE_UTILS_H
12 namespace __llvm_libc {
13 namespace internal {
15 // ------------------------------------------------------
16 // Rationale: Since these classification functions are
17 // called in other functions, we will avoid the overhead
18 // of a function call by inlining them.
19 // ------------------------------------------------------
21 static inline int isalpha(unsigned ch) { return (ch | 32) - 'a' < 26; }
23 static inline int isdigit(unsigned ch) { return (ch - '0') < 10; }
25 static inline int isalnum(unsigned ch) { return isalpha(ch) || isdigit(ch); }
27 static inline int isgraph(unsigned ch) { return 0x20 < ch && ch < 0x7f; }
29 static inline int islower(unsigned ch) { return (ch - 'a') < 26; }
31 static inline int isupper(unsigned ch) { return (ch - 'A') < 26; }
33 } // namespace internal
34 } // namespace __llvm_libc
36 #endif // LLVM_LIBC_SRC_CTYPE_CTYPE_UTILS_H