clang API Documentation

Enumerations | Functions
clang::tok Namespace Reference

Enumerations

enum  TokenKind
 Provides a simple uniform namespace for tokens from all C languages. More...
enum  PPKeywordKind
 Provides a namespace for preprocessor keywords which start with a '#' at the beginning of the line. More...
enum  ObjCKeywordKind
 Provides a namespace for Objective-C keywords which start with an '@'. 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'. Returns NULL for other token kinds.
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.

Enumeration Type Documentation

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

Definition at line 41 of file TokenKinds.h.

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

Enumerator:
OOS_ON 
OOS_OFF 
OOS_DEFAULT 

Definition at line 49 of file TokenKinds.h.

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

Definition at line 33 of file TokenKinds.h.

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

Definition at line 25 of file TokenKinds.h.


Function Documentation

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 41 of file TokenKinds.cpp.

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

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 32 of file TokenKinds.cpp.

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

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 25 of file TokenKinds.cpp.

References TokNames.

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

bool clang::tok::isAnnotation ( TokenKind  K) [inline]

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

Definition at line 95 of file TokenKinds.h.

Referenced by clang::TokenValue::TokenValue().

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

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

Definition at line 73 of file TokenKinds.h.

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

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

Definition at line 87 of file TokenKinds.h.

References isStringLiteral().

Referenced by getNSNumberFactoryMethod(), and clang::TokenValue::TokenValue().

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 79 of file TokenKinds.h.

Referenced by isLiteral(), and clang::MacroArgs::StringifyArgument().