clang 20.0.0git
Public Member Functions | List of all members
clang::MultipleIncludeOpt Class Reference

Implements the simple state machine that the Lexer class uses to detect files subject to the 'multiple-include' optimization. More...

#include "clang/Lex/MultipleIncludeOpt.h"

Public Member Functions

 MultipleIncludeOpt ()
 
SourceLocation GetMacroLocation () const
 
SourceLocation GetDefinedLocation () const
 
void resetImmediatelyAfterTopLevelIfndef ()
 
void SetDefinedMacro (IdentifierInfo *M, SourceLocation Loc)
 
void Invalidate ()
 Invalidate - Permanently mark this file as not being suitable for the include-file optimization.
 
bool getHasReadAnyTokensVal () const
 getHasReadAnyTokensVal - This is used for the #ifndef handshake at the top of the file when reading preprocessor directives.
 
bool getImmediatelyAfterTopLevelIfndef () const
 getImmediatelyAfterTopLevelIfndef - returns true if the last directive was an #ifndef at the beginning of the file.
 
void ReadToken ()
 
void SetReadToken (bool Value)
 SetReadToken - Set whether the value of 'ReadAnyTokens'.
 
void ExpandedMacro ()
 ExpandedMacro - When a macro is expanded with this lexer as the current buffer, this method is called to disable the MIOpt if needed.
 
void EnterTopLevelIfndef (const IdentifierInfo *M, SourceLocation Loc)
 Called when entering a top-level #ifndef directive (or the "\#if !defined" equivalent) without any preceding tokens.
 
void EnterTopLevelConditional ()
 Invoked when a top level conditional (except #ifndef) is found.
 
void ExitTopLevelConditional ()
 Called when the lexer exits the top-level conditional.
 
const IdentifierInfoGetControllingMacroAtEndOfFile () const
 Once the entire file has been lexed, if there is a controlling macro, return it.
 
const IdentifierInfoGetDefinedMacro () const
 If the ControllingMacro is followed by a macro definition, return the macro that was defined.
 

Detailed 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.

Definition at line 28 of file MultipleIncludeOpt.h.

Constructor & Destructor Documentation

◆ MultipleIncludeOpt()

clang::MultipleIncludeOpt::MultipleIncludeOpt ( )
inline

Definition at line 58 of file MultipleIncludeOpt.h.

Member Function Documentation

◆ EnterTopLevelConditional()

void clang::MultipleIncludeOpt::EnterTopLevelConditional ( )
inline

Invoked when a top level conditional (except #ifndef) is found.

Definition at line 148 of file MultipleIncludeOpt.h.

References Invalidate().

◆ EnterTopLevelIfndef()

void clang::MultipleIncludeOpt::EnterTopLevelIfndef ( const IdentifierInfo M,
SourceLocation  Loc 
)
inline

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.

Definition at line 128 of file MultipleIncludeOpt.h.

References Invalidate(), and Loc.

◆ ExitTopLevelConditional()

void clang::MultipleIncludeOpt::ExitTopLevelConditional ( )
inline

Called when the lexer exits the top-level conditional.

Definition at line 155 of file MultipleIncludeOpt.h.

References Invalidate().

◆ ExpandedMacro()

void clang::MultipleIncludeOpt::ExpandedMacro ( )
inline

ExpandedMacro - When a macro is expanded with this lexer as the current buffer, this method is called to disable the MIOpt if needed.

Definition at line 119 of file MultipleIncludeOpt.h.

◆ GetControllingMacroAtEndOfFile()

const IdentifierInfo * clang::MultipleIncludeOpt::GetControllingMacroAtEndOfFile ( ) const
inline

Once the entire file has been lexed, if there is a controlling macro, return it.

Definition at line 169 of file MultipleIncludeOpt.h.

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

◆ GetDefinedLocation()

SourceLocation clang::MultipleIncludeOpt::GetDefinedLocation ( ) const
inline

Definition at line 70 of file MultipleIncludeOpt.h.

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

◆ GetDefinedMacro()

const IdentifierInfo * clang::MultipleIncludeOpt::GetDefinedMacro ( ) const
inline

If the ControllingMacro is followed by a macro definition, return the macro that was defined.

Definition at line 179 of file MultipleIncludeOpt.h.

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

◆ getHasReadAnyTokensVal()

bool clang::MultipleIncludeOpt::getHasReadAnyTokensVal ( ) const
inline

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.

Definition at line 97 of file MultipleIncludeOpt.h.

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

◆ getImmediatelyAfterTopLevelIfndef()

bool clang::MultipleIncludeOpt::getImmediatelyAfterTopLevelIfndef ( ) const
inline

getImmediatelyAfterTopLevelIfndef - returns true if the last directive was an #ifndef at the beginning of the file.

Definition at line 101 of file MultipleIncludeOpt.h.

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

◆ GetMacroLocation()

SourceLocation clang::MultipleIncludeOpt::GetMacroLocation ( ) const
inline

Definition at line 66 of file MultipleIncludeOpt.h.

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

◆ Invalidate()

void clang::MultipleIncludeOpt::Invalidate ( )
inline

Invalidate - Permanently mark this file as not being suitable for the include-file optimization.

Definition at line 85 of file MultipleIncludeOpt.h.

Referenced by EnterTopLevelConditional(), EnterTopLevelIfndef(), and ExitTopLevelConditional().

◆ ReadToken()

void clang::MultipleIncludeOpt::ReadToken ( )
inline

Definition at line 106 of file MultipleIncludeOpt.h.

◆ resetImmediatelyAfterTopLevelIfndef()

void clang::MultipleIncludeOpt::resetImmediatelyAfterTopLevelIfndef ( )
inline

Definition at line 74 of file MultipleIncludeOpt.h.

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

◆ SetDefinedMacro()

void clang::MultipleIncludeOpt::SetDefinedMacro ( IdentifierInfo M,
SourceLocation  Loc 
)
inline

Definition at line 78 of file MultipleIncludeOpt.h.

References Loc.

◆ SetReadToken()

void clang::MultipleIncludeOpt::SetReadToken ( bool  Value)
inline

SetReadToken - Set whether the value of 'ReadAnyTokens'.

Called to override when encountering tokens outside of the include guard that have no effect if the file in question is is included multiple times (e.g. the null directive).

Definition at line 115 of file MultipleIncludeOpt.h.

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


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