class PreprocessingRecord

Declaration

class PreprocessingRecord : public PPCallbacks { /* full declaration omitted */ };

Description

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

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:306

Inherits from: PPCallbacks

Member Variables

private clang::SourceManager& SourceMgr
private llvm::BumpPtrAllocator BumpAlloc
Allocator used to store preprocessing objects.
private std::vector<PreprocessedEntity*> PreprocessedEntities
The set of preprocessed entities in this record, in order they were seen.
private std::vector<PreprocessedEntity*> LoadedPreprocessedEntities
The entries in this vector are loaded lazily from the external source, and are referenced by the iterator using negative indices.
private std::vector<SourceRange> SkippedRanges
The set of ranges that were skipped by the preprocessor,
private bool SkippedRangesAllLoaded = true
private llvm::DenseMap<const MacroInfo*, MacroDefinitionRecord*> MacroDefinitions
Mapping from MacroInfo structures to their definitions.
private clang::ExternalPreprocessingRecordSource* ExternalSource = nullptr
External source of preprocessed entities.
private struct(unnamed struct at / home / hdoc / tmp / llvm - project / clang / include / clang / Lex / PreprocessingRecord.h : 559 : 5) CachedRangeQuery

Method Overview

  • public void * Allocate(unsigned int Size, unsigned int Align = 8)
  • public void Deallocate(void * Ptr)
  • private void Defined(const clang::Token & MacroNameTok, const clang::MacroDefinition & MD, clang::SourceRange Range)
  • private void Elifdef(clang::SourceLocation Loc, const clang::Token & MacroNameTok, const clang::MacroDefinition & MD)
  • private void Elifndef(clang::SourceLocation Loc, const clang::Token & MacroNameTok, const clang::MacroDefinition & MD)
  • private void Ifdef(clang::SourceLocation Loc, const clang::Token & MacroNameTok, const clang::MacroDefinition & MD)
  • private void Ifndef(clang::SourceLocation Loc, const clang::Token & MacroNameTok, const clang::MacroDefinition & MD)
  • private void InclusionDirective(clang::SourceLocation HashLoc, const clang::Token & IncludeTok, llvm::StringRef FileName, bool IsAngled, clang::CharSourceRange FilenameRange, Optional<clang::FileEntryRef> File, llvm::StringRef SearchPath, llvm::StringRef RelativePath, const clang::Module * Imported, SrcMgr::CharacteristicKind FileType)
  • private void MacroDefined(const clang::Token & Id, const clang::MacroDirective * MD)
  • private void MacroExpands(const clang::Token & Id, const clang::MacroDefinition & MD, clang::SourceRange Range, const clang::MacroArgs * Args)
  • private void MacroUndefined(const clang::Token & Id, const clang::MacroDefinition & MD, const clang::MacroDirective * Undef)
  • public PreprocessingRecord(clang::SourceManager & SM)
  • private void RegisterMacroDefinition(clang::MacroInfo * Macro, clang::MacroDefinitionRecord * Def)
  • public void SetExternalSource(clang::ExternalPreprocessingRecordSource & Source)
  • private void SourceRangeSkipped(clang::SourceRange Range, clang::SourceLocation EndifLoc)
  • private void addMacroExpansion(const clang::Token & Id, const clang::MacroInfo * MI, clang::SourceRange Range)
  • public clang::PreprocessingRecord::PPEntityID addPreprocessedEntity(clang::PreprocessedEntity * Entity)
  • private unsigned int allocateLoadedEntities(unsigned int NumEntities)
  • private unsigned int allocateSkippedRanges(unsigned int NumRanges)
  • public clang::PreprocessingRecord::iterator begin()
  • public clang::PreprocessingRecord::iterator end()
  • private void ensureSkippedRangesLoaded()
  • private unsigned int findBeginLocalPreprocessedEntity(clang::SourceLocation Loc) const
  • private unsigned int findEndLocalPreprocessedEntity(clang::SourceLocation Loc) const
  • private std::pair<unsigned int, unsigned int> findLocalPreprocessedEntitiesInRange(clang::SourceRange Range) const
  • public clang::MacroDefinitionRecord * findMacroDefinition(const clang::MacroInfo * MI)
  • public clang::ExternalPreprocessingRecordSource * getExternalSource() const
  • public llvm::iterator_range<iterator> getIteratorsForLoadedRange(unsigned int start, unsigned int count)
  • private clang::PreprocessedEntity * getLoadedPreprocessedEntity(unsigned int Index)
  • private unsigned int getNumLoadedPreprocessedEntities() const
  • private static clang::PreprocessingRecord::PPEntityID getPPEntityID(unsigned int Index, bool isLoaded)
  • public llvm::iterator_range<iterator> getPreprocessedEntitiesInRange(clang::SourceRange R)
  • private std::pair<int, int> getPreprocessedEntitiesInRangeSlow(clang::SourceRange R)
  • private clang::PreprocessedEntity * getPreprocessedEntity(clang::PreprocessingRecord::PPEntityID PPID)
  • public const std::vector<SourceRange> & getSkippedRanges()
  • public clang::SourceManager & getSourceManager() const
  • public size_t getTotalMemory() const
  • public bool isEntityInFileID(clang::PreprocessingRecord::iterator PPEI, clang::FileID FID)
  • public clang::PreprocessingRecord::iterator local_begin()
  • public clang::PreprocessingRecord::iterator local_end()

Inherited from PPCallbacks:

Methods

void* Allocate(unsigned int Size,
               unsigned int Align = 8)

Description

Allocate memory in the preprocessing record.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:401

Parameters

unsigned int Size
unsigned int Align = 8

void Deallocate(void* Ptr)

Description

Deallocate memory in the preprocessing record.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:406

Parameters

void* Ptr

void Defined(const clang::Token& MacroNameTok,
             const clang::MacroDefinition& MD,
             clang::SourceRange Range)

Description

Hook called whenever the 'defined' operator is seen.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:548

Parameters

const clang::Token& MacroNameTok
const clang::MacroDefinition& MD
clang::SourceRange Range

void Elifdef(clang::SourceLocation Loc,
             const clang::Token& MacroNameTok,
             const clang::MacroDefinition& MD)

Description

Hook called whenever an # elifdef branch is taken.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:542

Parameters

clang::SourceLocation Loc
the source location of the directive.
const clang::Token& MacroNameTok
Information on the token being tested.
const clang::MacroDefinition& MD
The MacroDefinition if the name was a macro, null otherwise.

void Elifndef(clang::SourceLocation Loc,
              const clang::Token& MacroNameTok,
              const clang::MacroDefinition& MD)

Description

Hook called whenever an # elifndef branch is taken.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:544

Parameters

clang::SourceLocation Loc
the source location of the directive.
const clang::Token& MacroNameTok
Information on the token being tested.
const clang::MacroDefinition& MD
The MacroDefinition if the name was a macro, null otherwise.

void Ifdef(clang::SourceLocation Loc,
           const clang::Token& MacroNameTok,
           const clang::MacroDefinition& MD)

Description

Hook called whenever an # ifdef is seen.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:535

Parameters

clang::SourceLocation Loc
the source location of the directive.
const clang::Token& MacroNameTok
Information on the token being tested.
const clang::MacroDefinition& MD
The MacroDefinition if the name was a macro, null otherwise.

void Ifndef(clang::SourceLocation Loc,
            const clang::Token& MacroNameTok,
            const clang::MacroDefinition& MD)

Description

Hook called whenever an # ifndef is seen.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:537

Parameters

clang::SourceLocation Loc
the source location of the directive.
const clang::Token& MacroNameTok
Information on the token being tested.
const clang::MacroDefinition& MD
The MacroDefiniton if the name was a macro, null otherwise.

void InclusionDirective(
    clang::SourceLocation HashLoc,
    const clang::Token& IncludeTok,
    llvm::StringRef FileName,
    bool IsAngled,
    clang::CharSourceRange FilenameRange,
    Optional<clang::FileEntryRef> File,
    llvm::StringRef SearchPath,
    llvm::StringRef RelativePath,
    const clang::Module* Imported,
    SrcMgr::CharacteristicKind FileType)

Description

Callback invoked whenever an inclusion directive of any kind (\c \#include \c \#import etc.) has been processed, regardless of whether the inclusion will actually result in an inclusion.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:529

Parameters

clang::SourceLocation HashLoc
The location of the '#' that starts the inclusion directive.
const clang::Token& IncludeTok
The token that indicates the kind of inclusion directive, e.g., 'include' or 'import'.
llvm::StringRef FileName
The name of the file being included, as written in the source code.
bool IsAngled
Whether the file name was enclosed in angle brackets; otherwise, it was enclosed in quotes.
clang::CharSourceRange FilenameRange
The character range of the quotes or angle brackets for the written file name.
Optional<clang::FileEntryRef> File
The actual file that may be included by this inclusion directive.
llvm::StringRef SearchPath
Contains the search path which was used to find the file in the file system. If the file was found via an absolute include path, SearchPath will be empty. For framework includes, the SearchPath and RelativePath will be split up. For example, if an include of "Some/Some.h" is found via the framework path "path/to/Frameworks/Some.framework/Headers/Some.h", SearchPath will be "path/to/Frameworks/Some.framework/Headers" and RelativePath will be "Some.h".
llvm::StringRef RelativePath
The path relative to SearchPath, at which the include file was found. This is equal to FileName except for framework includes.
const clang::Module* Imported
The module, whenever an inclusion directive was automatically turned into a module import or null otherwise.
SrcMgr::CharacteristicKind FileType
The characteristic kind, indicates whether a file or directory holds normal user code, system code, or system code which is implicitly 'extern "C"' in C++ mode.

void MacroDefined(const clang::Token& Id,
                  const clang::MacroDirective* MD)

Description

Hook called whenever a macro definition is seen.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:526

Parameters

const clang::Token& Id
const clang::MacroDirective* MD

void MacroExpands(
    const clang::Token& Id,
    const clang::MacroDefinition& MD,
    clang::SourceRange Range,
    const clang::MacroArgs* Args)

Description

Called by Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is found.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:524

Parameters

const clang::Token& Id
const clang::MacroDefinition& MD
clang::SourceRange Range
const clang::MacroArgs* Args

void MacroUndefined(
    const clang::Token& Id,
    const clang::MacroDefinition& MD,
    const clang::MacroDirective* Undef)

Description

Hook called whenever a macro # undef is seen. MD is released immediately following this callback.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:527

Parameters

const clang::Token& Id
const clang::MacroDefinition& MD
A MacroDefinition for the named macro.
const clang::MacroDirective* Undef
New MacroDirective if the macro was defined, null otherwise.

PreprocessingRecord(clang::SourceManager& SM)

Description

Construct a new preprocessing record.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:398

Parameters

clang::SourceManager& SM

void RegisterMacroDefinition(
    clang::MacroInfo* Macro,
    clang::MacroDefinitionRecord* Def)

Description

Register a new macro definition.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:394

Parameters

clang::MacroInfo* Macro
clang::MacroDefinitionRecord* Def

void SetExternalSource(
    clang::ExternalPreprocessingRecordSource&
        Source)

Description

Set the external source for preprocessed entities.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:503

Parameters

clang::ExternalPreprocessingRecordSource& Source

void SourceRangeSkipped(
    clang::SourceRange Range,
    clang::SourceLocation EndifLoc)

Description

Hook called when a source range is skipped.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:551

Parameters

clang::SourceRange Range
The SourceRange that was skipped. The range begins at the # if/ # else directive and ends after the # endif/ # else directive.
clang::SourceLocation EndifLoc
The end location of the 'endif' token, which may precede the range skipped by the directive (e.g excluding comments after an 'endif').

void addMacroExpansion(const clang::Token& Id,
                       const clang::MacroInfo* MI,
                       clang::SourceRange Range)

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:554

Parameters

const clang::Token& Id
const clang::MacroInfo* MI
clang::SourceRange Range

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

Description

Add a new preprocessed entity to this record.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:500

Parameters

clang::PreprocessedEntity* Entity

unsigned int allocateLoadedEntities(
    unsigned int NumEntities)

Description

Allocate space for a new set of loaded preprocessed entities.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:381

Parameters

unsigned int NumEntities

Returns

The index into the set of loaded preprocessed entities, which corresponds to the first newly-allocated entity.

unsigned int allocateSkippedRanges(
    unsigned int NumRanges)

Description

Allocate space for a new set of loaded preprocessed skipped ranges.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:388

Parameters

unsigned int NumRanges

Returns

The index into the set of loaded preprocessed ranges, which corresponds to the first newly-allocated range.

clang::PreprocessingRecord::iterator begin()

Description

Begin iterator for all preprocessed entities.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:453

clang::PreprocessingRecord::iterator end()

Description

End iterator for all preprocessed entities.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:458

void ensureSkippedRangesLoaded()

Description

Ensures that all external skipped ranges have been loaded.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:391

unsigned int findBeginLocalPreprocessedEntity(
    clang::SourceLocation Loc) const

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:374

Parameters

clang::SourceLocation Loc

unsigned int findEndLocalPreprocessedEntity(
    clang::SourceLocation Loc) const

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:375

Parameters

clang::SourceLocation Loc

std::pair<unsigned int, unsigned int>
findLocalPreprocessedEntitiesInRange(
    clang::SourceRange Range) const

Description

Returns a pair of [Begin, End) indices of local preprocessed entities that \p Range encompasses.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:373

Parameters

clang::SourceRange Range

clang::MacroDefinitionRecord* findMacroDefinition(
    const clang::MacroInfo* MI)

Description

Retrieve the macro definition that corresponds to the given\c MacroInfo.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:512

Parameters

const clang::MacroInfo* MI

clang::ExternalPreprocessingRecordSource*
getExternalSource() const

Description

Retrieve the external source for preprocessed entities.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:506

llvm::iterator_range<iterator>
getIteratorsForLoadedRange(unsigned int start,
                           unsigned int count)

Description

iterator range for the given range of loaded preprocessed entities.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:474

Parameters

unsigned int start
unsigned int count

clang::PreprocessedEntity*
getLoadedPreprocessedEntity(unsigned int Index)

Description

Retrieve the loaded preprocessed entity at the given index.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:362

Parameters

unsigned int Index

unsigned int getNumLoadedPreprocessedEntities()
    const

Description

Determine the number of preprocessed entities that were loaded (or can be loaded) from an external source.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:366

static clang::PreprocessingRecord::PPEntityID
getPPEntityID(unsigned int Index, bool isLoaded)

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:348

Parameters

unsigned int Index
bool isLoaded

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

Description

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

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:488

Parameters

clang::SourceRange R
the range to look for preprocessed entities.

std::pair<int, int>
getPreprocessedEntitiesInRangeSlow(
    clang::SourceRange R)

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:564

Parameters

clang::SourceRange R

clang::PreprocessedEntity* getPreprocessedEntity(
    clang::PreprocessingRecord::PPEntityID PPID)

Description

Retrieve the preprocessed entity at the given ID.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:359

Parameters

clang::PreprocessingRecord::PPEntityID PPID

const std::vector<SourceRange>& getSkippedRanges()

Description

Retrieve all ranges that got skipped while preprocessing.

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:515

clang::SourceManager& getSourceManager() const

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:410

size_t getTotalMemory() const

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:408

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

Description

Returns true if the preprocessed entity that \p PPEI iterator points to is coming from the file \p 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

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:497

Parameters

clang::PreprocessingRecord::iterator PPEI
clang::FileID FID

clang::PreprocessingRecord::iterator local_begin()

Description

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

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:463

clang::PreprocessingRecord::iterator local_end()

Description

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

Declared at: clang/include/clang/Lex/PreprocessingRecord.h:468