clang API Documentation
#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). | |
Public Member Functions | |
| void | LexIncludeFilename (Token &Result) |
| void | setParsingPreprocessorDirective (bool f) |
| bool | isLexingRawMode () const |
| isLexingRawMode - Return true if this lexer is in raw mode or not. | |
| Preprocessor * | getPP () const |
| getPP - Return the preprocessor object for this lexer. | |
| FileID | getFileID () const |
| unsigned | getInitialNumSLocEntries () const |
| Number of SLocEntries before lexing the file. | |
| const FileEntry * | getFileEntry () const |
| conditional_iterator | conditional_begin () const |
| conditional_iterator | conditional_end () const |
Protected Member Functions | |
| PreprocessorLexer (const PreprocessorLexer &) | |
| void | operator= (const PreprocessorLexer &) |
| PreprocessorLexer (Preprocessor *pp, FileID fid) | |
| PreprocessorLexer () | |
| virtual | ~PreprocessorLexer () |
| virtual void | IndirectLex (Token &Result)=0 |
| virtual SourceLocation | getSourceLocation ()=0 |
| void | pushConditionalLevel (SourceLocation DirectiveStart, bool WasSkipping, bool FoundNonSkip, bool FoundElse) |
| void | pushConditionalLevel (const PPConditionalInfo &CI) |
| bool | popConditionalLevel (PPConditionalInfo &CI) |
| PPConditionalInfo & | peekConditionalLevel () |
| unsigned | getConditionalStackDepth () const |
Protected Attributes | |
| Preprocessor * | PP |
| const FileID | FID |
| The SourceManager FileID corresponding to the file being lexed. | |
| unsigned | InitialNumSLocEntries |
| Number of SLocEntries before lexing the file. | |
| bool | ParsingPreprocessorDirective |
| bool | ParsingFilename |
| bool | LexingRawMode |
| MultipleIncludeOpt | MIOpt |
| SmallVector< PPConditionalInfo, 4 > | ConditionalStack |
Friends | |
| class | Preprocessor |
Definition at line 26 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 168 of file PreprocessorLexer.h.
| clang::PreprocessorLexer::PreprocessorLexer | ( | const PreprocessorLexer & | ) | [protected] |
| PreprocessorLexer::PreprocessorLexer | ( | Preprocessor * | pp, |
| FileID | fid | ||
| ) | [protected] |
Definition at line 22 of file PreprocessorLexer.cpp.
References clang::Preprocessor::getSourceManager(), InitialNumSLocEntries, and clang::SourceManager::local_sloc_entry_size().
| clang::PreprocessorLexer::PreprocessorLexer | ( | ) | [inline, protected] |
Definition at line 76 of file PreprocessorLexer.h.
| virtual clang::PreprocessorLexer::~PreprocessorLexer | ( | ) | [inline, protected, virtual] |
Definition at line 82 of file PreprocessorLexer.h.
| conditional_iterator clang::PreprocessorLexer::conditional_begin | ( | ) | const [inline] |
Definition at line 170 of file PreprocessorLexer.h.
References ConditionalStack.
| conditional_iterator clang::PreprocessorLexer::conditional_end | ( | ) | const [inline] |
Definition at line 173 of file PreprocessorLexer.h.
References ConditionalStack.
| unsigned clang::PreprocessorLexer::getConditionalStackDepth | ( | ) | const [inline, protected] |
Definition at line 126 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 53 of file PreprocessorLexer.cpp.
References clang::SourceManager::getFileEntryForID(), getFileID(), clang::Preprocessor::getSourceManager(), and PP.
Referenced by clang::Preprocessor::HandlePragmaDependency(), and clang::Preprocessor::HandlePragmaSystemHeader().
| FileID clang::PreprocessorLexer::getFileID | ( | ) | const [inline] |
Definition at line 150 of file PreprocessorLexer.h.
Referenced by getFileEntry(), clang::Preprocessor::HandleEndOfFile(), and clang::Preprocessor::LookupFile().
| unsigned clang::PreprocessorLexer::getInitialNumSLocEntries | ( | ) | const [inline] |
Number of SLocEntries before lexing the file.
Definition at line 157 of file PreprocessorLexer.h.
References InitialNumSLocEntries.
Referenced by clang::Preprocessor::HandleEndOfFile().
| Preprocessor* clang::PreprocessorLexer::getPP | ( | ) | const [inline] |
getPP - Return the preprocessor object for this lexer.
Definition at line 148 of file PreprocessorLexer.h.
References PP.
| virtual SourceLocation clang::PreprocessorLexer::getSourceLocation | ( | ) | [protected, pure virtual] |
getSourceLocation - Return the source location for the next observable location.
Implemented in clang::Lexer, and clang::PTHLexer.
Referenced by clang::Preprocessor::HandleEndOfFile().
| virtual void clang::PreprocessorLexer::IndirectLex | ( | Token & | Result | ) | [protected, pure virtual] |
Implemented in clang::Lexer, and clang::PTHLexer.
Referenced by LexIncludeFilename().
| bool clang::PreprocessorLexer::isLexingRawMode | ( | ) | const [inline] |
isLexingRawMode - Return true if this lexer is in raw mode or not.
Definition at line 145 of file PreprocessorLexer.h.
References LexingRawMode.
Referenced by DecodeTrigraphChar(), and isEndOfBlockCommentWithEscapedNewLine().
| void PreprocessorLexer::LexIncludeFilename | ( | Token & | FilenameTok | ) |
LexIncludeFilename - 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.
LexIncludeFilename - After the preprocessor has parsed a #include, lex and (potentially) macro expand the filename.
Definition at line 32 of file PreprocessorLexer.cpp.
References clang::Preprocessor::Diag(), clang::Token::getLocation(), IndirectLex(), clang::Token::is(), ParsingFilename, ParsingPreprocessorDirective, and PP.
Referenced by EvaluateHasIncludeCommon(), and clang::Preprocessor::HandlePragmaDependency().
| void clang::PreprocessorLexer::operator= | ( | const PreprocessorLexer & | ) | [protected] |
| PPConditionalInfo& clang::PreprocessorLexer::peekConditionalLevel | ( | ) | [inline, protected] |
peekConditionalLevel - Return the top of the conditional stack. This requires that there be a conditional active.
Definition at line 121 of file PreprocessorLexer.h.
References ConditionalStack.
| bool clang::PreprocessorLexer::popConditionalLevel | ( | PPConditionalInfo & | CI | ) | [inline, protected] |
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 112 of file PreprocessorLexer.h.
References ConditionalStack.
| void clang::PreprocessorLexer::pushConditionalLevel | ( | SourceLocation | DirectiveStart, |
| bool | WasSkipping, | ||
| bool | FoundNonSkip, | ||
| bool | FoundElse | ||
| ) | [inline, protected] |
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 96 of file PreprocessorLexer.h.
References ConditionalStack, clang::PPConditionalInfo::FoundElse, clang::PPConditionalInfo::FoundNonSkip, clang::PPConditionalInfo::IfLoc, and clang::PPConditionalInfo::WasSkipping.
| void clang::PreprocessorLexer::pushConditionalLevel | ( | const PPConditionalInfo & | CI | ) | [inline, protected] |
Definition at line 105 of file PreprocessorLexer.h.
References ConditionalStack.
| void clang::PreprocessorLexer::setParsingPreprocessorDirective | ( | bool | f | ) | [inline] |
setParsingPreprocessorDirective - Inform the lexer whether or not we are currently lexing a preprocessor directive.
Definition at line 140 of file PreprocessorLexer.h.
References ParsingPreprocessorDirective.
friend class Preprocessor [friend] |
Reimplemented in clang::Lexer.
Definition at line 72 of file PreprocessorLexer.h.
SmallVector<PPConditionalInfo, 4> clang::PreprocessorLexer::ConditionalStack [protected] |
ConditionalStack - Information about the set of if/#ifdef/#ifndef blocks we are currently in.
Definition at line 68 of file PreprocessorLexer.h.
Referenced by conditional_begin(), conditional_end(), getConditionalStackDepth(), peekConditionalLevel(), popConditionalLevel(), and pushConditionalLevel().
const FileID clang::PreprocessorLexer::FID [protected] |
The SourceManager FileID corresponding to the file being lexed.
Definition at line 32 of file PreprocessorLexer.h.
Referenced by getFileID(), clang::Lexer::getImmediateMacroName(), clang::Lexer::isAtEndOfMacroExpansion(), and clang::Lexer::makeFileCharRange().
unsigned clang::PreprocessorLexer::InitialNumSLocEntries [protected] |
Number of SLocEntries before lexing the file.
Definition at line 35 of file PreprocessorLexer.h.
Referenced by getInitialNumSLocEntries(), and PreprocessorLexer().
bool clang::PreprocessorLexer::LexingRawMode [protected] |
LexingRawMode - True if in raw mode: This flag disables interpretation of tokens and is a far faster mode to lex in than non-raw-mode. This flag: 1. If EOF of the current lexer is found, the include stack isn't popped. 2. Identifier information is not looked up for identifier tokens. As an effect of this, implicit macro expansion is naturally disabled. 3. "#" tokens at the start of a line are treated as normal tokens, not implicitly transformed by the lexer. 4. All diagnostic messages are disabled. 5. No callbacks are made into the preprocessor.
Note that in raw mode that the PP pointer may be null.
Definition at line 60 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::HandleMicrosoftCommentPaste(), clang::Preprocessor::HandlePragmaPoison(), isLexingRawMode(), clang::PTHLexer::Lex(), clang::Lexer::Lexer(), clang::Lexer::LexFromRawLexer(), and clang::Lexer::SetKeepWhitespaceMode().
MultipleIncludeOpt clang::PreprocessorLexer::MIOpt [protected] |
MIOpt - This is a state machine that detects the #ifndef-wrapping a file idiom for the multiple-include optimization.
Definition at line 64 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::HandleDirective(), clang::Preprocessor::HandleEndOfFile(), and clang::PTHLexer::Lex().
bool clang::PreprocessorLexer::ParsingFilename [protected] |
ParsingFilename - True after #include: this 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().
bool clang::PreprocessorLexer::ParsingPreprocessorDirective [protected] |
ParsingPreprocessorDirective - This is true when parsing #XXX. This turns '
' 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().
Preprocessor* clang::PreprocessorLexer::PP [protected] |
Definition at line 29 of file PreprocessorLexer.h.
Referenced by clang::Lexer::Diag(), getFileEntry(), getFileID(), getPP(), clang::Lexer::getSourceLocation(), clang::PTHLexer::Lex(), LexIncludeFilename(), and clang::Lexer::ReadToEndOfLine().