File indexing completed on 2026-05-10 08:36:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_CLANG_BASIC_TOKENKINDS_H
0015 #define LLVM_CLANG_BASIC_TOKENKINDS_H
0016
0017 #include "llvm/ADT/DenseMapInfo.h"
0018 #include "llvm/Support/Compiler.h"
0019
0020 namespace clang {
0021
0022 namespace tok {
0023
0024
0025 enum TokenKind : unsigned short {
0026 #define TOK(X) X,
0027 #include "clang/Basic/TokenKinds.def"
0028 NUM_TOKENS
0029 };
0030
0031
0032
0033 enum PPKeywordKind {
0034 #define PPKEYWORD(X) pp_##X,
0035 #include "clang/Basic/TokenKinds.def"
0036 NUM_PP_KEYWORDS
0037 };
0038
0039
0040
0041 enum ObjCKeywordKind {
0042 #define OBJC_AT_KEYWORD(X) objc_##X,
0043 #include "clang/Basic/TokenKinds.def"
0044 NUM_OBJC_KEYWORDS
0045 };
0046
0047
0048
0049 enum NotableIdentifierKind {
0050 #define NOTABLE_IDENTIFIER(X) X,
0051 #include "clang/Basic/TokenKinds.def"
0052 NUM_NOTABLE_IDENTIFIERS
0053 };
0054
0055
0056 enum OnOffSwitch {
0057 OOS_ON, OOS_OFF, OOS_DEFAULT
0058 };
0059
0060
0061
0062
0063
0064 const char *getTokenName(TokenKind Kind) LLVM_READNONE;
0065
0066
0067
0068
0069
0070
0071
0072
0073 const char *getPunctuatorSpelling(TokenKind Kind) LLVM_READNONE;
0074
0075
0076
0077 const char *getKeywordSpelling(TokenKind Kind) LLVM_READNONE;
0078
0079
0080 const char *getPPKeywordSpelling(PPKeywordKind Kind) LLVM_READNONE;
0081
0082
0083 inline bool isAnyIdentifier(TokenKind K) {
0084 return (K == tok::identifier) || (K == tok::raw_identifier);
0085 }
0086
0087
0088
0089 inline bool isStringLiteral(TokenKind K) {
0090 return K == tok::string_literal || K == tok::wide_string_literal ||
0091 K == tok::utf8_string_literal || K == tok::utf16_string_literal ||
0092 K == tok::utf32_string_literal;
0093 }
0094
0095
0096
0097 inline bool isLiteral(TokenKind K) {
0098 return K == tok::numeric_constant || K == tok::char_constant ||
0099 K == tok::wide_char_constant || K == tok::utf8_char_constant ||
0100 K == tok::utf16_char_constant || K == tok::utf32_char_constant ||
0101 isStringLiteral(K) || K == tok::header_name || K == tok::binary_data;
0102 }
0103
0104
0105 bool isAnnotation(TokenKind K);
0106
0107
0108 bool isPragmaAnnotation(TokenKind K);
0109
0110 inline constexpr bool isRegularKeywordAttribute(TokenKind K) {
0111 return (false
0112 #define KEYWORD_ATTRIBUTE(X, ...) || (K == tok::kw_##X)
0113 #include "clang/Basic/RegularKeywordAttrInfo.inc"
0114 );
0115 }
0116
0117 }
0118 }
0119
0120 namespace llvm {
0121 template <> struct DenseMapInfo<clang::tok::PPKeywordKind> {
0122 static inline clang::tok::PPKeywordKind getEmptyKey() {
0123 return clang::tok::PPKeywordKind::pp_not_keyword;
0124 }
0125 static inline clang::tok::PPKeywordKind getTombstoneKey() {
0126 return clang::tok::PPKeywordKind::NUM_PP_KEYWORDS;
0127 }
0128 static unsigned getHashValue(const clang::tok::PPKeywordKind &Val) {
0129 return static_cast<unsigned>(Val);
0130 }
0131 static bool isEqual(const clang::tok::PPKeywordKind &LHS,
0132 const clang::tok::PPKeywordKind &RHS) {
0133 return LHS == RHS;
0134 }
0135 };
0136 }
0137
0138 #endif