clang 20.0.0git
|
#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). | |
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. | |
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. | |
OptionalFileEntryRef | getFileEntry () const |
getFileEntry - Return the FileEntry corresponding to this FileID. | |
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. | |
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. | |
void | pushConditionalLevel (const PPConditionalInfo &CI) |
bool | popConditionalLevel (PPConditionalInfo &CI) |
popConditionalLevel - Remove an entry off the top of the conditional stack, returning information about it. | |
PPConditionalInfo & | peekConditionalLevel () |
Return the top of the conditional stack. | |
unsigned | getConditionalStackDepth () const |
Protected Attributes | |
Preprocessor * | PP = nullptr |
const FileID | FID |
The SourceManager FileID corresponding to the file being lexed. | |
unsigned | InitialNumSLocEntries = 0 |
Number of SLocEntries before lexing the file. | |
bool | ParsingPreprocessorDirective = false |
True when parsing #XXX; turns '\n' into a tok::eod token. | |
bool | ParsingFilename = false |
True after #include; turns <xx> or "xxx" into a tok::header_name token. | |
bool | LexingRawMode = false |
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 30 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 78 of file PreprocessorLexer.h.
|
protected |
Definition at line 24 of file PreprocessorLexer.cpp.
References clang::Preprocessor::getSourceManager(), InitialNumSLocEntries, and clang::SourceManager::local_sloc_entry_size().
|
protectedvirtualdefault |
|
delete |
|
inline |
Definition at line 167 of file PreprocessorLexer.h.
References ConditionalStack.
|
inline |
Definition at line 171 of file PreprocessorLexer.h.
References ConditionalStack.
|
inlineprotected |
Definition at line 123 of file PreprocessorLexer.h.
References ConditionalStack.
Referenced by clang::Preprocessor::HandleDirective().
OptionalFileEntryRef 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::getFileEntryRefForID(), getFileID(), clang::Preprocessor::getSourceManager(), and PP.
Referenced by clang::SemaCodeCompletion::CodeCompleteIncludedFile(), clang::Preprocessor::HandleEndOfFile(), clang::Preprocessor::HandlePragmaDependency(), clang::Preprocessor::HandlePragmaSystemHeader(), and clang::Preprocessor::LookupFile().
|
inline |
Definition at line 147 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 154 of file PreprocessorLexer.h.
References InitialNumSLocEntries.
Referenced by clang::Preprocessor::HandleEndOfFile().
|
inline |
Return the preprocessor object for this lexer.
Definition at line 145 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::HandleEndOfFile().
|
protectedpure virtual |
Referenced by LexIncludeFilename().
|
inline |
Return true if this lexer is in raw mode or not.
Definition at line 142 of file PreprocessorLexer.h.
References LexingRawMode.
Referenced by DecodeTrigraphChar(), isEndOfBlockCommentWithEscapedNewLine(), and clang::Lexer::Lex().
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 clang::Preprocessor::LexHeaderName().
|
delete |
|
inlineprotected |
Return the top of the conditional stack.
Definition at line 118 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 109 of file PreprocessorLexer.h.
References ConditionalStack.
|
inlineprotected |
Definition at line 102 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 93 of file PreprocessorLexer.h.
References ConditionalStack, clang::PPConditionalInfo::FoundElse, clang::PPConditionalInfo::FoundNonSkip, clang::PPConditionalInfo::IfLoc, and clang::PPConditionalInfo::WasSkipping.
|
inline |
Definition at line 175 of file PreprocessorLexer.h.
References ConditionalStack.
|
inline |
Inform the lexer whether or not we are currently lexing a preprocessor directive.
Definition at line 137 of file PreprocessorLexer.h.
References ParsingPreprocessorDirective.
|
friend |
Definition at line 34 of file PreprocessorLexer.h.
|
protected |
Information about the set of #if/#ifdef/#ifndef blocks we are currently in.
Definition at line 76 of file PreprocessorLexer.h.
Referenced by conditional_begin(), conditional_end(), getConditionalStackDepth(), peekConditionalLevel(), popConditionalLevel(), pushConditionalLevel(), and setConditionalLevels().
|
protected |
The SourceManager FileID corresponding to the file being lexed.
Definition at line 40 of file PreprocessorLexer.h.
Referenced by getFileID(), and clang::Lexer::getImmediateMacroName().
|
protected |
Number of SLocEntries before lexing the file.
Definition at line 43 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 68 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::HandleMicrosoftCommentPaste(), clang::Preprocessor::HandlePragmaPoison(), isLexingRawMode(), 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 72 of file PreprocessorLexer.h.
Referenced by clang::Preprocessor::HandleDirective(), and clang::Preprocessor::HandleEndOfFile().
True after #include; turns <xx> or "xxx" into a tok::header_name token.
Definition at line 53 of file PreprocessorLexer.h.
Referenced by LexIncludeFilename(), and clang::Lexer::ReadToEndOfLine().
True when parsing #XXX; turns '\n' into a tok::eod token.
Definition at line 50 of file PreprocessorLexer.h.
Referenced by clang::Lexer::Create_PragmaLexer(), clang::Preprocessor::HandleDirective(), clang::Preprocessor::HandleMicrosoftCommentPaste(), clang::Lexer::ReadToEndOfLine(), and setParsingPreprocessorDirective().
|
protected |
Definition at line 37 of file PreprocessorLexer.h.
Referenced by clang::Lexer::Create_PragmaLexer(), clang::Lexer::Diag(), getFileEntry(), getFileID(), getPP(), clang::Lexer::getSourceLocation(), LexIncludeFilename(), clang::Lexer::ReadToEndOfLine(), and clang::Lexer::resetExtendedTokenMode().