15 #ifndef LLVM_CLANG_LEX_PREPROCESSORLEXER_H 16 #define LLVM_CLANG_LEX_PREPROCESSORLEXER_H 21 #include "llvm/ADT/ArrayRef.h" 22 #include "llvm/ADT/SmallVector.h" 31 virtual void anchor();
95 bool FoundNonSkip,
bool FoundElse) {
97 CI.
IfLoc = DirectiveStart;
101 ConditionalStack.push_back(CI);
104 ConditionalStack.push_back(CI);
111 if (ConditionalStack.empty())
113 CI = ConditionalStack.pop_back_val();
120 assert(!ConditionalStack.empty() &&
"No conditionals active!");
121 return ConditionalStack.back();
143 ParsingPreprocessorDirective = f;
154 "PreprocessorLexer::getFileID() should only be used with a Preprocessor");
173 return ConditionalStack.begin();
177 return ConditionalStack.end();
181 ConditionalStack.clear();
182 ConditionalStack.append(CL.begin(), CL.end());
188 #endif // LLVM_CLANG_LEX_PREPROCESSORLEXER_H PPConditionalInfo & peekConditionalLevel()
Return the top of the conditional stack.
unsigned InitialNumSLocEntries
Number of SLocEntries before lexing the file.
SmallVectorImpl< PPConditionalInfo >::const_iterator conditional_iterator
Iterator that traverses the current stack of preprocessor conditional directives (#if/#ifdef/#ifndef)...
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 fo...
conditional_iterator conditional_end() const
Defines the MultipleIncludeOpt interface.
bool ParsingPreprocessorDirective
True when parsing #XXX; turns '\n' into a tok::eod token.
SmallVector< PPConditionalInfo, 4 > ConditionalStack
Information about the set of #if/#ifdef/#ifndef blocks we are currently in.
Preprocessor * getPP() const
Return the preprocessor object for this lexer.
Token - This structure provides full information about a lexed token.
unsigned getInitialNumSLocEntries() const
Number of SLocEntries before lexing the file.
bool popConditionalLevel(PPConditionalInfo &CI)
popConditionalLevel - Remove an entry off the top of the conditional stack, returning information abo...
Implements the simple state machine that the Lexer class uses to detect files subject to the 'multipl...
void setParsingPreprocessorDirective(bool f)
Inform the lexer whether or not we are currently lexing a preprocessor directive. ...
bool FoundNonSkip
True if we have emitted tokens already, and now we're in an #else block or something.
const FileID FID
The SourceManager FileID corresponding to the file being lexed.
bool ParsingFilename
True after #include; turns <xx> into a tok::angle_string_literal token.
bool LexingRawMode
True if in raw mode.
virtual ~PreprocessorLexer()=default
void pushConditionalLevel(const PPConditionalInfo &CI)
MultipleIncludeOpt MIOpt
A state machine that detects the #ifndef-wrapping a file idiom for the multiple-include optimization...
Information about the conditional stack (#if directives) currently active.
conditional_iterator conditional_begin() const
The result type of a method or function.
virtual SourceLocation getSourceLocation()=0
Return the source location for the next observable location.
bool WasSkipping
True if this was contained in a skipping directive, e.g., in a "\#if 0" block.
Encodes a location in the source.
Cached information about one file (either on disk or in the virtual file system). ...
PreprocessorLexer & operator=(const PreprocessorLexer &)=delete
SourceLocation IfLoc
Location where the conditional started.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
unsigned getConditionalStackDepth() const
Dataflow Directional Tag Classes.
const FileEntry * getFileEntry() const
getFileEntry - Return the FileEntry corresponding to this FileID.
bool isLexingRawMode() const
Return true if this lexer is in raw mode or not.
void setConditionalLevels(ArrayRef< PPConditionalInfo > CL)
void LexIncludeFilename(Token &Result)
After the preprocessor has parsed a #include, lex and (potentially) macro expand the filename...
Defines the clang::SourceLocation class and associated facilities.
virtual void IndirectLex(Token &Result)=0
bool FoundElse
True if we've seen a #else in this block.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.