clang 20.0.0git
Enumerations | Functions
clang::tok Namespace Reference

Enumerations

enum  TokenKind : unsigned short { NUM_TOKENS }
 Provides a simple uniform namespace for tokens from all C languages. More...
 
enum  PPKeywordKind { NUM_PP_KEYWORDS }
 Provides a namespace for preprocessor keywords which start with a '#' at the beginning of the line. More...
 
enum  ObjCKeywordKind { NUM_OBJC_KEYWORDS }
 Provides a namespace for Objective-C keywords which start with an '@'. More...
 
enum  NotableIdentifierKind { NUM_NOTABLE_IDENTIFIERS }
 Provides a namespace for notable identifers such as float_t and double_t. More...
 
enum  OnOffSwitch { OOS_ON , OOS_OFF , OOS_DEFAULT }
 Defines the possible values of an on-off-switch (C99 6.10.6p2). More...
 

Functions

const char * getTokenName (TokenKind Kind) LLVM_READNONE
 Determines the name of a token as used within the front end.
 
const char * getPunctuatorSpelling (TokenKind Kind) LLVM_READNONE
 Determines the spelling of simple punctuation tokens like '!' or '', and returns NULL for literal and annotation tokens.
 
const char * getKeywordSpelling (TokenKind Kind) LLVM_READNONE
 Determines the spelling of simple keyword and contextual keyword tokens like 'int' and 'dynamic_cast'.
 
const char * getPPKeywordSpelling (PPKeywordKind Kind) LLVM_READNONE
 Returns the spelling of preprocessor keywords, such as "else".
 
bool isAnyIdentifier (TokenKind K)
 Return true if this is a raw identifier or an identifier kind.
 
bool isStringLiteral (TokenKind K)
 Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token.
 
bool isLiteral (TokenKind K)
 Return true if this is a "literal" kind, like a numeric constant, string, etc.
 
bool isAnnotation (TokenKind K)
 Return true if this is any of tok::annot_* kinds.
 
bool isPragmaAnnotation (TokenKind K)
 Return true if this is an annotation token representing a pragma.
 
constexpr bool isRegularKeywordAttribute (TokenKind K)
 

Enumeration Type Documentation

◆ NotableIdentifierKind

Provides a namespace for notable identifers such as float_t and double_t.

Enumerator
NUM_NOTABLE_IDENTIFIERS 

Definition at line 49 of file TokenKinds.h.

◆ ObjCKeywordKind

Provides a namespace for Objective-C keywords which start with an '@'.

Enumerator
NUM_OBJC_KEYWORDS 

Definition at line 41 of file TokenKinds.h.

◆ OnOffSwitch

Defines the possible values of an on-off-switch (C99 6.10.6p2).

Enumerator
OOS_ON 
OOS_OFF 
OOS_DEFAULT 

Definition at line 56 of file TokenKinds.h.

◆ PPKeywordKind

Provides a namespace for preprocessor keywords which start with a '#' at the beginning of the line.

Enumerator
NUM_PP_KEYWORDS 

Definition at line 33 of file TokenKinds.h.

◆ TokenKind

Provides a simple uniform namespace for tokens from all C languages.

Enumerator
NUM_TOKENS 

Definition at line 25 of file TokenKinds.h.

Function Documentation

◆ getKeywordSpelling()

const char * clang::tok::getKeywordSpelling ( TokenKind  Kind)

Determines the spelling of simple keyword and contextual keyword tokens like 'int' and 'dynamic_cast'.

Returns NULL for other token kinds.

Definition at line 40 of file TokenKinds.cpp.

Referenced by clang::syntax::createLeaf(), clang::Diagnostic::FormatDiagnostic(), and getIdentifier().

◆ getPPKeywordSpelling()

const char * clang::tok::getPPKeywordSpelling ( tok::PPKeywordKind  Kind)

Returns the spelling of preprocessor keywords, such as "else".

Definition at line 49 of file TokenKinds.cpp.

◆ getPunctuatorSpelling()

const char * clang::tok::getPunctuatorSpelling ( TokenKind  Kind)

Determines the spelling of simple punctuation tokens like '!' or '', and returns NULL for literal and annotation tokens.

This routine only retrieves the "simple" spelling of the token, and will not produce any alternative spellings (e.g., a digraph). For the actual spelling of a given Token, use Preprocessor::getSpelling().

Definition at line 31 of file TokenKinds.cpp.

Referenced by clang::syntax::createLeaf(), clang::MacroInfo::dump(), and clang::Diagnostic::FormatDiagnostic().

◆ getTokenName()

const char * clang::tok::getTokenName ( TokenKind  Kind)

Determines the name of a token as used within the front end.

The name of a token will be an internal name (such as "l_square") and should not be used as part of diagnostic messages.

Definition at line 24 of file TokenKinds.cpp.

References NUM_TOKENS, and TokNames.

Referenced by clang::syntax::Token::dumpForTests(), clang::Preprocessor::DumpToken(), clang::Diagnostic::FormatDiagnostic(), clang::Token::getName(), and clang::syntax::Token::str().

◆ isAnnotation()

bool clang::tok::isAnnotation ( TokenKind  K)

Return true if this is any of tok::annot_* kinds.

Definition at line 58 of file TokenKinds.cpp.

Referenced by clang::Token::isAnnotation(), and clang::TokenValue::TokenValue().

◆ isAnyIdentifier()

bool clang::tok::isAnyIdentifier ( TokenKind  K)
inline

Return true if this is a raw identifier or an identifier kind.

Definition at line 83 of file TokenKinds.h.

Referenced by clang::Token::isAnyIdentifier().

◆ isLiteral()

bool clang::tok::isLiteral ( TokenKind  K)
inline

Return true if this is a "literal" kind, like a numeric constant, string, etc.

Definition at line 97 of file TokenKinds.h.

References isStringLiteral().

Referenced by highlightLines(), clang::Token::isLiteral(), and clang::TokenValue::TokenValue().

◆ isPragmaAnnotation()

bool clang::tok::isPragmaAnnotation ( TokenKind  K)

Return true if this is an annotation token representing a pragma.

Definition at line 68 of file TokenKinds.cpp.

◆ isRegularKeywordAttribute()

constexpr bool clang::tok::isRegularKeywordAttribute ( TokenKind  K)
inlineconstexpr

Definition at line 110 of file TokenKinds.h.

References KEYWORD_ATTRIBUTE, and X.

Referenced by clang::Token::isRegularKeywordAttribute().

◆ isStringLiteral()

bool clang::tok::isStringLiteral ( TokenKind  K)
inline

Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token.

Definition at line 89 of file TokenKinds.h.

Referenced by clang::Sema::ExpandFunctionLocalPredefinedMacros(), getSpellingSlow(), isLiteral(), clang::format::FormatToken::isObjCAtKeyword(), clang::MacroArgs::StringifyArgument(), and clang::tokenIsLikeStringLiteral().