1//===--- TokenKinds.def - C Family Token Kind Database ----------*- 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//===----------------------------------------------------------------------===// 8// 9// This file defines the TokenKind database. This includes normal tokens like 10// tok::ampamp (corresponding to the && token) as well as keywords for various 11// languages. Users of this file must optionally #define the TOK, KEYWORD, 12// CXX11_KEYWORD, ALIAS, or PPKEYWORD macros to make use of this file. 13// 14//===----------------------------------------------------------------------===// 15 16#ifndef TOK 17#define TOK(X) 18#endif 19#ifndef PUNCTUATOR 20#define PUNCTUATOR(X,Y) TOK(X) 21#endif 22#ifndef KEYWORD 23#define KEYWORD(X,Y) TOK(kw_ ## X) 24#endif 25#ifndef CXX11_KEYWORD 26#define CXX11_KEYWORD(X,Y) KEYWORD(X,KEYCXX11|(Y)) 27#endif 28#ifndef CXX20_KEYWORD 29#define CXX20_KEYWORD(X,Y) KEYWORD(X,KEYCXX20|(Y)) 30#endif 31#ifndef C99_KEYWORD 32#define C99_KEYWORD(X,Y) KEYWORD(X,KEYC99|(Y)) 33#endif 34#ifndef C2X_KEYWORD 35#define C2X_KEYWORD(X,Y) KEYWORD(X,KEYC2X|(Y)) 36#endif 37#ifndef COROUTINES_KEYWORD 38#define COROUTINES_KEYWORD(X) CXX20_KEYWORD(X,KEYCOROUTINES) 39#endif 40#ifndef MODULES_KEYWORD 41#define MODULES_KEYWORD(X) KEYWORD(X,KEYMODULES) 42#endif 43#ifndef TYPE_TRAIT 44#define TYPE_TRAIT(N,I,K) KEYWORD(I,K) 45#endif 46#ifndef TYPE_TRAIT_1 47#define TYPE_TRAIT_1(I,E,K) TYPE_TRAIT(1,I,K) 48#endif 49#ifndef TYPE_TRAIT_2 50#define TYPE_TRAIT_2(I,E,K) TYPE_TRAIT(2,I,K) 51#endif 52#ifndef TYPE_TRAIT_N 53#define TYPE_TRAIT_N(I,E,K) TYPE_TRAIT(0,I,K) 54#endif 55#ifndef ARRAY_TYPE_TRAIT 56#define ARRAY_TYPE_TRAIT(I,E,K) KEYWORD(I,K) 57#endif 58#ifndef UNARY_EXPR_OR_TYPE_TRAIT 59#define UNARY_EXPR_OR_TYPE_TRAIT(I,E,K) KEYWORD(I,K) 60#endif 61#ifndef CXX11_UNARY_EXPR_OR_TYPE_TRAIT 62#define CXX11_UNARY_EXPR_OR_TYPE_TRAIT(I,E,K) CXX11_KEYWORD(I,K) 63#endif 64#ifndef EXPRESSION_TRAIT 65#define EXPRESSION_TRAIT(I,E,K) KEYWORD(I,K) 66#endif 67#ifndef ALIAS 68#define ALIAS(X,Y,Z) 69#endif 70#ifndef PPKEYWORD 71#define PPKEYWORD(X) 72#endif 73#ifndef CXX_KEYWORD_OPERATOR 74#define CXX_KEYWORD_OPERATOR(X,Y) 75#endif 76#ifndef OBJC_AT_KEYWORD 77#define OBJC_AT_KEYWORD(X) 78#endif 79#ifndef TESTING_KEYWORD 80#define TESTING_KEYWORD(X, L) KEYWORD(X, L) 81#endif 82#ifndef ANNOTATION 83#define ANNOTATION(X) TOK(annot_ ## X) 84#endif 85#ifndef PRAGMA_ANNOTATION 86#define PRAGMA_ANNOTATION(X) ANNOTATION(X) 87#endif 88 89//===----------------------------------------------------------------------===// 90// Preprocessor keywords. 91//===----------------------------------------------------------------------===// 92 93// These have meaning after a '#' at the start of a line. These define enums in 94// the tok::pp_* namespace. Note that IdentifierInfo::getPPKeywordID must be 95// manually updated if something is added here. 96PPKEYWORD(not_keyword) 97 98// C99 6.10.1 - Conditional Inclusion. 99PPKEYWORD(if) 100PPKEYWORD(ifdef) 101PPKEYWORD(ifndef) 102PPKEYWORD(elif) 103PPKEYWORD(elifdef) 104PPKEYWORD(elifndef) 105PPKEYWORD(else) 106PPKEYWORD(endif) 107PPKEYWORD(defined) 108 109// C99 6.10.2 - Source File Inclusion. 110PPKEYWORD(include) 111PPKEYWORD(__include_macros) 112 113// C99 6.10.3 - Macro Replacement. 114PPKEYWORD(define) 115PPKEYWORD(undef) 116 117// C99 6.10.4 - Line Control. 118PPKEYWORD(line) 119 120// C99 6.10.5 - Error Directive. 121PPKEYWORD(error) 122 123// C99 6.10.6 - Pragma Directive. 124PPKEYWORD(pragma) 125 126// GNU Extensions. 127PPKEYWORD(import) 128PPKEYWORD(include_next) 129PPKEYWORD(warning) 130PPKEYWORD(ident) 131PPKEYWORD(sccs) 132PPKEYWORD(assert) 133PPKEYWORD(unassert) 134 135// Clang extensions 136PPKEYWORD(__public_macro) 137PPKEYWORD(__private_macro) 138 139//===----------------------------------------------------------------------===// 140// Language keywords. 141//===----------------------------------------------------------------------===// 142 143// These define members of the tok::* namespace. 144 145TOK(unknown) // Not a token. 146TOK(eof) // End of file. 147TOK(eod) // End of preprocessing directive (end of line inside a 148 // directive). 149TOK(code_completion) // Code completion marker 150 151// C99 6.4.9: Comments. 152TOK(comment) // Comment (only in -E -C[C] mode) 153 154// C99 6.4.2: Identifiers. 155TOK(identifier) // abcde123 156TOK(raw_identifier) // Used only in raw lexing mode. 157 158// C99 6.4.4.1: Integer Constants 159// C99 6.4.4.2: Floating Constants 160TOK(numeric_constant) // 0x123 161 162// C99 6.4.4: Character Constants 163TOK(char_constant) // 'a' 164TOK(wide_char_constant) // L'b' 165 166// C++17 Character Constants 167TOK(utf8_char_constant) // u8'a' 168 169// C++11 Character Constants 170TOK(utf16_char_constant) // u'a' 171TOK(utf32_char_constant) // U'a' 172 173// C99 6.4.5: String Literals. 174TOK(string_literal) // "foo" 175TOK(wide_string_literal) // L"foo" 176 177// C11 6.4.7: Header Names 178TOK(header_name) // <foo>, or "foo" lexed as a header-name 179 180// C++11 String Literals. 181TOK(utf8_string_literal) // u8"foo" 182TOK(utf16_string_literal)// u"foo" 183TOK(utf32_string_literal)// U"foo" 184 185// C99 6.4.6: Punctuators. 186PUNCTUATOR(l_square, "[") 187PUNCTUATOR(r_square, "]") 188PUNCTUATOR(l_paren, "(") 189PUNCTUATOR(r_paren, ")") 190PUNCTUATOR(l_brace, "{") 191PUNCTUATOR(r_brace, "}") 192PUNCTUATOR(period, ".") 193PUNCTUATOR(ellipsis, "...") 194PUNCTUATOR(amp, "&") 195PUNCTUATOR(ampamp, "&&") 196PUNCTUATOR(ampequal, "&=") 197PUNCTUATOR(star, "*") 198PUNCTUATOR(starequal, "*=") 199PUNCTUATOR(plus, "+") 200PUNCTUATOR(plusplus, "++") 201PUNCTUATOR(plusequal, "+=") 202PUNCTUATOR(minus, "-") 203PUNCTUATOR(arrow, "->") 204PUNCTUATOR(minusminus, "--") 205PUNCTUATOR(minusequal, "-=") 206PUNCTUATOR(tilde, "~") 207PUNCTUATOR(exclaim, "!") 208PUNCTUATOR(exclaimequal, "!=") 209PUNCTUATOR(slash, "/") 210PUNCTUATOR(slashequal, "/=") 211PUNCTUATOR(percent, "%") 212PUNCTUATOR(percentequal, "%=") 213PUNCTUATOR(less, "<") 214PUNCTUATOR(lessless, "<<") 215PUNCTUATOR(lessequal, "<=") 216PUNCTUATOR(lesslessequal, "<<=") 217PUNCTUATOR(spaceship, "<=>") 218PUNCTUATOR(greater, ">") 219PUNCTUATOR(greatergreater, ">>") 220PUNCTUATOR(greaterequal, ">=") 221PUNCTUATOR(greatergreaterequal, ">>=") 222PUNCTUATOR(caret, "^") 223PUNCTUATOR(caretequal, "^=") 224PUNCTUATOR(pipe, "|") 225PUNCTUATOR(pipepipe, "||") 226PUNCTUATOR(pipeequal, "|=") 227PUNCTUATOR(question, "?") 228PUNCTUATOR(colon, ":") 229PUNCTUATOR(semi, ";") 230PUNCTUATOR(equal, "=") 231PUNCTUATOR(equalequal, "==") 232PUNCTUATOR(comma, ",") 233PUNCTUATOR(hash, "#") 234PUNCTUATOR(hashhash, "##") 235PUNCTUATOR(hashat, "#@") 236 237// C++ Support 238PUNCTUATOR(periodstar, ".*") 239PUNCTUATOR(arrowstar, "->*") 240PUNCTUATOR(coloncolon, "::") 241 242// Objective C support. 243PUNCTUATOR(at, "@") 244 245// CUDA support. 246PUNCTUATOR(lesslessless, "<<<") 247PUNCTUATOR(greatergreatergreater, ">>>") 248 249// CL support 250PUNCTUATOR(caretcaret, "^^") 251 252// C99 6.4.1: Keywords. These turn into kw_* tokens. 253// Flags allowed: 254// KEYALL - This is a keyword in all variants of C and C++, or it 255// is a keyword in the implementation namespace that should 256// always be treated as a keyword 257// KEYC99 - This is a keyword introduced to C in C99 258// KEYC11 - This is a keyword introduced to C in C11 259// KEYC2X - This is a keyword introduced to C in C2x 260// KEYCXX - This is a C++ keyword, or a C++-specific keyword in the 261// implementation namespace 262// KEYNOCXX - This is a keyword in every non-C++ dialect. 263// KEYCXX11 - This is a C++ keyword introduced to C++ in C++11 264// KEYCXX20 - This is a C++ keyword introduced to C++ in C++20 265// KEYMODULES - This is a keyword if the C++ extensions for modules 266// are enabled. 267// KEYGNU - This is a keyword if GNU extensions are enabled 268// KEYMS - This is a keyword if Microsoft extensions are enabled 269// KEYMSCOMPAT - This is a keyword if Microsoft compatibility mode is enabled 270// KEYNOMS18 - This is a keyword that must never be enabled under 271// MSVC <= v18. 272// KEYOPENCLC - This is a keyword in OpenCL C 273// KEYOPENCLCXX - This is a keyword in C++ for OpenCL 274// KEYNOOPENCL - This is a keyword that is not supported in OpenCL 275// KEYALTIVEC - This is a keyword in AltiVec 276// KEYZVECTOR - This is a keyword for the System z vector extensions, 277// which are heavily based on AltiVec 278// KEYBORLAND - This is a keyword if Borland extensions are enabled 279// KEYCOROUTINES - This is a keyword if support for C++ coroutines is enabled 280// BOOLSUPPORT - This is a keyword if 'bool' is a built-in type 281// HALFSUPPORT - This is a keyword if 'half' is a built-in type 282// WCHARSUPPORT - This is a keyword if 'wchar_t' is a built-in type 283// CHAR8SUPPORT - This is a keyword if 'char8_t' is a built-in type 284// 285KEYWORD(auto , KEYALL) 286KEYWORD(break , KEYALL) 287KEYWORD(case , KEYALL) 288KEYWORD(char , KEYALL) 289KEYWORD(const , KEYALL) 290KEYWORD(continue , KEYALL) 291KEYWORD(default , KEYALL) 292KEYWORD(do , KEYALL) 293KEYWORD(double , KEYALL) 294KEYWORD(else , KEYALL) 295KEYWORD(enum , KEYALL) 296KEYWORD(extern , KEYALL) 297KEYWORD(float , KEYALL) 298KEYWORD(for , KEYALL) 299KEYWORD(goto , KEYALL) 300KEYWORD(if , KEYALL) 301KEYWORD(int , KEYALL) 302KEYWORD(_ExtInt , KEYALL) 303KEYWORD(_BitInt , KEYALL) 304KEYWORD(long , KEYALL) 305KEYWORD(register , KEYALL) 306KEYWORD(return , KEYALL) 307KEYWORD(short , KEYALL) 308KEYWORD(signed , KEYALL) 309UNARY_EXPR_OR_TYPE_TRAIT(sizeof, SizeOf, KEYALL) 310KEYWORD(static , KEYALL) 311KEYWORD(struct , KEYALL) 312KEYWORD(switch , KEYALL) 313KEYWORD(typedef , KEYALL) 314KEYWORD(union , KEYALL) 315KEYWORD(unsigned , KEYALL) 316KEYWORD(void , KEYALL) 317KEYWORD(volatile , KEYALL) 318KEYWORD(while , KEYALL) 319KEYWORD(_Alignas , KEYALL) 320KEYWORD(_Alignof , KEYALL) 321KEYWORD(_Atomic , KEYALL|KEYNOOPENCL) 322KEYWORD(_Bool , KEYNOCXX) 323KEYWORD(_Complex , KEYALL) 324KEYWORD(_Generic , KEYALL) 325KEYWORD(_Imaginary , KEYALL) 326KEYWORD(_Noreturn , KEYALL) 327KEYWORD(_Static_assert , KEYALL) 328KEYWORD(_Thread_local , KEYALL) 329KEYWORD(__func__ , KEYALL) 330KEYWORD(__objc_yes , KEYALL) 331KEYWORD(__objc_no , KEYALL) 332 333 334// C++ 2.11p1: Keywords. 335KEYWORD(asm , KEYCXX|KEYGNU) 336KEYWORD(bool , BOOLSUPPORT|KEYC2X) 337KEYWORD(catch , KEYCXX) 338KEYWORD(class , KEYCXX) 339KEYWORD(const_cast , KEYCXX) 340KEYWORD(delete , KEYCXX) 341KEYWORD(dynamic_cast , KEYCXX) 342KEYWORD(explicit , KEYCXX) 343KEYWORD(export , KEYCXX) 344KEYWORD(false , BOOLSUPPORT|KEYC2X) 345KEYWORD(friend , KEYCXX) 346KEYWORD(mutable , KEYCXX) 347KEYWORD(namespace , KEYCXX) 348KEYWORD(new , KEYCXX) 349KEYWORD(operator , KEYCXX) 350KEYWORD(private , KEYCXX) 351KEYWORD(protected , KEYCXX) 352KEYWORD(public , KEYCXX) 353KEYWORD(reinterpret_cast , KEYCXX) 354KEYWORD(static_cast , KEYCXX) 355KEYWORD(template , KEYCXX) 356KEYWORD(this , KEYCXX) 357KEYWORD(throw , KEYCXX) 358KEYWORD(true , BOOLSUPPORT|KEYC2X) 359KEYWORD(try , KEYCXX) 360KEYWORD(typename , KEYCXX) 361KEYWORD(typeid , KEYCXX) 362KEYWORD(using , KEYCXX) 363KEYWORD(virtual , KEYCXX) 364KEYWORD(wchar_t , WCHARSUPPORT) 365 366// C++ 2.5p2: Alternative Representations. 367CXX_KEYWORD_OPERATOR(and , ampamp) 368CXX_KEYWORD_OPERATOR(and_eq , ampequal) 369CXX_KEYWORD_OPERATOR(bitand , amp) 370CXX_KEYWORD_OPERATOR(bitor , pipe) 371CXX_KEYWORD_OPERATOR(compl , tilde) 372CXX_KEYWORD_OPERATOR(not , exclaim) 373CXX_KEYWORD_OPERATOR(not_eq , exclaimequal) 374CXX_KEYWORD_OPERATOR(or , pipepipe) 375CXX_KEYWORD_OPERATOR(or_eq , pipeequal) 376CXX_KEYWORD_OPERATOR(xor , caret) 377CXX_KEYWORD_OPERATOR(xor_eq , caretequal) 378 379// C99 Keywords. 380C99_KEYWORD(restrict , 0) 381C99_KEYWORD(inline , KEYCXX|KEYGNU) 382 383 384// C++11 keywords 385CXX11_KEYWORD(alignas , KEYC2X) 386// alignof and _Alignof return the required ABI alignment 387CXX11_UNARY_EXPR_OR_TYPE_TRAIT(alignof, AlignOf, KEYC2X) 388CXX11_KEYWORD(char16_t , KEYNOMS18) 389CXX11_KEYWORD(char32_t , KEYNOMS18) 390CXX11_KEYWORD(constexpr , 0) 391CXX11_KEYWORD(decltype , 0) 392CXX11_KEYWORD(noexcept , 0) 393CXX11_KEYWORD(nullptr , KEYC2X) 394CXX11_KEYWORD(static_assert , KEYMSCOMPAT|KEYC2X) 395CXX11_KEYWORD(thread_local , KEYC2X) 396 397// C++20 / coroutines TS keywords 398COROUTINES_KEYWORD(co_await) 399COROUTINES_KEYWORD(co_return) 400COROUTINES_KEYWORD(co_yield) 401 402// C++ modules TS keywords 403MODULES_KEYWORD(module) 404MODULES_KEYWORD(import) 405 406// C++20 keywords. 407CXX20_KEYWORD(consteval , 0) 408CXX20_KEYWORD(constinit , 0) 409CXX20_KEYWORD(concept , 0) 410CXX20_KEYWORD(requires , 0) 411 412// Not a CXX20_KEYWORD because it is disabled by -fno-char8_t. 413KEYWORD(char8_t , CHAR8SUPPORT) 414 415// C11 Extension 416KEYWORD(_Float16 , KEYALL) 417 418// C2x keywords 419C2X_KEYWORD(typeof , KEYGNU) 420C2X_KEYWORD(typeof_unqual , 0) 421 422// ISO/IEC JTC1 SC22 WG14 N1169 Extension 423KEYWORD(_Accum , KEYNOCXX) 424KEYWORD(_Fract , KEYNOCXX) 425KEYWORD(_Sat , KEYNOCXX) 426 427// GNU Extensions (in impl-reserved namespace) 428KEYWORD(_Decimal32 , KEYALL) 429KEYWORD(_Decimal64 , KEYALL) 430KEYWORD(_Decimal128 , KEYALL) 431KEYWORD(__null , KEYCXX) 432// __alignof returns the preferred alignment of a type, the alignment 433// clang will attempt to give an object of the type if allowed by ABI. 434UNARY_EXPR_OR_TYPE_TRAIT(__alignof, PreferredAlignOf, KEYALL) 435KEYWORD(__attribute , KEYALL) 436KEYWORD(__builtin_choose_expr , KEYALL) 437KEYWORD(__builtin_offsetof , KEYALL) 438KEYWORD(__builtin_FILE , KEYALL) 439KEYWORD(__builtin_FUNCTION , KEYALL) 440KEYWORD(__builtin_LINE , KEYALL) 441KEYWORD(__builtin_COLUMN , KEYALL) 442KEYWORD(__builtin_source_location , KEYCXX) 443 444// __builtin_types_compatible_p is a GNU C extension that we handle like a C++ 445// type trait. 446TYPE_TRAIT_2(__builtin_types_compatible_p, TypeCompatible, KEYNOCXX) 447KEYWORD(__builtin_va_arg , KEYALL) 448KEYWORD(__extension__ , KEYALL) 449KEYWORD(__float128 , KEYALL) 450KEYWORD(__ibm128 , KEYALL) 451KEYWORD(__imag , KEYALL) 452KEYWORD(__int128 , KEYALL) 453KEYWORD(__label__ , KEYALL) 454KEYWORD(__real , KEYALL) 455KEYWORD(__thread , KEYALL) 456KEYWORD(__FUNCTION__ , KEYALL) 457KEYWORD(__PRETTY_FUNCTION__ , KEYALL) 458KEYWORD(__auto_type , KEYALL) 459 460// MS Extensions 461KEYWORD(__FUNCDNAME__ , KEYMS) 462KEYWORD(__FUNCSIG__ , KEYMS) 463KEYWORD(L__FUNCTION__ , KEYMS) 464KEYWORD(L__FUNCSIG__ , KEYMS) 465TYPE_TRAIT_1(__is_interface_class, IsInterfaceClass, KEYMS) 466TYPE_TRAIT_1(__is_sealed, IsSealed, KEYMS) 467 468// MSVC12.0 / VS2013 Type Traits 469TYPE_TRAIT_1(__is_destructible, IsDestructible, KEYALL) 470TYPE_TRAIT_1(__is_trivially_destructible, IsTriviallyDestructible, KEYCXX) 471TYPE_TRAIT_1(__is_nothrow_destructible, IsNothrowDestructible, KEYALL) 472TYPE_TRAIT_2(__is_nothrow_assignable, IsNothrowAssignable, KEYCXX) 473TYPE_TRAIT_N(__is_constructible, IsConstructible, KEYCXX) 474TYPE_TRAIT_N(__is_nothrow_constructible, IsNothrowConstructible, KEYCXX) 475 476// MSVC14.0 / VS2015 Type Traits 477TYPE_TRAIT_2(__is_assignable, IsAssignable, KEYCXX) 478 479// MSVC Type Traits of unknown vintage 480TYPE_TRAIT_1(__has_nothrow_move_assign, HasNothrowMoveAssign, KEYCXX) 481TYPE_TRAIT_1(__has_trivial_move_assign, HasTrivialMoveAssign, KEYCXX) 482TYPE_TRAIT_1(__has_trivial_move_constructor, HasTrivialMoveConstructor, KEYCXX) 483 484// GNU and MS Type Traits 485TYPE_TRAIT_1(__has_nothrow_assign, HasNothrowAssign, KEYCXX) 486TYPE_TRAIT_1(__has_nothrow_copy, HasNothrowCopy, KEYCXX) 487TYPE_TRAIT_1(__has_nothrow_constructor, HasNothrowConstructor, KEYCXX) 488TYPE_TRAIT_1(__has_trivial_assign, HasTrivialAssign, KEYCXX) 489TYPE_TRAIT_1(__has_trivial_copy, HasTrivialCopy, KEYCXX) 490TYPE_TRAIT_1(__has_trivial_constructor, HasTrivialDefaultConstructor, KEYCXX) 491TYPE_TRAIT_1(__has_trivial_destructor, HasTrivialDestructor, KEYCXX) 492TYPE_TRAIT_1(__has_virtual_destructor, HasVirtualDestructor, KEYCXX) 493TYPE_TRAIT_1(__is_abstract, IsAbstract, KEYCXX) 494TYPE_TRAIT_1(__is_aggregate, IsAggregate, KEYCXX) 495TYPE_TRAIT_2(__is_base_of, IsBaseOf, KEYCXX) 496TYPE_TRAIT_1(__is_class, IsClass, KEYCXX) 497TYPE_TRAIT_2(__is_convertible_to, IsConvertibleTo, KEYCXX) 498TYPE_TRAIT_1(__is_empty, IsEmpty, KEYCXX) 499TYPE_TRAIT_1(__is_enum, IsEnum, KEYCXX) 500TYPE_TRAIT_1(__is_final, IsFinal, KEYCXX) 501TYPE_TRAIT_1(__is_literal, IsLiteral, KEYCXX) 502// Name for GCC 4.6 compatibility - people have already written libraries using 503// this name unfortunately. 504ALIAS("__is_literal_type", __is_literal, KEYCXX) 505TYPE_TRAIT_1(__is_pod, IsPOD, KEYCXX) 506TYPE_TRAIT_1(__is_polymorphic, IsPolymorphic, KEYCXX) 507TYPE_TRAIT_1(__is_standard_layout, IsStandardLayout, KEYCXX) 508TYPE_TRAIT_1(__is_trivial, IsTrivial, KEYCXX) 509TYPE_TRAIT_2(__is_trivially_assignable, IsTriviallyAssignable, KEYCXX) 510TYPE_TRAIT_N(__is_trivially_constructible, IsTriviallyConstructible, KEYCXX) 511TYPE_TRAIT_1(__is_trivially_copyable, IsTriviallyCopyable, KEYCXX) 512TYPE_TRAIT_1(__is_union, IsUnion, KEYCXX) 513TYPE_TRAIT_1(__has_unique_object_representations, 514 HasUniqueObjectRepresentations, KEYCXX) 515 516#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) KEYWORD(__##Trait, KEYCXX) 517#include "clang/Basic/TransformTypeTraits.def" 518 519// Clang-only C++ Type Traits 520TYPE_TRAIT_1(__is_trivially_relocatable, IsTriviallyRelocatable, KEYCXX) 521TYPE_TRAIT_1(__is_bounded_array, IsBoundedArray, KEYCXX) 522TYPE_TRAIT_1(__is_unbounded_array, IsUnboundedArray, KEYCXX) 523TYPE_TRAIT_1(__is_nullptr, IsNullPointer, KEYCXX) 524TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX) 525TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX) 526TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX) 527 528// Embarcadero Expression Traits 529EXPRESSION_TRAIT(__is_lvalue_expr, IsLValueExpr, KEYCXX) 530EXPRESSION_TRAIT(__is_rvalue_expr, IsRValueExpr, KEYCXX) 531 532// Embarcadero Unary Type Traits 533TYPE_TRAIT_1(__is_arithmetic, IsArithmetic, KEYCXX) 534TYPE_TRAIT_1(__is_floating_point, IsFloatingPoint, KEYCXX) 535TYPE_TRAIT_1(__is_integral, IsIntegral, KEYCXX) 536TYPE_TRAIT_1(__is_complete_type, IsCompleteType, KEYCXX) 537TYPE_TRAIT_1(__is_void, IsVoid, KEYCXX) 538TYPE_TRAIT_1(__is_array, IsArray, KEYCXX) 539TYPE_TRAIT_1(__is_function, IsFunction, KEYCXX) 540TYPE_TRAIT_1(__is_reference, IsReference, KEYCXX) 541TYPE_TRAIT_1(__is_lvalue_reference, IsLvalueReference, KEYCXX) 542TYPE_TRAIT_1(__is_rvalue_reference, IsRvalueReference, KEYCXX) 543TYPE_TRAIT_1(__is_fundamental, IsFundamental, KEYCXX) 544TYPE_TRAIT_1(__is_object, IsObject, KEYCXX) 545TYPE_TRAIT_1(__is_scalar, IsScalar, KEYCXX) 546TYPE_TRAIT_1(__is_compound, IsCompound, KEYCXX) 547TYPE_TRAIT_1(__is_pointer, IsPointer, KEYCXX) 548TYPE_TRAIT_1(__is_member_object_pointer, IsMemberObjectPointer, KEYCXX) 549TYPE_TRAIT_1(__is_member_function_pointer, IsMemberFunctionPointer, KEYCXX) 550TYPE_TRAIT_1(__is_member_pointer, IsMemberPointer, KEYCXX) 551TYPE_TRAIT_1(__is_const, IsConst, KEYCXX) 552TYPE_TRAIT_1(__is_volatile, IsVolatile, KEYCXX) 553TYPE_TRAIT_1(__is_signed, IsSigned, KEYCXX) 554TYPE_TRAIT_1(__is_unsigned, IsUnsigned, KEYCXX) 555 556// Embarcadero Binary Type Traits 557TYPE_TRAIT_2(__is_same, IsSame, KEYCXX) 558TYPE_TRAIT_2(__is_convertible, IsConvertible, KEYCXX) 559ARRAY_TYPE_TRAIT(__array_rank, ArrayRank, KEYCXX) 560ARRAY_TYPE_TRAIT(__array_extent, ArrayExtent, KEYCXX) 561// Name for GCC 6 compatibility. 562ALIAS("__is_same_as", __is_same, KEYCXX) 563 564// Apple Extension. 565KEYWORD(__private_extern__ , KEYALL) 566KEYWORD(__module_private__ , KEYALL) 567 568// Extension that will be enabled for Microsoft, Borland and PS4, but can be 569// disabled via '-fno-declspec'. 570KEYWORD(__declspec , 0) 571 572// Microsoft Extension. 573KEYWORD(__cdecl , KEYALL) 574KEYWORD(__stdcall , KEYALL) 575KEYWORD(__fastcall , KEYALL) 576KEYWORD(__thiscall , KEYALL) 577KEYWORD(__regcall , KEYALL) 578KEYWORD(__vectorcall , KEYALL) 579KEYWORD(__forceinline , KEYMS) 580KEYWORD(__unaligned , KEYMS) 581KEYWORD(__super , KEYMS) 582 583// OpenCL address space qualifiers 584KEYWORD(__global , KEYOPENCLC | KEYOPENCLCXX) 585KEYWORD(__local , KEYOPENCLC | KEYOPENCLCXX) 586KEYWORD(__constant , KEYOPENCLC | KEYOPENCLCXX) 587KEYWORD(__private , KEYOPENCLC | KEYOPENCLCXX) 588KEYWORD(__generic , KEYOPENCLC | KEYOPENCLCXX) 589ALIAS("global", __global , KEYOPENCLC | KEYOPENCLCXX) 590ALIAS("local", __local , KEYOPENCLC | KEYOPENCLCXX) 591ALIAS("constant", __constant , KEYOPENCLC | KEYOPENCLCXX) 592ALIAS("private", __private , KEYOPENCLC) 593ALIAS("generic", __generic , KEYOPENCLC | KEYOPENCLCXX) 594// OpenCL function qualifiers 595KEYWORD(__kernel , KEYOPENCLC | KEYOPENCLCXX) 596ALIAS("kernel", __kernel , KEYOPENCLC | KEYOPENCLCXX) 597// OpenCL access qualifiers 598KEYWORD(__read_only , KEYOPENCLC | KEYOPENCLCXX) 599KEYWORD(__write_only , KEYOPENCLC | KEYOPENCLCXX) 600KEYWORD(__read_write , KEYOPENCLC | KEYOPENCLCXX) 601ALIAS("read_only", __read_only , KEYOPENCLC | KEYOPENCLCXX) 602ALIAS("write_only", __write_only , KEYOPENCLC | KEYOPENCLCXX) 603ALIAS("read_write", __read_write , KEYOPENCLC | KEYOPENCLCXX) 604// OpenCL builtins 605KEYWORD(__builtin_astype , KEYOPENCLC | KEYOPENCLCXX) 606UNARY_EXPR_OR_TYPE_TRAIT(vec_step, VecStep, KEYOPENCLC | KEYOPENCLCXX | KEYALTIVEC | KEYZVECTOR) 607#define GENERIC_IMAGE_TYPE(ImgType, Id) KEYWORD(ImgType##_t, KEYOPENCLC | KEYOPENCLCXX) 608#include "clang/Basic/OpenCLImageTypes.def" 609KEYWORD(pipe , KEYOPENCLC | KEYOPENCLCXX) 610// C++ for OpenCL s2.3.1: addrspace_cast operator 611KEYWORD(addrspace_cast , KEYOPENCLCXX) 612 613// CUDA/HIP function attributes 614KEYWORD(__noinline__ , KEYCUDA) 615 616// HLSL keywords. 617KEYWORD(cbuffer , KEYHLSL) 618KEYWORD(tbuffer , KEYHLSL) 619KEYWORD(groupshared , KEYHLSL) 620 621// OpenMP Type Traits 622UNARY_EXPR_OR_TYPE_TRAIT(__builtin_omp_required_simd_align, OpenMPRequiredSimdAlign, KEYALL) 623 624// Borland Extensions. 625KEYWORD(__pascal , KEYALL) 626 627// Altivec Extension. 628KEYWORD(__vector , KEYALTIVEC|KEYZVECTOR) 629KEYWORD(__pixel , KEYALTIVEC) 630KEYWORD(__bool , KEYALTIVEC|KEYZVECTOR) 631 632// ARM NEON extensions. 633ALIAS("__fp16", half , KEYALL) 634KEYWORD(__bf16 , KEYALL) 635 636// OpenCL Extension. 637KEYWORD(half , HALFSUPPORT) 638 639// Objective-C ARC keywords. 640KEYWORD(__bridge , KEYOBJC) 641KEYWORD(__bridge_transfer , KEYOBJC) 642KEYWORD(__bridge_retained , KEYOBJC) 643KEYWORD(__bridge_retain , KEYOBJC) 644 645// Objective-C keywords. 646KEYWORD(__covariant , KEYOBJC) 647KEYWORD(__contravariant , KEYOBJC) 648KEYWORD(__kindof , KEYOBJC) 649 650// Alternate spelling for various tokens. There are GCC extensions in all 651// languages, but should not be disabled in strict conformance mode. 652ALIAS("__alignof__" , __alignof , KEYALL) 653ALIAS("__asm" , asm , KEYALL) 654ALIAS("__asm__" , asm , KEYALL) 655ALIAS("__attribute__", __attribute, KEYALL) 656ALIAS("__complex" , _Complex , KEYALL) 657ALIAS("__complex__" , _Complex , KEYALL) 658ALIAS("__const" , const , KEYALL) 659ALIAS("__const__" , const , KEYALL) 660ALIAS("__decltype" , decltype , KEYCXX) 661ALIAS("__imag__" , __imag , KEYALL) 662ALIAS("__inline" , inline , KEYALL) 663ALIAS("__inline__" , inline , KEYALL) 664ALIAS("__nullptr" , nullptr , KEYCXX) 665ALIAS("__real__" , __real , KEYALL) 666ALIAS("__restrict" , restrict , KEYALL) 667ALIAS("__restrict__" , restrict , KEYALL) 668ALIAS("__signed" , signed , KEYALL) 669ALIAS("__signed__" , signed , KEYALL) 670ALIAS("__typeof" , typeof , KEYALL) 671ALIAS("__typeof__" , typeof , KEYALL) 672ALIAS("__volatile" , volatile , KEYALL) 673ALIAS("__volatile__" , volatile , KEYALL) 674 675// Type nullability. 676KEYWORD(_Nonnull , KEYALL) 677KEYWORD(_Nullable , KEYALL) 678KEYWORD(_Nullable_result , KEYALL) 679KEYWORD(_Null_unspecified , KEYALL) 680 681// Microsoft extensions which should be disabled in strict conformance mode 682KEYWORD(__ptr64 , KEYMS) 683KEYWORD(__ptr32 , KEYMS) 684KEYWORD(__sptr , KEYMS) 685KEYWORD(__uptr , KEYMS) 686KEYWORD(__w64 , KEYMS) 687KEYWORD(__uuidof , KEYMS | KEYBORLAND) 688KEYWORD(__try , KEYMS | KEYBORLAND) 689KEYWORD(__finally , KEYMS | KEYBORLAND) 690KEYWORD(__leave , KEYMS | KEYBORLAND) 691KEYWORD(__int64 , KEYMS) 692KEYWORD(__if_exists , KEYMS) 693KEYWORD(__if_not_exists , KEYMS) 694KEYWORD(__single_inheritance , KEYMS) 695KEYWORD(__multiple_inheritance , KEYMS) 696KEYWORD(__virtual_inheritance , KEYMS) 697KEYWORD(__interface , KEYMS) 698ALIAS("__int8" , char , KEYMS) 699ALIAS("__int16" , short , KEYMS) 700ALIAS("__int32" , int , KEYMS) 701ALIAS("__wchar_t" , wchar_t , KEYMS) 702ALIAS("__builtin_alignof", __alignof , KEYMS) 703 704// Microsoft single-underscore prefixed aliases for double-underscore prefixed 705// keywords. 706ALIAS("_asm" , asm , KEYMS) 707ALIAS("_alignof" , __alignof , KEYMS) 708ALIAS("_cdecl" , __cdecl , KEYMS | KEYBORLAND) 709ALIAS("_declspec" , __declspec , KEYMS) 710ALIAS("_fastcall" , __fastcall , KEYMS | KEYBORLAND) 711ALIAS("_finally" , __finally , KEYMSCOMPAT) 712ALIAS("_forceinline" , __forceinline, KEYMSCOMPAT) 713ALIAS("_inline" , inline , KEYMS) 714ALIAS("_int8" , char , KEYMS) 715ALIAS("_int16" , short , KEYMS) 716ALIAS("_int32" , int , KEYMS) 717ALIAS("_int64" , __int64 , KEYMS) 718ALIAS("_leave" , __leave , KEYMSCOMPAT) 719ALIAS("_multiple_inheritance", __multiple_inheritance, KEYMSCOMPAT) 720ALIAS("_ptr32" , __ptr32 , KEYMSCOMPAT) 721ALIAS("_ptr64" , __ptr64 , KEYMSCOMPAT) 722ALIAS("_restrict" , restrict , KEYMSCOMPAT) 723ALIAS("_stdcall" , __stdcall , KEYMS | KEYBORLAND) 724ALIAS("_thiscall" , __thiscall , KEYMS) 725ALIAS("_try" , __try , KEYMSCOMPAT) 726ALIAS("_vectorcall" , __vectorcall , KEYMS) 727ALIAS("_unaligned" , __unaligned , KEYMSCOMPAT) 728ALIAS("_uptr" , __uptr , KEYMSCOMPAT) 729ALIAS("_uuidof" , __uuidof , KEYMS | KEYBORLAND) 730ALIAS("_virtual_inheritance", __virtual_inheritance, KEYMSCOMPAT) 731ALIAS("_w64" , __w64 , KEYMSCOMPAT) 732 733// Borland Extensions which should be disabled in strict conformance mode. 734ALIAS("_pascal" , __pascal , KEYBORLAND) 735 736// Clang Extensions. 737KEYWORD(__builtin_convertvector , KEYALL) 738ALIAS("__char16_t" , char16_t , KEYCXX) 739ALIAS("__char32_t" , char32_t , KEYCXX) 740KEYWORD(__builtin_bit_cast , KEYALL) 741KEYWORD(__builtin_available , KEYALL) 742KEYWORD(__builtin_sycl_unique_stable_name, KEYSYCL) 743 744// Clang-specific keywords enabled only in testing. 745TESTING_KEYWORD(__unknown_anytype , KEYALL) 746 747 748//===----------------------------------------------------------------------===// 749// Objective-C @-preceded keywords. 750//===----------------------------------------------------------------------===// 751 752// These have meaning after an '@' in Objective-C mode. These define enums in 753// the tok::objc_* namespace. 754 755OBJC_AT_KEYWORD(not_keyword) 756OBJC_AT_KEYWORD(class) 757OBJC_AT_KEYWORD(compatibility_alias) 758OBJC_AT_KEYWORD(defs) 759OBJC_AT_KEYWORD(encode) 760OBJC_AT_KEYWORD(end) 761OBJC_AT_KEYWORD(implementation) 762OBJC_AT_KEYWORD(interface) 763OBJC_AT_KEYWORD(private) 764OBJC_AT_KEYWORD(protected) 765OBJC_AT_KEYWORD(protocol) 766OBJC_AT_KEYWORD(public) 767OBJC_AT_KEYWORD(selector) 768OBJC_AT_KEYWORD(throw) 769OBJC_AT_KEYWORD(try) 770OBJC_AT_KEYWORD(catch) 771OBJC_AT_KEYWORD(finally) 772OBJC_AT_KEYWORD(synchronized) 773OBJC_AT_KEYWORD(autoreleasepool) 774 775OBJC_AT_KEYWORD(property) 776OBJC_AT_KEYWORD(package) 777OBJC_AT_KEYWORD(required) 778OBJC_AT_KEYWORD(optional) 779OBJC_AT_KEYWORD(synthesize) 780OBJC_AT_KEYWORD(dynamic) 781OBJC_AT_KEYWORD(import) 782OBJC_AT_KEYWORD(available) 783 784// TODO: What to do about context-sensitive keywords like: 785// bycopy/byref/in/inout/oneway/out? 786 787ANNOTATION(cxxscope) // annotation for a C++ scope spec, e.g. "::foo::bar::" 788ANNOTATION(typename) // annotation for a C typedef name, a C++ (possibly 789 // qualified) typename, e.g. "foo::MyClass", or 790 // template-id that names a type ("std::vector<int>") 791ANNOTATION(template_id) // annotation for a C++ template-id that names a 792 // function template specialization (not a type), 793 // e.g., "std::swap<int>", or a type-constraint (which 794 // might not have explicit template arguments), 795 // e.g. "C", "C<int>". 796ANNOTATION(non_type) // annotation for a single non-type declaration 797ANNOTATION(non_type_undeclared) // annotation for an undeclared identifier that 798 // was assumed to be an ADL-only function name 799ANNOTATION(non_type_dependent) // annotation for an assumed non-type member of 800 // a dependent base class 801ANNOTATION(overload_set) // annotation for an unresolved overload set 802ANNOTATION(primary_expr) // annotation for a primary expression, used when 803 // tentatively parsing a lambda init-capture or ObjC 804 // message send 805ANNOTATION(decltype) // annotation for a decltype expression, 806 // e.g., "decltype(foo.bar())" 807 808// Annotation for #pragma unused(...) 809// For each argument inside the parentheses the pragma handler will produce 810// one 'pragma_unused' annotation token followed by the argument token. 811PRAGMA_ANNOTATION(pragma_unused) 812 813// Annotation for #pragma GCC visibility... 814// The lexer produces these so that they only take effect when the parser 815// handles them. 816PRAGMA_ANNOTATION(pragma_vis) 817 818// Annotation for #pragma pack... 819// The lexer produces these so that they only take effect when the parser 820// handles them. 821PRAGMA_ANNOTATION(pragma_pack) 822 823// Annotation for #pragma clang __debug parser_crash... 824// The lexer produces these so that they only take effect when the parser 825// handles them. 826PRAGMA_ANNOTATION(pragma_parser_crash) 827 828// Annotation for #pragma clang __debug captured... 829// The lexer produces these so that they only take effect when the parser 830// handles them. 831PRAGMA_ANNOTATION(pragma_captured) 832 833// Annotation for #pragma clang __debug dump... 834// The lexer produces these so that the parser and semantic analysis can 835// look up and dump the operand. 836PRAGMA_ANNOTATION(pragma_dump) 837 838// Annotation for #pragma ms_struct... 839// The lexer produces these so that they only take effect when the parser 840// handles them. 841PRAGMA_ANNOTATION(pragma_msstruct) 842 843// Annotation for #pragma align... 844// The lexer produces these so that they only take effect when the parser 845// handles them. 846PRAGMA_ANNOTATION(pragma_align) 847 848// Annotation for #pragma weak id 849// The lexer produces these so that they only take effect when the parser 850// handles them. 851PRAGMA_ANNOTATION(pragma_weak) 852 853// Annotation for #pragma weak id = id 854// The lexer produces these so that they only take effect when the parser 855// handles them. 856PRAGMA_ANNOTATION(pragma_weakalias) 857 858// Annotation for #pragma redefine_extname... 859// The lexer produces these so that they only take effect when the parser 860// handles them. 861PRAGMA_ANNOTATION(pragma_redefine_extname) 862 863// Annotation for #pragma STDC FP_CONTRACT... 864// The lexer produces these so that they only take effect when the parser 865// handles them. 866PRAGMA_ANNOTATION(pragma_fp_contract) 867 868// Annotations for #pragma STDC FENV_ACCESS and #pragma fenv_access (MS compat) 869// The lexer produces these so that they only take effect when the parser 870// handles them. 871PRAGMA_ANNOTATION(pragma_fenv_access) 872PRAGMA_ANNOTATION(pragma_fenv_access_ms) 873 874// Annotation for #pragma STDC FENV_ROUND 875// The lexer produces these so that they only take effect when the parser 876// handles them. 877PRAGMA_ANNOTATION(pragma_fenv_round) 878 879// Annotation for #pragma float_control 880// The lexer produces these so that they only take effect when the parser 881// handles them. 882PRAGMA_ANNOTATION(pragma_float_control) 883 884// Annotation for #pragma pointers_to_members... 885// The lexer produces these so that they only take effect when the parser 886// handles them. 887PRAGMA_ANNOTATION(pragma_ms_pointers_to_members) 888 889// Annotation for #pragma vtordisp... 890// The lexer produces these so that they only take effect when the parser 891// handles them. 892PRAGMA_ANNOTATION(pragma_ms_vtordisp) 893 894// Annotation for all microsoft #pragmas... 895// The lexer produces these so that they only take effect when the parser 896// handles them. 897PRAGMA_ANNOTATION(pragma_ms_pragma) 898 899// Annotation for #pragma OPENCL EXTENSION... 900// The lexer produces these so that they only take effect when the parser 901// handles them. 902PRAGMA_ANNOTATION(pragma_opencl_extension) 903 904// Annotations for OpenMP pragma directives - #pragma omp ... 905// The parser produces this annotation token when it parses an [[omp::*]] 906// attribute. The tokens from the attribute argument list are replayed to the 907// token stream with this leading token (and a trailing pragma_openmp_end) so 908// that the parser can reuse the OpenMP parsing logic but still be able to 909// distinguish between a real pragma and a converted pragma. It is not marked 910// as a PRAGMA_ANNOTATION because it doesn't get generated from a #pragma. 911ANNOTATION(attr_openmp) 912// The lexer produces these so that they only take effect when the parser 913// handles #pragma omp ... directives. 914PRAGMA_ANNOTATION(pragma_openmp) 915PRAGMA_ANNOTATION(pragma_openmp_end) 916 917// Annotations for loop pragma directives #pragma clang loop ... 918// The lexer produces these so that they only take effect when the parser 919// handles #pragma loop ... directives. 920PRAGMA_ANNOTATION(pragma_loop_hint) 921 922PRAGMA_ANNOTATION(pragma_fp) 923 924// Annotation for the attribute pragma directives - #pragma clang attribute ... 925PRAGMA_ANNOTATION(pragma_attribute) 926 927// Annotation for the riscv pragma directives - #pragma clang riscv intrinsic ... 928PRAGMA_ANNOTATION(pragma_riscv) 929 930// Annotations for module import translated from #include etc. 931ANNOTATION(module_include) 932ANNOTATION(module_begin) 933ANNOTATION(module_end) 934 935// Annotation for a header_name token that has been looked up and transformed 936// into the name of a header unit. 937ANNOTATION(header_unit) 938 939#undef PRAGMA_ANNOTATION 940#undef ANNOTATION 941#undef TESTING_KEYWORD 942#undef OBJC_AT_KEYWORD 943#undef CXX_KEYWORD_OPERATOR 944#undef PPKEYWORD 945#undef ALIAS 946#undef EXPRESSION_TRAIT 947#undef CXX11_UNARY_EXPR_OR_TYPE_TRAIT 948#undef UNARY_EXPR_OR_TYPE_TRAIT 949#undef ARRAY_TYPE_TRAIT 950#undef TYPE_TRAIT_N 951#undef TYPE_TRAIT_2 952#undef TYPE_TRAIT_1 953#undef TYPE_TRAIT 954#undef CXX20_KEYWORD 955#undef CXX11_KEYWORD 956#undef KEYWORD 957#undef PUNCTUATOR 958#undef TOK 959#undef C99_KEYWORD 960#undef C2X_KEYWORD 961