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) |
After the preprocessor has parsed a #include, lex and (potentially) macro expand the filename. | |
void | setParsingPreprocessorDirective (bool f) |
Inform the lexer whether or not we are currently lexing a preprocessor directive. | |
bool | isLexingRawMode () const |
Return true if this lexer is in raw mode or not. | |
Preprocessor * | getPP () const |
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 &) LLVM_DELETED_FUNCTION | |
void | operator= (const PreprocessorLexer &) LLVM_DELETED_FUNCTION |
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. | |
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. | |
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 |
True when parsing #XXX; turns '\n' into a tok::eod token. | |
bool | ParsingFilename |
True after #include; turns <xx> into a tok::angle_string_literal token. | |
bool | LexingRawMode |
True if in raw mode. | |
MultipleIncludeOpt | MIOpt |
A state machine that detects the #ifndef-wrapping a file idiom for the multiple-include optimization. | |
SmallVector< PPConditionalInfo, 4 > | ConditionalStack |
Information about the set of #if/#ifdef/#ifndef blocks we are currently in. | |
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.
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 78 of file PreprocessorLexer.h.
virtual clang::PreprocessorLexer::~PreprocessorLexer | ( | ) | [inline, protected, virtual] |
Definition at line 84 of file PreprocessorLexer.h.
conditional_iterator clang::PreprocessorLexer::conditional_begin | ( | ) | const [inline] |
Definition at line 173 of file PreprocessorLexer.h.
References ConditionalStack.
conditional_iterator clang::PreprocessorLexer::conditional_end | ( | ) | const [inline] |
Definition at line 176 of file PreprocessorLexer.h.
References ConditionalStack.
unsigned clang::PreprocessorLexer::getConditionalStackDepth | ( | ) | const [inline, protected] |
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().
FileID clang::PreprocessorLexer::getFileID | ( | ) | const [inline] |
Definition at line 153 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 160 of file PreprocessorLexer.h.
References InitialNumSLocEntries.
Referenced by clang::Preprocessor::HandleEndOfFile().
Preprocessor* clang::PreprocessorLexer::getPP | ( | ) | const [inline] |
Return the preprocessor object for this lexer.
Definition at line 151 of file PreprocessorLexer.h.
References PP.
virtual SourceLocation clang::PreprocessorLexer::getSourceLocation | ( | ) | [protected, pure virtual] |
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::PTHLexer.
Referenced by LexIncludeFilename().
bool clang::PreprocessorLexer::isLexingRawMode | ( | ) | const [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().
void clang::PreprocessorLexer::operator= | ( | const PreprocessorLexer & | ) | [protected] |
PPConditionalInfo& clang::PreprocessorLexer::peekConditionalLevel | ( | ) | [inline, protected] |
Return the top of the conditional stack.
Definition at line 122 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 113 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 97 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 106 of file PreprocessorLexer.h.
References ConditionalStack.
void clang::PreprocessorLexer::setParsingPreprocessorDirective | ( | bool | f | ) | [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 class Preprocessor [friend] |
Reimplemented in clang::Lexer.
Definition at line 74 of file PreprocessorLexer.h.
SmallVector<PPConditionalInfo, 4> clang::PreprocessorLexer::ConditionalStack [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().
const FileID clang::PreprocessorLexer::FID [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().
Number of SLocEntries before lexing the file.
Definition at line 36 of file PreprocessorLexer.h.
Referenced by getInitialNumSLocEntries(), and PreprocessorLexer().
bool clang::PreprocessorLexer::LexingRawMode [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: 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 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().
MultipleIncludeOpt clang::PreprocessorLexer::MIOpt [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().
bool clang::PreprocessorLexer::ParsingFilename [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().
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().
Preprocessor* clang::PreprocessorLexer::PP [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().