clang
6.0.0
|
TokenLexer - This implements a lexer that returns tokens from a macro body or token stream instead of lexing from a character buffer. More...
#include "clang/Lex/TokenLexer.h"
Public Member Functions | |
TokenLexer (Token &Tok, SourceLocation ILEnd, MacroInfo *MI, MacroArgs *ActualArgs, Preprocessor &pp) | |
Create a TokenLexer for the specified macro with the specified actual arguments. More... | |
TokenLexer (const Token *TokArray, unsigned NumToks, bool DisableExpansion, bool ownsTokens, Preprocessor &pp) | |
Create a TokenLexer for the specified token stream. More... | |
TokenLexer (const TokenLexer &)=delete | |
TokenLexer & | operator= (const TokenLexer &)=delete |
~TokenLexer () | |
void | Init (Token &Tok, SourceLocation ILEnd, MacroInfo *MI, MacroArgs *ActualArgs) |
Init - Initialize this TokenLexer to expand from the specified macro with the specified argument information. More... | |
void | Init (const Token *TokArray, unsigned NumToks, bool DisableMacroExpansion, bool OwnsTokens) |
Init - Initialize this TokenLexer with the specified token stream. More... | |
unsigned | isNextTokenLParen () const |
isNextTokenLParen - If the next token lexed will pop this macro off the expansion stack, return 2. More... | |
bool | Lex (Token &Tok) |
Lex - Lex and return a token from this macro stream. More... | |
bool | isParsingPreprocessorDirective () const |
isParsingPreprocessorDirective - Return true if we are in the middle of a preprocessor directive. More... | |
Friends | |
class | Preprocessor |
TokenLexer - This implements a lexer that returns tokens from a macro body or token stream instead of lexing from a character buffer.
This is used for macro expansion and _Pragma handling, for example.
Definition at line 31 of file TokenLexer.h.
|
inline |
Create a TokenLexer for the specified macro with the specified actual arguments.
Note that this ctor takes ownership of the ActualArgs pointer. ILEnd specifies the location of the ')' for a function-like macro or the identifier for an object-like macro.
Definition at line 107 of file TokenLexer.h.
References Init().
Referenced by TokenLexer().
|
inline |
Create a TokenLexer for the specified token stream.
If 'OwnsTokens' is specified, this takes ownership of the tokens and delete[]'s them when the token lexer is empty.
Definition at line 116 of file TokenLexer.h.
References Init(), operator=(), and TokenLexer().
|
delete |
|
inline |
Definition at line 124 of file TokenLexer.h.
References Init(), isNextTokenLParen(), isParsingPreprocessorDirective(), Lex(), clang::Result, and clang::format::Tok.
void TokenLexer::Init | ( | Token & | Tok, |
SourceLocation | ELEnd, | ||
MacroInfo * | MI, | ||
MacroArgs * | Actuals | ||
) |
Init - Initialize this TokenLexer to expand from the specified macro with the specified argument information.
Create a TokenLexer for the specified macro with the specified actual arguments.
Note that this ctor takes ownership of the ActualArgs pointer. ILEnd specifies the location of the ')' for a function-like macro or the identifier for an object-like macro.
Note that this ctor takes ownership of the ActualArgs pointer.
Definition at line 39 of file TokenLexer.cpp.
References clang::SourceManager::createExpansionLoc(), clang::MacroInfo::DisableMacro(), clang::MacroInfo::getDefinitionLength(), clang::SourceManager::getExpansionLoc(), clang::Token::getLocation(), clang::SourceManager::getNextLocalOffset(), clang::MacroInfo::getNumParams(), clang::Preprocessor::getSourceManager(), clang::Token::hasLeadingSpace(), clang::Token::isAtStartOfLine(), clang::MacroInfo::isFunctionLike(), clang::SourceLocation::isValid(), SM, clang::MacroInfo::tokens_begin(), and clang::MacroInfo::tokens_end().
Referenced by TokenLexer(), and ~TokenLexer().
void TokenLexer::Init | ( | const Token * | TokArray, |
unsigned | NumToks, | ||
bool | disableMacroExpansion, | ||
bool | ownsTokens | ||
) |
Init - Initialize this TokenLexer with the specified token stream.
Create a TokenLexer for the specified token stream.
This does not take ownership of the specified token vector.
DisableExpansion is true when macro expansion of tokens lexed from this stream should be disabled.
This does not take ownership of the specified token vector.
Definition at line 94 of file TokenLexer.cpp.
References clang::Token::CommaAfterElided, clang::MacroArgs::destroy(), clang::Preprocessor::Diag(), clang::VAOptExpansionContext::getEOFTok(), clang::Preprocessor::getLangOpts(), clang::VAOptExpansionContext::getLeadingSpaceForStringifiedToken(), clang::VAOptExpansionContext::getNumberOfTokensPriorToVAOpt(), clang::MacroInfo::getNumParams(), clang::VAOptExpansionContext::getVAOptLoc(), clang::VAOptExpansionContext::hasCharifyBefore(), clang::Token::hasLeadingSpace(), clang::MacroArgs::invokedWithVariadicArgument(), clang::Token::isAtStartOfLine(), clang::MacroInfo::isVariadic(), clang::Token::LeadingSpace, clang::Token::setFlag(), clang::Token::StringifiedInMacro, and clang::MacroArgs::StringifyArgument().
unsigned TokenLexer::isNextTokenLParen | ( | ) | const |
isNextTokenLParen - If the next token lexed will pop this macro off the expansion stack, return 2.
If the next unexpanded token is a '(', return 1, otherwise return 0.
Definition at line 889 of file TokenLexer.cpp.
References clang::Token::is().
Referenced by ~TokenLexer().
bool TokenLexer::isParsingPreprocessorDirective | ( | ) | const |
isParsingPreprocessorDirective - Return true if we are in the middle of a preprocessor directive.
Definition at line 898 of file TokenLexer.cpp.
References clang::Preprocessor::Diag(), clang::MacroInfo::EnableMacro(), clang::SourceLocation::getLocWithOffset(), clang::Preprocessor::getSourceManager(), clang::Preprocessor::HandleMicrosoftCommentPaste(), clang::Token::is(), clang::SourceLocation::isFileID(), clang::SourceManager::isInSLocAddrSpace(), clang::SourceLocation::isValid(), and SM.
Referenced by ~TokenLexer().
Lex - Lex and return a token from this macro stream.
Definition at line 586 of file TokenLexer.cpp.
References clang::Token::clearFlag(), clang::SourceManager::createExpansionLoc(), clang::MacroInfo::EnableMacro(), clang::Token::getIdentifierInfo(), clang::Preprocessor::getLangOpts(), clang::Token::getLength(), clang::Token::getLocation(), clang::Preprocessor::getSourceManager(), clang::IdentifierInfo::getTokenID(), clang::Preprocessor::HandleEndOfTokenLexer(), clang::Preprocessor::HandleIdentifier(), clang::Preprocessor::HandlePoisonedIdentifier(), clang::Token::is(), clang::Token::isAnnotation(), clang::SourceManager::isBeforeInSLocAddrSpace(), clang::IdentifierInfo::isHandleIdentifierCase(), clang::IdentifierInfo::isPoisoned(), clang::SourceLocation::isValid(), isWideStringLiteralFromMacro(), clang::Token::LeadingEmptyMacro, clang::Token::LeadingSpace, clang::Token::setFlag(), clang::Token::setFlagValue(), clang::Token::setKind(), clang::Token::setLocation(), SM, clang::Token::StartOfLine, clang::Token::startToken(), and clang::format::Tok.
Referenced by ~TokenLexer().
|
delete |
Referenced by TokenLexer().
|
friend |
Definition at line 32 of file TokenLexer.h.