clang
3.7.0
|
#include <PreprocessorLexer.h>
Public Types | |
typedef SmallVectorImpl < PPConditionalInfo > ::const_iterator | conditional_iterator |
Iterator that traverses the current stack of preprocessor conditional directives (#if/#ifdef/#ifndef). More... | |
Public Member Functions | |
void | LexIncludeFilename (Token &Result) |
After the preprocessor has parsed a #include, lex and (potentially) macro expand the filename. More... | |
void | setParsingPreprocessorDirective (bool f) |
Inform the lexer whether or not we are currently lexing a preprocessor directive. More... | |
bool | isLexingRawMode () const |
Return true if this lexer is in raw mode or not. More... | |
Preprocessor * | getPP () const |
Return the preprocessor object for this lexer. More... | |
FileID | getFileID () const |
unsigned | getInitialNumSLocEntries () const |
Number of SLocEntries before lexing the file. More... | |
const FileEntry * | getFileEntry () const |
conditional_iterator | conditional_begin () const |
conditional_iterator | conditional_end () const |
Protected Member Functions | |
PreprocessorLexer (const PreprocessorLexer &)=delete | |
void | operator= (const PreprocessorLexer &)=delete |
PreprocessorLexer (Preprocessor *pp, FileID fid) | |
PreprocessorLexer () | |
virtual | ~PreprocessorLexer () |
virtual void | IndirectLex (Token &Result)=0 |
virtual SourceLocation | getSourceLocation ()=0 |
Return the source location for the next observable location. More... | |
void | pushConditionalLevel (SourceLocation DirectiveStart, bool WasSkipping, bool FoundNonSkip, bool FoundElse) |
void | pushConditionalLevel (const PPConditionalInfo &CI) |
bool | popConditionalLevel (PPConditionalInfo &CI) |
PPConditionalInfo & | peekConditionalLevel () |
Return the top of the conditional stack. More... | |
unsigned | getConditionalStackDepth () const |
Protected Attributes | |
Preprocessor * | PP |
const FileID | FID |
The SourceManager FileID corresponding to the file being lexed. More... | |
unsigned | InitialNumSLocEntries |
Number of SLocEntries before lexing the file. More... | |
bool | ParsingPreprocessorDirective |
True when parsing #XXX; turns '\n' into a tok::eod token. More... | |
bool | ParsingFilename |
True after #include; turns <xx> into a tok::angle_string_literal token. More... | |
bool | LexingRawMode |
True if in raw mode. More... | |
MultipleIncludeOpt | MIOpt |
A state machine that detects the #ifndef-wrapping a file idiom for the multiple-include optimization. More... | |
SmallVector< PPConditionalInfo, 4 > | ConditionalStack |
Information about the set of #if/#ifdef/#ifndef blocks we are currently in. More... | |
Friends | |
class | Preprocessor |
Definition at line 27 of file PreprocessorLexer.h.
typedef SmallVectorImpl<PPConditionalInfo>::const_iterator clang::PreprocessorLexer::conditional_iterator |
Iterator that traverses the current stack of preprocessor conditional directives (#if/#ifdef/#ifndef).
Definition at line 171 of file PreprocessorLexer.h.
|
protecteddelete |
|
protected |
Definition at line 22 of file PreprocessorLexer.cpp.
References clang::Preprocessor::getSourceManager(), InitialNumSLocEntries, and clang::SourceManager::local_sloc_entry_size().
|
inlineprotected |
Definition at line 78 of file PreprocessorLexer.h.
|
inlineprotectedvirtual |
Definition at line 84 of file PreprocessorLexer.h.
|
inline |
Definition at line 173 of file PreprocessorLexer.h.
References ConditionalStack.
|
inline |
Definition at line 176 of file PreprocessorLexer.h.
References ConditionalStack.
|
inlineprotected |
Definition at line 127 of file PreprocessorLexer.h.
References ConditionalStack.
Referenced by clang::Preprocessor::HandleDirective().
const FileEntry * PreprocessorLexer::getFileEntry | ( | ) | const |
getFileEntry - Return the FileEntry corresponding to this FileID. Like getFileID(), this only works for lexers with attached preprocessors.
Definition at line 56 of file PreprocessorLexer.cpp.
References clang::SourceManager::getFileEntryForID(), getFileID(), clang::Preprocessor::getSourceManager(), and PP.
Referenced by EvaluateHasIncludeNext(), clang::Preprocessor::HandlePragmaDependency(), and clang::Preprocessor::HandlePragmaSystemHeader().
|
inline |
Definition at line 153 of file PreprocessorLexer.h.
Referenced by getFileEntry(), clang::Preprocessor::HandleEndOfFile(), and clang::Preprocessor::LookupFile().
|
inline |
Number of SLocEntries before lexing the file.
Definition at line 160 of file PreprocessorLexer.h.
References InitialNumSLocEntries.
Referenced by clang::Preprocessor::HandleEndOfFile().
|
inline |
Return the preprocessor object for this lexer.
Definition at line 151 of file PreprocessorLexer.h.
References PP.
|
protectedpure virtual |
Return the source location for the next observable location.
Implemented in clang::Lexer, and clang::PTHLexer.
Referenced by clang::Preprocessor::HandleEndOfFile().
|
protectedpure virtual |
Implemented in clang::PTHLexer.
Referenced by LexIncludeFilename().
|
inline |
Return true if this lexer is in raw mode or not.
Definition at line 148 of file PreprocessorLexer.h.
References LexingRawMode.
Referenced by DecodeTrigraphChar(), and isEndOfBlockCommentWithEscapedNewLine().
void PreprocessorLexer::LexIncludeFilename | ( | Token & | Result | ) |
After the preprocessor has parsed a #include, lex and (potentially) macro expand the filename.
If the sequence parsed is not lexically legal, emit a diagnostic and return a result EOD token.
Definition at line 32 of file PreprocessorLexer.cpp.
References clang::Preprocessor::Diag(), clang::Token::getLocation(), IndirectLex(), clang::Token::is(), clang::Preprocessor::Lex(), LexingRawMode, ParsingFilename, ParsingPreprocessorDirective, and PP.
Referenced by EvaluateHasIncludeCommon(), clang::Preprocessor::HandlePragmaDependency(), and clang::Preprocessor::HandlePragmaIncludeAlias().
|
protecteddelete |
|
inlineprotected |
Return the top of the conditional stack.
Definition at line 122 of file PreprocessorLexer.h.
References ConditionalStack.
|
inlineprotected |
popConditionalLevel - Remove an entry off the top of the conditional stack, returning information about it. If the conditional stack is empty, this returns true and does not fill in the arguments.
Definition at line 113 of file PreprocessorLexer.h.
References ConditionalStack.
|
inlineprotected |
pushConditionalLevel - When we enter a #if directive, this keeps track of what we are currently in for diagnostic emission (e.g. #if with missing #endif).
Definition at line 97 of file PreprocessorLexer.h.
References ConditionalStack, clang::PPConditionalInfo::FoundElse, clang::PPConditionalInfo::FoundNonSkip, clang::PPConditionalInfo::IfLoc, and clang::PPConditionalInfo::WasSkipping.
|
inlineprotected |
Definition at line 106 of file PreprocessorLexer.h.
References ConditionalStack.
|
inline |
Inform the lexer whether or not we are currently lexing a preprocessor directive.
Definition at line 143 of file PreprocessorLexer.h.
References ParsingPreprocessorDirective.
|
friend |
Definition at line 74 of file PreprocessorLexer.h.
|
protected |
Information about the set of #if/#ifdef/#ifndef blocks we are currently in.
Definition at line 70 of file PreprocessorLexer.h.
Referenced by conditional_begin(), conditional_end(), getConditionalStackDepth(), peekConditionalLevel(), popConditionalLevel(), and pushConditionalLevel().
|
protected |
The SourceManager FileID corresponding to the file being lexed.
Definition at line 33 of file PreprocessorLexer.h.
Referenced by getFileID(), and clang::Lexer::getImmediateMacroName().
|
protected |
Number of SLocEntries before lexing the file.
Definition at line 36 of file PreprocessorLexer.h.
Referenced by getInitialNumSLocEntries(), and PreprocessorLexer().
|
protected |
True if in raw mode.
Raw mode disables interpretation of tokens and is a far faster mode to lex in than non-raw-mode. This flag:
Note that in raw mode that the PP pointer may be null.
Definition at line 62 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::HandleMicrosoftCommentPaste(), clang::Preprocessor::HandlePragmaPoison(), isLexingRawMode(), clang::PTHLexer::Lex(), clang::Lexer::Lexer(), clang::Lexer::LexFromRawLexer(), LexIncludeFilename(), and clang::Lexer::SetKeepWhitespaceMode().
|
protected |
A state machine that detects the #ifndef-wrapping a file idiom for the multiple-include optimization.
Definition at line 66 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::HandleDirective(), clang::Preprocessor::HandleEndOfFile(), and clang::PTHLexer::Lex().
|
protected |
True after #include; turns <xx> into a tok::angle_string_literal token.
Definition at line 47 of file PreprocessorLexer.h.
Referenced by clang::PTHLexer::DiscardToEndOfLine(), LexIncludeFilename(), and clang::Lexer::ReadToEndOfLine().
|
protected |
True when parsing #XXX; turns '\n' into a tok::eod token.
Definition at line 43 of file PreprocessorLexer.h.
Referenced by clang::Lexer::Create_PragmaLexer(), clang::PTHLexer::DiscardToEndOfLine(), clang::Preprocessor::HandleDirective(), clang::Preprocessor::HandleMicrosoftCommentPaste(), clang::PTHLexer::Lex(), LexIncludeFilename(), clang::Lexer::ReadToEndOfLine(), and setParsingPreprocessorDirective().
|
protected |
Definition at line 30 of file PreprocessorLexer.h.
Referenced by clang::Lexer::Diag(), getFileEntry(), getFileID(), getPP(), clang::Lexer::getSourceLocation(), clang::PTHLexer::Lex(), LexIncludeFilename(), clang::Lexer::ReadToEndOfLine(), and clang::Lexer::resetExtendedTokenMode().