class MultipleIncludeOpt
Declaration
class MultipleIncludeOpt { /* full declaration omitted */ };
Description
Implements the simple state machine that the Lexer class uses to detect files subject to the 'multiple-include' optimization. The public methods in this class are triggered by various events that occur when a file is lexed, and after the entire file is lexed, information about which macro (if any) controls the header is returned.
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:28
Member Variables
- private bool ReadAnyTokens
- ReadAnyTokens - This is set to false when a file is first opened and true any time a token is returned to the client or a (non-multiple-include) directive is parsed. When the final # endif is parsed this is reset back to false, that way any tokens before the first # ifdef or after the last # endif can be easily detected.
- private bool ImmediatelyAfterTopLevelIfndef
- ImmediatelyAfterTopLevelIfndef - This is true when the only tokens processed in the file so far is an #ifndef and an identifier. Used in the detection of header guards in a file.
- private bool DidMacroExpansion
- ReadAnyTokens - This is set to false when a file is first opened and true any time a token is returned to the client or a (non-multiple-include) directive is parsed. When the final #endif is parsed this is reset back to false, that way any tokens before the first #ifdef or after the last #endif can be easily detected.
- private const clang::IdentifierInfo* TheMacro
- TheMacro - The controlling macro for a file, if valid.
- private const clang::IdentifierInfo* DefinedMacro
- DefinedMacro - The macro defined right after TheMacro, if any.
- private clang::SourceLocation MacroLoc
- private clang::SourceLocation DefinedLoc
Method Overview
- public void EnterTopLevelConditional()
- public void EnterTopLevelIfndef(const clang::IdentifierInfo * M, clang::SourceLocation Loc)
- public void ExitTopLevelConditional()
- public void ExpandedMacro()
- public const clang::IdentifierInfo * GetControllingMacroAtEndOfFile() const
- public clang::SourceLocation GetDefinedLocation() const
- public const clang::IdentifierInfo * GetDefinedMacro() const
- public clang::SourceLocation GetMacroLocation() const
- public void Invalidate()
- public MultipleIncludeOpt()
- public void ReadToken()
- public void SetDefinedMacro(clang::IdentifierInfo * M, clang::SourceLocation Loc)
- public bool getHasReadAnyTokensVal() const
- public bool getImmediatelyAfterTopLevelIfndef() const
- public void resetImmediatelyAfterTopLevelIfndef()
Methods
¶void EnterTopLevelConditional()
void EnterTopLevelConditional()
Description
Invoked when a top level conditional (except # ifndef) is found.
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:142
¶void EnterTopLevelIfndef(
const clang::IdentifierInfo* M,
clang::SourceLocation Loc)
void EnterTopLevelIfndef(
const clang::IdentifierInfo* M,
clang::SourceLocation Loc)
Description
Called when entering a top-level # ifndef directive (or the "\#if !defined" equivalent) without any preceding tokens. Note, we don't care about the input value of 'ReadAnyTokens'. The caller ensures that this is only called if there are no tokens read before the # ifndef. The caller is required to do this, because reading the # if line obviously reads in tokens.
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:122
Parameters
- const clang::IdentifierInfo* M
- clang::SourceLocation Loc
¶void ExitTopLevelConditional()
void ExitTopLevelConditional()
Description
Called when the lexer exits the top-level conditional.
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:149
¶void ExpandedMacro()
void ExpandedMacro()
Description
ExpandedMacro - When a macro is expanded with this lexer as the current buffer, this method is called to disable the MIOpt if needed.
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:113
¶const clang::IdentifierInfo*
GetControllingMacroAtEndOfFile() const
const clang::IdentifierInfo*
GetControllingMacroAtEndOfFile() const
Description
Once the entire file has been lexed, if there is a controlling macro, return it.
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:163
¶clang::SourceLocation GetDefinedLocation() const
clang::SourceLocation GetDefinedLocation() const
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:70
¶const clang::IdentifierInfo* GetDefinedMacro()
const
const clang::IdentifierInfo* GetDefinedMacro()
const
Description
If the ControllingMacro is followed by a macro definition, return the macro that was defined.
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:173
¶clang::SourceLocation GetMacroLocation() const
clang::SourceLocation GetMacroLocation() const
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:66
¶void Invalidate()
void Invalidate()
Description
Invalidate - Permanently mark this file as not being suitable for the include-file optimization.
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:85
¶MultipleIncludeOpt()
MultipleIncludeOpt()
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:58
¶void ReadToken()
void ReadToken()
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:106
¶void SetDefinedMacro(clang::IdentifierInfo* M,
clang::SourceLocation Loc)
void SetDefinedMacro(clang::IdentifierInfo* M,
clang::SourceLocation Loc)
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:78
Parameters
¶bool getHasReadAnyTokensVal() const
bool getHasReadAnyTokensVal() const
Description
getHasReadAnyTokensVal - This is used for the # ifndef handshake at the top of the file when reading preprocessor directives. Otherwise, reading the "ifndef x" would count as reading tokens.
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:97
¶bool getImmediatelyAfterTopLevelIfndef() const
bool getImmediatelyAfterTopLevelIfndef() const
Description
getImmediatelyAfterTopLevelIfndef - returns true if the last directive was an #ifndef at the beginning of the file.
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:101
¶void resetImmediatelyAfterTopLevelIfndef()
void resetImmediatelyAfterTopLevelIfndef()
Declared at: clang/include/clang/Lex/MultipleIncludeOpt.h:74