clang API Documentation

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
clang::PreprocessorLexer Class Reference

#include <PreprocessorLexer.h>

Inheritance diagram for clang::PreprocessorLexer:
Inheritance graph
[legend]
Collaboration diagram for clang::PreprocessorLexer:
Collaboration graph
[legend]

List of all members.

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.
PreprocessorgetPP () const
 Return the preprocessor object for this lexer.
FileID getFileID () const
unsigned getInitialNumSLocEntries () const
 Number of SLocEntries before lexing the file.
const FileEntrygetFileEntry () 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)
PPConditionalInfopeekConditionalLevel ()
 Return the top of the conditional stack.
unsigned getConditionalStackDepth () const

Protected Attributes

PreprocessorPP
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

Detailed Description

Definition at line 27 of file PreprocessorLexer.h.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

PreprocessorLexer::PreprocessorLexer ( Preprocessor pp,
FileID  fid 
) [protected]

Definition at line 78 of file PreprocessorLexer.h.

virtual clang::PreprocessorLexer::~PreprocessorLexer ( ) [inline, protected, virtual]

Definition at line 84 of file PreprocessorLexer.h.


Member Function Documentation

Definition at line 173 of file PreprocessorLexer.h.

References ConditionalStack.

Definition at line 176 of file PreprocessorLexer.h.

References ConditionalStack.

Definition at line 127 of file PreprocessorLexer.h.

References ConditionalStack.

Referenced by clang::Preprocessor::HandleDirective().

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().

Number of SLocEntries before lexing the file.

Definition at line 160 of file PreprocessorLexer.h.

References InitialNumSLocEntries.

Referenced by clang::Preprocessor::HandleEndOfFile().

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().

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().

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]

Return the top of the conditional stack.

Precondition:
This requires that there be a conditional active.

Definition at line 122 of file PreprocessorLexer.h.

References ConditionalStack.

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.

Inform the lexer whether or not we are currently lexing a preprocessor directive.

Definition at line 143 of file PreprocessorLexer.h.

References ParsingPreprocessorDirective.


Friends And Related Function Documentation

friend class Preprocessor [friend]

Reimplemented in clang::Lexer.

Definition at line 74 of file PreprocessorLexer.h.


Member Data Documentation

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().

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().

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().

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().

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().


The documentation for this class was generated from the following files: