clang 20.0.0git
Classes | Public Member Functions | Friends | List of all members
clang::PreprocessingRecord Class Reference

A record of the steps taken while preprocessing a source file, including the various preprocessing directives processed, macros expanded, etc. More...

#include "clang/Lex/PreprocessingRecord.h"

Inheritance diagram for clang::PreprocessingRecord:
Inheritance graph
[legend]

Classes

class  iterator
 Iteration over the preprocessed entities. More...
 

Public Member Functions

 PreprocessingRecord (SourceManager &SM)
 Construct a new preprocessing record.
 
void * Allocate (unsigned Size, unsigned Align=8)
 Allocate memory in the preprocessing record.
 
void Deallocate (void *Ptr)
 Deallocate memory in the preprocessing record.
 
size_t getTotalMemory () const
 
SourceManagergetSourceManager () const
 
iterator begin ()
 Begin iterator for all preprocessed entities.
 
iterator end ()
 End iterator for all preprocessed entities.
 
iterator local_begin ()
 Begin iterator for local, non-loaded, preprocessed entities.
 
iterator local_end ()
 End iterator for local, non-loaded, preprocessed entities.
 
llvm::iterator_range< iteratorgetIteratorsForLoadedRange (unsigned start, unsigned count)
 iterator range for the given range of loaded preprocessed entities.
 
llvm::iterator_range< iteratorgetPreprocessedEntitiesInRange (SourceRange R)
 Returns a range of preprocessed entities that source range R encompasses.
 
bool isEntityInFileID (iterator PPEI, FileID FID)
 Returns true if the preprocessed entity that PPEI iterator points to is coming from the file FID.
 
PPEntityID addPreprocessedEntity (PreprocessedEntity *Entity)
 Add a new preprocessed entity to this record.
 
void SetExternalSource (ExternalPreprocessingRecordSource &Source)
 Set the external source for preprocessed entities.
 
ExternalPreprocessingRecordSourcegetExternalSource () const
 Retrieve the external source for preprocessed entities.
 
MacroDefinitionRecordfindMacroDefinition (const MacroInfo *MI)
 Retrieve the macro definition that corresponds to the given MacroInfo.
 
const std::vector< SourceRange > & getSkippedRanges ()
 Retrieve all ranges that got skipped while preprocessing.
 
- Public Member Functions inherited from clang::PPCallbacks
virtual ~PPCallbacks ()
 
virtual void FileChanged (SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID=FileID())
 Callback invoked whenever a source file is entered or exited.
 
virtual void LexedFileChanged (FileID FID, LexedFileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID, SourceLocation Loc)
 Callback invoked whenever the Lexer moves to a different file for lexing.
 
virtual void FileSkipped (const FileEntryRef &SkippedFile, const Token &FilenameTok, SrcMgr::CharacteristicKind FileType)
 Callback invoked whenever a source file is skipped as the result of header guard optimization.
 
virtual bool EmbedFileNotFound (StringRef FileName)
 Callback invoked whenever the preprocessor cannot find a file for an embed directive.
 
virtual void EmbedDirective (SourceLocation HashLoc, StringRef FileName, bool IsAngled, OptionalFileEntryRef File, const LexEmbedParametersResult &Params)
 Callback invoked whenever an embed directive has been processed, regardless of whether the embed will actually find a file.
 
virtual bool FileNotFound (StringRef FileName)
 Callback invoked whenever the preprocessor cannot find a file for an inclusion directive.
 
virtual void InclusionDirective (SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File, StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule, bool ModuleImported, SrcMgr::CharacteristicKind FileType)
 Callback invoked whenever an inclusion directive of any kind (#include, #import, etc.) has been processed, regardless of whether the inclusion will actually result in an inclusion.
 
virtual void EnteredSubmodule (Module *M, SourceLocation ImportLoc, bool ForPragma)
 Callback invoked whenever a submodule was entered.
 
virtual void LeftSubmodule (Module *M, SourceLocation ImportLoc, bool ForPragma)
 Callback invoked whenever a submodule was left.
 
virtual void moduleImport (SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported)
 Callback invoked whenever there was an explicit module-import syntax.
 
virtual void EndOfMainFile ()
 Callback invoked when the end of the main file is reached.
 
virtual void Ident (SourceLocation Loc, StringRef str)
 Callback invoked when a #ident or #sccs directive is read.
 
virtual void PragmaDirective (SourceLocation Loc, PragmaIntroducerKind Introducer)
 Callback invoked when start reading any pragma directive.
 
virtual void PragmaComment (SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str)
 Callback invoked when a #pragma comment directive is read.
 
virtual void PragmaMark (SourceLocation Loc, StringRef Trivia)
 Callback invoked when a #pragma mark comment is read.
 
virtual void PragmaDetectMismatch (SourceLocation Loc, StringRef Name, StringRef Value)
 Callback invoked when a #pragma detect_mismatch directive is read.
 
virtual void PragmaDebug (SourceLocation Loc, StringRef DebugType)
 Callback invoked when a #pragma clang __debug directive is read.
 
virtual void PragmaMessage (SourceLocation Loc, StringRef Namespace, PragmaMessageKind Kind, StringRef Str)
 Callback invoked when a #pragma message directive is read.
 
virtual void PragmaDiagnosticPush (SourceLocation Loc, StringRef Namespace)
 Callback invoked when a #pragma gcc diagnostic push directive is read.
 
virtual void PragmaDiagnosticPop (SourceLocation Loc, StringRef Namespace)
 Callback invoked when a #pragma gcc diagnostic pop directive is read.
 
virtual void PragmaDiagnostic (SourceLocation Loc, StringRef Namespace, diag::Severity mapping, StringRef Str)
 Callback invoked when a #pragma gcc diagnostic directive is read.
 
virtual void PragmaOpenCLExtension (SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State)
 Called when an OpenCL extension is either disabled or enabled with a pragma.
 
virtual void PragmaWarning (SourceLocation Loc, PragmaWarningSpecifier WarningSpec, ArrayRef< int > Ids)
 
virtual void PragmaWarningPush (SourceLocation Loc, int Level)
 Callback invoked when a #pragma warning(push) directive is read.
 
virtual void PragmaWarningPop (SourceLocation Loc)
 Callback invoked when a #pragma warning(pop) directive is read.
 
virtual void PragmaExecCharsetPush (SourceLocation Loc, StringRef Str)
 Callback invoked when a #pragma execution_character_set(push) directive is read.
 
virtual void PragmaExecCharsetPop (SourceLocation Loc)
 Callback invoked when a #pragma execution_character_set(pop) directive is read.
 
virtual void PragmaAssumeNonNullBegin (SourceLocation Loc)
 Callback invoked when a #pragma clang assume_nonnull begin directive is read.
 
virtual void PragmaAssumeNonNullEnd (SourceLocation Loc)
 Callback invoked when a #pragma clang assume_nonnull end directive is read.
 
virtual void MacroExpands (const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args)
 Called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found.
 
virtual void MacroDefined (const Token &MacroNameTok, const MacroDirective *MD)
 Hook called whenever a macro definition is seen.
 
virtual void MacroUndefined (const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef)
 Hook called whenever a macro #undef is seen.
 
virtual void Defined (const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range)
 Hook called whenever the 'defined' operator is seen.
 
virtual void HasEmbed (SourceLocation Loc, StringRef FileName, bool IsAngled, OptionalFileEntryRef File)
 Hook called when a '__has_embed' directive is read.
 
virtual void HasInclude (SourceLocation Loc, StringRef FileName, bool IsAngled, OptionalFileEntryRef File, SrcMgr::CharacteristicKind FileType)
 Hook called when a '__has_include' or '__has_include_next' directive is read.
 
virtual void SourceRangeSkipped (SourceRange Range, SourceLocation EndifLoc)
 Hook called when a source range is skipped.
 
virtual void If (SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue)
 Hook called whenever an #if is seen.
 
virtual void Elif (SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc)
 Hook called whenever an #elif is seen.
 
virtual void Ifdef (SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD)
 Hook called whenever an #ifdef is seen.
 
virtual void Elifdef (SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD)
 Hook called whenever an #elifdef branch is taken.
 
virtual void Elifdef (SourceLocation Loc, SourceRange ConditionRange, SourceLocation IfLoc)
 Hook called whenever an #elifdef is skipped.
 
virtual void Ifndef (SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD)
 Hook called whenever an #ifndef is seen.
 
virtual void Elifndef (SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD)
 Hook called whenever an #elifndef branch is taken.
 
virtual void Elifndef (SourceLocation Loc, SourceRange ConditionRange, SourceLocation IfLoc)
 Hook called whenever an #elifndef is skipped.
 
virtual void Else (SourceLocation Loc, SourceLocation IfLoc)
 Hook called whenever an #else is seen.
 
virtual void Endif (SourceLocation Loc, SourceLocation IfLoc)
 Hook called whenever an #endif is seen.
 

Friends

class ASTReader
 
class ASTWriter
 

Additional Inherited Members

- Public Types inherited from clang::PPCallbacks
enum  FileChangeReason { EnterFile , ExitFile , SystemHeaderPragma , RenameFile }
 
enum class  LexedFileChangeReason { EnterFile , ExitFile }
 
enum  PragmaMessageKind { PMK_Message , PMK_Warning , PMK_Error }
 Determines the kind of #pragma invoking a call to PragmaMessage. More...
 
enum  PragmaWarningSpecifier {
  PWS_Default , PWS_Disable , PWS_Error , PWS_Once ,
  PWS_Suppress , PWS_Level1 , PWS_Level2 , PWS_Level3 ,
  PWS_Level4
}
 Callback invoked when a #pragma warning directive is read. More...
 
enum  ConditionValueKind { CVK_NotEvaluated , CVK_False , CVK_True }
 

Detailed Description

A record of the steps taken while preprocessing a source file, including the various preprocessing directives processed, macros expanded, etc.

Definition at line 308 of file PreprocessingRecord.h.

Constructor & Destructor Documentation

◆ PreprocessingRecord()

PreprocessingRecord::PreprocessingRecord ( SourceManager SM)
explicit

Construct a new preprocessing record.

Definition at line 55 of file PreprocessingRecord.cpp.

Member Function Documentation

◆ addPreprocessedEntity()

PreprocessingRecord::PPEntityID PreprocessingRecord::addPreprocessedEntity ( PreprocessedEntity Entity)

◆ Allocate()

void * clang::PreprocessingRecord::Allocate ( unsigned  Size,
unsigned  Align = 8 
)
inline

Allocate memory in the preprocessing record.

Definition at line 403 of file PreprocessingRecord.h.

Referenced by clang::InclusionDirective::InclusionDirective().

◆ begin()

iterator clang::PreprocessingRecord::begin ( )
inline

Begin iterator for all preprocessed entities.

Definition at line 455 of file PreprocessingRecord.h.

◆ Deallocate()

void clang::PreprocessingRecord::Deallocate ( void *  Ptr)
inline

Deallocate memory in the preprocessing record.

Definition at line 408 of file PreprocessingRecord.h.

◆ end()

iterator clang::PreprocessingRecord::end ( )
inline

End iterator for all preprocessed entities.

Definition at line 460 of file PreprocessingRecord.h.

Referenced by getIteratorsForLoadedRange().

◆ findMacroDefinition()

MacroDefinitionRecord * PreprocessingRecord::findMacroDefinition ( const MacroInfo MI)

Retrieve the macro definition that corresponds to the given MacroInfo.

Definition at line 383 of file PreprocessingRecord.cpp.

◆ getExternalSource()

ExternalPreprocessingRecordSource * clang::PreprocessingRecord::getExternalSource ( ) const
inline

Retrieve the external source for preprocessed entities.

Definition at line 508 of file PreprocessingRecord.h.

◆ getIteratorsForLoadedRange()

llvm::iterator_range< iterator > clang::PreprocessingRecord::getIteratorsForLoadedRange ( unsigned  start,
unsigned  count 
)
inline

iterator range for the given range of loaded preprocessed entities.

Definition at line 476 of file PreprocessingRecord.h.

References end().

◆ getPreprocessedEntitiesInRange()

llvm::iterator_range< PreprocessingRecord::iterator > PreprocessingRecord::getPreprocessedEntitiesInRange ( SourceRange  R)

Returns a range of preprocessed entities that source range R encompasses.

Returns a pair of [Begin, End) iterators of preprocessed entities that source range Range encompasses.

Parameters
Rthe range to look for preprocessed entities.

Definition at line 60 of file PreprocessingRecord.cpp.

References clang::SourceRange::isInvalid(), and Range.

◆ getSkippedRanges()

const std::vector< SourceRange > & clang::PreprocessingRecord::getSkippedRanges ( )
inline

Retrieve all ranges that got skipped while preprocessing.

Definition at line 517 of file PreprocessingRecord.h.

◆ getSourceManager()

SourceManager & clang::PreprocessingRecord::getSourceManager ( ) const
inline

Definition at line 412 of file PreprocessingRecord.h.

◆ getTotalMemory()

size_t PreprocessingRecord::getTotalMemory ( ) const

Definition at line 515 of file PreprocessingRecord.cpp.

◆ isEntityInFileID()

bool PreprocessingRecord::isEntityInFileID ( iterator  PPEI,
FileID  FID 
)

Returns true if the preprocessed entity that PPEI iterator points to is coming from the file FID.

Returns true if the preprocessed entity that.

Can be used to avoid implicit deserializations of preallocated preprocessed entities if we only care about entities of a specific file and not from files #included in the range given at

See also
getPreprocessedEntitiesInRange.
  • PPEI iterator points to is coming from the file
  • FID.

Can be used to avoid implicit deserializations of preallocated preprocessed entities if we only care about entities of a specific file and not from files #included in the range given at

See also
getPreprocessedEntitiesInRange.

Definition at line 98 of file PreprocessingRecord.cpp.

References clang::FileID::isInvalid(), and isPreprocessedEntityIfInFileID().

◆ local_begin()

iterator clang::PreprocessingRecord::local_begin ( )
inline

Begin iterator for local, non-loaded, preprocessed entities.

Definition at line 465 of file PreprocessingRecord.h.

◆ local_end()

iterator clang::PreprocessingRecord::local_end ( )
inline

End iterator for local, non-loaded, preprocessed entities.

Definition at line 470 of file PreprocessingRecord.h.

◆ SetExternalSource()

void PreprocessingRecord::SetExternalSource ( ExternalPreprocessingRecordSource Source)

Set the external source for preprocessed entities.

Definition at line 313 of file PreprocessingRecord.cpp.

Friends And Related Function Documentation

◆ ASTReader

friend class ASTReader
friend

Definition at line 523 of file PreprocessingRecord.h.

◆ ASTWriter

friend class ASTWriter
friend

Definition at line 524 of file PreprocessingRecord.h.

Member Data Documentation

◆ Range

SourceRange clang::PreprocessingRecord::Range

Definition at line 563 of file PreprocessingRecord.h.

Referenced by getPreprocessedEntitiesInRange().

◆ Result

std::pair<int, int> clang::PreprocessingRecord::Result

Definition at line 564 of file PreprocessingRecord.h.


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