9#ifndef LLVM_CLANG_BASIC_CHARINFO_H
10#define LLVM_CLANG_BASIC_CHARINFO_H
13#include "llvm/ADT/StringRef.h"
14#include "llvm/Support/Compiler.h"
15#include "llvm/Support/DataTypes.h"
42 return static_cast<unsigned char>(
c) <= 127;
45LLVM_READNONE
inline bool isASCII(
unsigned char c) {
return c <= 127; }
48LLVM_READNONE
inline bool isASCII(uint32_t
c) {
return c <= 127; }
49LLVM_READNONE
inline bool isASCII(int64_t
c) {
return 0 <=
c &&
c <= 127; }
54 bool AllowDollar =
false) {
55 using namespace charinfo;
56 if (
InfoTable[
c] & (CHAR_UPPER|CHAR_LOWER|CHAR_UNDER))
58 return AllowDollar &&
c ==
'$';
63 static constexpr unsigned char IDContinue[256] = {
64 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
65 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
66 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
67 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
68 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
69 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
71 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
72 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
73 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
74 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
84 return AllowDollar &&
c ==
'$';
92 using namespace charinfo;
93 return (
InfoTable[
c] & (CHAR_HORZ_WS|CHAR_SPACE)) != 0;
100 using namespace charinfo;
109 using namespace charinfo;
110 return (
InfoTable[
c] & (CHAR_HORZ_WS|CHAR_VERT_WS|CHAR_SPACE)) != 0;
114LLVM_READONLY
inline bool isDigit(
unsigned char c) {
115 using namespace charinfo;
121 using namespace charinfo;
127 using namespace charinfo;
133 using namespace charinfo;
134 return (
InfoTable[
c] & (CHAR_UPPER|CHAR_LOWER)) != 0;
139 using namespace charinfo;
140 return (
InfoTable[
c] & (CHAR_DIGIT|CHAR_UPPER|CHAR_LOWER)) != 0;
145 using namespace charinfo;
146 return (
InfoTable[
c] & (CHAR_DIGIT|CHAR_XLETTER)) != 0;
153 using namespace charinfo;
154 return (
InfoTable[
c] & (CHAR_UNDER | CHAR_PERIOD | CHAR_PUNCT)) != 0;
161 using namespace charinfo;
162 return (
InfoTable[
c] & (CHAR_UPPER | CHAR_LOWER | CHAR_PERIOD | CHAR_PUNCT |
163 CHAR_DIGIT | CHAR_UNDER | CHAR_SPACE)) != 0;
169 using namespace charinfo;
171 (CHAR_UPPER|CHAR_LOWER|CHAR_DIGIT|CHAR_UNDER|CHAR_PERIOD)) != 0;
176 using namespace charinfo;
177 return (
InfoTable[
c] & (CHAR_UPPER | CHAR_LOWER | CHAR_PERIOD | CHAR_DIGIT |
178 CHAR_UNDER | CHAR_PUNCT)) != 0 &&
179 c !=
'(' &&
c !=
')' &&
c !=
'\\';
190template <EscapeChar Opt,
class CharT>
226 return c +
'a' -
'A';
235 return c +
'A' -
'a';
245 bool AllowDollar =
false) {
249 for (StringRef::iterator I = S.begin(),
E = S.end(); I !=
E; ++I)
static constexpr OptTable::Info InfoTable[]
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
__device__ __2f16 float c
const uint16_t InfoTable[256]
The JSON file list parser is used to communicate input to InstallAPI.
LLVM_READNONE bool isASCII(char c)
Returns true if a byte is an ASCII character.
LLVM_READONLY bool isVerticalWhitespace(unsigned char c)
Returns true if this character is vertical ASCII whitespace: '\n', '\r'.
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
LLVM_READONLY bool isAsciiIdentifierContinue(unsigned char c)
LLVM_READONLY auto escapeCStyle(CharT Ch) -> StringRef
Return C-style escaped string for special characters, or an empty string if there is no such mapping.
LLVM_READONLY char toLowercase(char c)
Converts the given ASCII character to its lowercase equivalent.
LLVM_READONLY bool isUppercase(unsigned char c)
Return true if this character is an uppercase ASCII letter: [A-Z].
LLVM_READONLY bool isValidAsciiIdentifier(StringRef S, bool AllowDollar=false)
Return true if this is a valid ASCII identifier.
LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
LLVM_READONLY bool isAlphanumeric(unsigned char c)
Return true if this character is an ASCII letter or digit: [a-zA-Z0-9].
LLVM_READONLY bool isHorizontalWhitespace(unsigned char c)
Returns true if this character is horizontal ASCII whitespace: ' ', '\t', '\f', '\v'.
LLVM_READONLY bool isRawStringDelimBody(unsigned char c)
Return true if this is the body character of a C++ raw string delimiter.
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
LLVM_READONLY bool isLowercase(unsigned char c)
Return true if this character is a lowercase ASCII letter: [a-z].
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...
LLVM_READONLY bool isPreprocessingNumberBody(unsigned char c)
Return true if this is the body character of a C preprocessing number, which is [a-zA-Z0-9_.
LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
LLVM_READONLY bool isHexDigit(unsigned char c)
Return true if this character is an ASCII hex digit: [0-9a-fA-F].
LLVM_READONLY bool isPunctuation(unsigned char c)
Return true if this character is an ASCII punctuation character.
LLVM_READONLY bool isAsciiIdentifierStart(unsigned char c, bool AllowDollar=false)
Returns true if this is a valid first character of a C identifier, which is [a-zA-Z_].