clang
9.0.0
|
#include "clang/Lex/PreprocessorLexer.h"
Public Types | |
using | conditional_iterator = SmallVectorImpl< PPConditionalInfo >::const_iterator |
Iterator that traverses the current stack of preprocessor conditional directives (#if/#ifdef/#ifndef). More... | |
Public Member Functions | |
PreprocessorLexer (const PreprocessorLexer &)=delete | |
PreprocessorLexer & | operator= (const PreprocessorLexer &)=delete |
void | LexIncludeFilename (Token &FilenameTok) |
Lex a token, producing a header-name token if possible. 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 |
getFileEntry - Return the FileEntry corresponding to this FileID. More... | |
conditional_iterator | conditional_begin () const |
conditional_iterator | conditional_end () const |
void | setConditionalLevels (ArrayRef< PPConditionalInfo > CL) |
Protected Member Functions | |
PreprocessorLexer () | |
PreprocessorLexer (Preprocessor *pp, FileID fid) | |
virtual | ~PreprocessorLexer ()=default |
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) |
pushConditionalLevel - When we enter a #if directive, this keeps track of what we are currently in for diagnostic emission (e.g. More... | |
void | pushConditionalLevel (const PPConditionalInfo &CI) |
bool | popConditionalLevel (PPConditionalInfo &CI) |
popConditionalLevel - Remove an entry off the top of the conditional stack, returning information about it. More... | |
PPConditionalInfo & | peekConditionalLevel () |
Return the top of the conditional stack. More... | |
unsigned | getConditionalStackDepth () const |
Protected Attributes | |
Preprocessor * | PP = nullptr |
const FileID | FID |
The SourceManager FileID corresponding to the file being lexed. More... | |
unsigned | InitialNumSLocEntries = 0 |
Number of SLocEntries before lexing the file. More... | |
bool | ParsingPreprocessorDirective = false |
True when parsing #XXX; turns '\n' into a tok::eod token. More... | |
bool | ParsingFilename = false |
True after #include; turns <xx> or "xxx" into a tok::header_name token. More... | |
bool | LexingRawMode = false |
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 29 of file PreprocessorLexer.h.
using clang::PreprocessorLexer::conditional_iterator = SmallVectorImpl<PPConditionalInfo>::const_iterator |
Iterator that traverses the current stack of preprocessor conditional directives (#if/#ifdef/#ifndef).
Definition at line 164 of file PreprocessorLexer.h.
|
inlineprotected |
Definition at line 77 of file PreprocessorLexer.h.
References getSourceLocation(), IndirectLex(), clang::Result, and ~PreprocessorLexer().
Referenced by getConditionalStackDepth().
|
protected |
Definition at line 24 of file PreprocessorLexer.cpp.
References clang::Preprocessor::getSourceManager(), InitialNumSLocEntries, and clang::SourceManager::local_sloc_entry_size().
|
protectedvirtualdefault |
Referenced by PreprocessorLexer().
|
delete |
|
inline |
Definition at line 166 of file PreprocessorLexer.h.
|
inline |
Definition at line 170 of file PreprocessorLexer.h.
|
inlineprotected |
Definition at line 122 of file PreprocessorLexer.h.
References LexIncludeFilename(), operator=(), and PreprocessorLexer().
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 50 of file PreprocessorLexer.cpp.
References clang::SourceManager::getFileEntryForID(), getFileID(), clang::Preprocessor::getSourceManager(), and PP.
Referenced by EvaluateHasIncludeNext(), getInitialNumSLocEntries(), clang::Preprocessor::HandlePragmaSystemHeader(), and clang::Preprocessor::LookupFile().
|
inline |
Definition at line 146 of file PreprocessorLexer.h.
References FID.
Referenced by getFileEntry(), isTargetEnvironment(), and clang::Preprocessor::LookupFile().
|
inline |
Number of SLocEntries before lexing the file.
Definition at line 153 of file PreprocessorLexer.h.
References getFileEntry(), and InitialNumSLocEntries.
|
inline |
Return the preprocessor object for this lexer.
Definition at line 144 of file PreprocessorLexer.h.
References PP.
|
protectedpure virtual |
Return the source location for the next observable location.
Implemented in clang::Lexer.
Referenced by clang::Preprocessor::CheckEndOfDirective(), and PreprocessorLexer().
|
protectedpure virtual |
Referenced by LexIncludeFilename(), and PreprocessorLexer().
|
inline |
Return true if this lexer is in raw mode or not.
Definition at line 141 of file PreprocessorLexer.h.
References LexingRawMode.
Referenced by DecodeTrigraphChar(), FindConflictEnd(), clang::Lexer::findLocationAfterToken(), findPlaceholderEnd(), isEndOfBlockCommentWithEscapedNewLine(), maybeDiagnoseUTF8Homoglyph(), and clang::Lexer::ReadToEndOfLine().
void PreprocessorLexer::LexIncludeFilename | ( | Token & | FilenameTok | ) |
Lex a token, producing a header-name token if possible.
After the preprocessor has parsed a #include, lex and (potentially) macro expand the filename.
Definition at line 32 of file PreprocessorLexer.cpp.
References IndirectLex(), clang::Preprocessor::Lex(), LexingRawMode, ParsingFilename, and PP.
Referenced by getConditionalStackDepth(), and clang::Preprocessor::LexHeaderName().
|
delete |
Referenced by getConditionalStackDepth().
|
inlineprotected |
Return the top of the conditional stack.
Definition at line 117 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::CheckEndOfDirective().
|
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 108 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::CheckEndOfDirective().
|
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 92 of file PreprocessorLexer.h.
References clang::PPConditionalInfo::FoundElse, clang::PPConditionalInfo::FoundNonSkip, clang::PPConditionalInfo::IfLoc, and clang::PPConditionalInfo::WasSkipping.
Referenced by clang::Preprocessor::CheckEndOfDirective().
|
inlineprotected |
Definition at line 101 of file PreprocessorLexer.h.
|
inline |
Definition at line 174 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::SkipTokensWhileUsingPCH().
|
inline |
Inform the lexer whether or not we are currently lexing a preprocessor directive.
Definition at line 136 of file PreprocessorLexer.h.
Referenced by DetectEOL().
|
friend |
Definition at line 33 of file PreprocessorLexer.h.
|
protected |
Information about the set of #if/#ifdef/#ifndef blocks we are currently in.
Definition at line 75 of file PreprocessorLexer.h.
Referenced by clang::Lexer::ReadToEndOfLine().
|
protected |
The SourceManager FileID corresponding to the file being lexed.
Definition at line 39 of file PreprocessorLexer.h.
Referenced by getFileID(), clang::Lexer::getImmediateMacroName(), and makeRangeFromFileLocs().
|
protected |
Number of SLocEntries before lexing the file.
Definition at line 42 of file PreprocessorLexer.h.
Referenced by getInitialNumSLocEntries(), and PreprocessorLexer().
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 67 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::CheckEndOfDirective(), findPlaceholderEnd(), clang::Preprocessor::HandleMicrosoftCommentPaste(), isLexingRawMode(), clang::Lexer::Lexer(), LexIncludeFilename(), maybeDiagnoseUTF8Homoglyph(), and clang::Lexer::ReadToEndOfLine().
|
protected |
A state machine that detects the #ifndef-wrapping a file idiom for the multiple-include optimization.
Definition at line 71 of file PreprocessorLexer.h.
Referenced by findPlaceholderEnd(), and isTrivialSingleTokenExpansion().
True after #include; turns <xx> or "xxx" into a tok::header_name token.
Definition at line 52 of file PreprocessorLexer.h.
Referenced by findPlaceholderEnd(), LexIncludeFilename(), and clang::Lexer::ReadToEndOfLine().
True when parsing #XXX; turns '\n' into a tok::eod token.
Definition at line 49 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::CheckEndOfDirective(), clang::Lexer::Create_PragmaLexer(), findPlaceholderEnd(), clang::Preprocessor::HandleMicrosoftCommentPaste(), and clang::Lexer::ReadToEndOfLine().
|
protected |
Definition at line 36 of file PreprocessorLexer.h.
Referenced by getFileEntry(), clang::Lexer::getIndentationForLine(), getPP(), LexIncludeFilename(), and clang::Lexer::resetExtendedTokenMode().