class ModuleManager

Declaration

class ModuleManager { /* full declaration omitted */ };

Description

Manages the set of modules loaded by an AST reader.

Declared at: clang/include/clang/Serialization/ModuleManager.h:48

Member Variables

private SmallVector<std::unique_ptr<ModuleFile>, 2> Chain
The chain of AST files, in the order in which we started to load them (this order isn't really useful for anything).
private SmallVector<clang::serialization::ModuleFile*, 2> PCHChain
The chain of non-module PCH files. The first entry is the one named by the user, the last one is the one that doesn't depend on anything further.
private SmallVector<clang::serialization::ModuleFile*, 2> Roots
private llvm::DenseMap<const FileEntry*, ModuleFile*> Modules
All loaded modules, indexed by name.
private clang::FileManager& FileMgr
FileManager that handles translating between filenames and FileEntry *.
private IntrusiveRefCntPtr<clang::InMemoryModuleCache> ModuleCache
Cache of PCM files.
private const clang::PCHContainerReader& PCHContainerRdr
Knows how to unwrap module containers.
private const clang::HeaderSearch& HeaderSearchInfo
Preprocessor's HeaderSearchInfo containing the module map.
private llvm::DenseMap< const FileEntry*, std::unique_ptr<llvm::MemoryBuffer>> InMemoryBuffers
A lookup of in-memory (virtual file) buffers
private SmallVector<clang::serialization::ModuleFile*, 4> VisitOrder
The visitation order.
private SmallVector<clang::serialization::ModuleFile*, 4> ModulesInCommonWithGlobalIndex
Either the global index or the module manager may have modules that the other does not know about, because the global index can be out-of-date (in which case the module manager could have modules it does not) and this particular translation unit might not have loaded all of the modules known to the global index.
private clang::GlobalModuleIndex* GlobalIndex = nullptr
The global module index will actually be owned by the ASTReader; this is just an non-owning pointer.
private std::unique_ptr<VisitState> FirstVisitState
The first visit() state in the chain.

Method Overview

  • public ModuleManager(clang::FileManager & FileMgr, clang::InMemoryModuleCache & ModuleCache, const clang::PCHContainerReader & PCHContainerRdr, const clang::HeaderSearch & HeaderSearchInfo)
  • public void addInMemoryBuffer(llvm::StringRef FileName, std::unique_ptr<llvm::MemoryBuffer> Buffer)
  • public clang::serialization::ModuleManager::AddModuleResult addModule(llvm::StringRef FileName, clang::serialization::ModuleKind Type, clang::SourceLocation ImportLoc, clang::serialization::ModuleFile * ImportedBy, unsigned int Generation, off_t ExpectedSize, time_t ExpectedModTime, clang::ASTFileSignature ExpectedSignature, clang::serialization::ModuleManager::ASTFileSignatureReader ReadSignature, clang::serialization::ModuleFile *& Module, std::string & ErrorStr)
  • private std::unique_ptr<VisitState> allocateVisitState()
  • public clang::serialization::ModuleManager::ModuleIterator begin()
  • public clang::serialization::ModuleManager::ModuleConstIterator begin() const
  • public clang::serialization::ModuleManager::ModuleIterator end()
  • public clang::serialization::ModuleManager::ModuleConstIterator end() const
  • public clang::InMemoryModuleCache & getModuleCache() const
  • public clang::serialization::ModuleFile & getPrimaryModule()
  • public clang::serialization::ModuleFile & getPrimaryModule() const
  • public clang::serialization::ModuleFile * lookup(const clang::FileEntry * File) const
  • public std::unique_ptr<llvm::MemoryBuffer> lookupBuffer(llvm::StringRef Name)
  • public clang::serialization::ModuleFile * lookupByFileName(llvm::StringRef FileName) const
  • public clang::serialization::ModuleFile * lookupByModuleName(llvm::StringRef ModName) const
  • public bool lookupModuleFile(llvm::StringRef FileName, off_t ExpectedSize, time_t ExpectedModTime, Optional<clang::FileEntryRef> & File)
  • public void moduleFileAccepted(clang::serialization::ModuleFile * MF)
  • public llvm::iterator_range<SmallVectorImpl<ModuleFile *>::const_iterator> pch_modules() const
  • public clang::serialization::ModuleManager::ModuleReverseIterator rbegin()
  • public void removeModules(clang::serialization::ModuleManager::ModuleIterator First, clang::ModuleMap * modMap)
  • public clang::serialization::ModuleManager::ModuleReverseIterator rend()
  • private void returnVisitState(std::unique_ptr<VisitState> State)
  • public void setGlobalIndex(clang::GlobalModuleIndex * Index)
  • public unsigned int size() const
  • public void viewGraph()
  • public void visit(llvm::function_ref<bool (ModuleFile &)> Visitor, llvm::SmallPtrSetImpl<ModuleFile *> * ModuleFilesHit = nullptr)

Methods

ModuleManager(
    clang::FileManager& FileMgr,
    clang::InMemoryModuleCache& ModuleCache,
    const clang::PCHContainerReader&
        PCHContainerRdr,
    const clang::HeaderSearch& HeaderSearchInfo)

Declared at: clang/include/clang/Serialization/ModuleManager.h:138

Parameters

clang::FileManager& FileMgr
clang::InMemoryModuleCache& ModuleCache
const clang::PCHContainerReader& PCHContainerRdr
const clang::HeaderSearch& HeaderSearchInfo

void addInMemoryBuffer(
    llvm::StringRef FileName,
    std::unique_ptr<llvm::MemoryBuffer> Buffer)

Description

Add an in-memory buffer the list of known buffers

Declared at: clang/include/clang/Serialization/ModuleManager.h:256

Parameters

llvm::StringRef FileName
std::unique_ptr<llvm::MemoryBuffer> Buffer

clang::serialization::ModuleManager::
    AddModuleResult
    addModule(
        llvm::StringRef FileName,
        clang::serialization::ModuleKind Type,
        clang::SourceLocation ImportLoc,
        clang::serialization::ModuleFile*
            ImportedBy,
        unsigned int Generation,
        off_t ExpectedSize,
        time_t ExpectedModTime,
        clang::ASTFileSignature ExpectedSignature,
        clang::serialization::ModuleManager::
            ASTFileSignatureReader ReadSignature,
        clang::serialization::ModuleFile*& Module,
        std::string& ErrorStr)

Description

Attempts to create a new module and add it to the list of known modules.

Declared at: clang/include/clang/Serialization/ModuleManager.h:243

Parameters

llvm::StringRef FileName
The file name of the module to be loaded.
clang::serialization::ModuleKind Type
The kind of module being loaded.
clang::SourceLocation ImportLoc
The location at which the module is imported.
clang::serialization::ModuleFile* ImportedBy
The module that is importing this module, or NULL if this module is imported directly by the user.
unsigned int Generation
The generation in which this module was loaded.
off_t ExpectedSize
The expected size of the module file, used for validation. This will be zero if unknown.
time_t ExpectedModTime
The expected modification time of the module file, used for validation. This will be zero if unknown.
clang::ASTFileSignature ExpectedSignature
The expected signature of the module file, used for validation. This will be zero if unknown.
clang::serialization::ModuleManager:: ASTFileSignatureReader ReadSignature
Reads the signature from an AST file without actually loading it.
clang::serialization::ModuleFile*& Module
A pointer to the module file if the module was successfully loaded.
std::string& ErrorStr
Will be set to a non-empty string if any errors occurred while trying to load the module.

Returns

A pointer to the module that corresponds to this file name, and a value indicating whether the module was loaded.

std::unique_ptr<VisitState> allocateVisitState()

Declared at: clang/include/clang/Serialization/ModuleManager.h:126

clang::serialization::ModuleManager::
    ModuleIterator
    begin()

Description

Forward iterator to traverse all loaded modules.

Declared at: clang/include/clang/Serialization/ModuleManager.h:143

clang::serialization::ModuleManager::
    ModuleConstIterator
    begin() const

Description

Const forward iterator to traverse all loaded modules.

Declared at: clang/include/clang/Serialization/ModuleManager.h:149

clang::serialization::ModuleManager::
    ModuleIterator
    end()

Description

Forward iterator end-point to traverse all loaded modules

Declared at: clang/include/clang/Serialization/ModuleManager.h:146

clang::serialization::ModuleManager::
    ModuleConstIterator
    end() const

Description

Const forward iterator end-point to traverse all loaded modules

Declared at: clang/include/clang/Serialization/ModuleManager.h:152

clang::InMemoryModuleCache& getModuleCache() const

Declared at: clang/include/clang/Serialization/ModuleManager.h:311

clang::serialization::ModuleFile&
getPrimaryModule()

Description

Returns the primary module associated with the manager, that is, the first module loaded

Declared at: clang/include/clang/Serialization/ModuleManager.h:168

clang::serialization::ModuleFile&
getPrimaryModule() const

Description

Returns the primary module associated with the manager, that is, the first module loaded.

Declared at: clang/include/clang/Serialization/ModuleManager.h:172

clang::serialization::ModuleFile* lookup(
    const clang::FileEntry* File) const

Description

Returns the module associated with the given module file.

Declared at: clang/include/clang/Serialization/ModuleManager.h:184

Parameters

const clang::FileEntry* File

std::unique_ptr<llvm::MemoryBuffer> lookupBuffer(
    llvm::StringRef Name)

Description

Returns the in-memory (virtual file) buffer with the given name

Declared at: clang/include/clang/Serialization/ModuleManager.h:187

Parameters

llvm::StringRef Name

clang::serialization::ModuleFile*
lookupByFileName(llvm::StringRef FileName) const

Description

Returns the module associated with the given file name.

Declared at: clang/include/clang/Serialization/ModuleManager.h:178

Parameters

llvm::StringRef FileName

clang::serialization::ModuleFile*
lookupByModuleName(llvm::StringRef ModName) const

Description

Returns the module associated with the given module name.

Declared at: clang/include/clang/Serialization/ModuleManager.h:181

Parameters

llvm::StringRef ModName

bool lookupModuleFile(
    llvm::StringRef FileName,
    off_t ExpectedSize,
    time_t ExpectedModTime,
    Optional<clang::FileEntryRef>& File)

Description

Attempt to resolve the given module file name to a file entry.

Declared at: clang/include/clang/Serialization/ModuleManager.h:305

Parameters

llvm::StringRef FileName
The name of the module file.
off_t ExpectedSize
The size that the module file is expected to have. If the actual size differs, the resolver should return \c true.
time_t ExpectedModTime
The modification time that the module file is expected to have. If the actual modification time differs, the resolver should return \c true.
Optional<clang::FileEntryRef>& File
Will be set to the file if there is one, or null otherwise.

Returns

True if a file exists but does not meet the size/ modification time criteria, false if the file is either available and suitable, or is missing.

void moduleFileAccepted(
    clang::serialization::ModuleFile* MF)

Description

Notification from the AST reader that the given module file has been "accepted", and will not (can not) be unloaded.

Declared at: clang/include/clang/Serialization/ModuleManager.h:264

Parameters

clang::serialization::ModuleFile* MF

llvm::iterator_range<
    SmallVectorImpl<ModuleFile*>::const_iterator>
pch_modules() const

Description

A range covering the PCH and preamble module files loaded.

Declared at: clang/include/clang/Serialization/ModuleManager.h:162

clang::serialization::ModuleManager::
    ModuleReverseIterator
    rbegin()

Description

Reverse iterator to traverse all loaded modules.

Declared at: clang/include/clang/Serialization/ModuleManager.h:155

void removeModules(
    clang::serialization::ModuleManager::
        ModuleIterator First,
    clang::ModuleMap* modMap)

Description

Remove the modules starting from First (to the end).

Declared at: clang/include/clang/Serialization/ModuleManager.h:253

Parameters

clang::serialization::ModuleManager:: ModuleIterator First
clang::ModuleMap* modMap

clang::serialization::ModuleManager::
    ModuleReverseIterator
    rend()

Description

Reverse iterator end-point to traverse all loaded modules.

Declared at: clang/include/clang/Serialization/ModuleManager.h:158

void returnVisitState(
    std::unique_ptr<VisitState> State)

Declared at: clang/include/clang/Serialization/ModuleManager.h:127

Parameters

std::unique_ptr<VisitState> State

void setGlobalIndex(
    clang::GlobalModuleIndex* Index)

Description

Set the global module index.

Declared at: clang/include/clang/Serialization/ModuleManager.h:260

Parameters

clang::GlobalModuleIndex* Index

unsigned int size() const

Description

Number of modules loaded

Declared at: clang/include/clang/Serialization/ModuleManager.h:190

void viewGraph()

Description

View the graphviz representation of the module graph.

Declared at: clang/include/clang/Serialization/ModuleManager.h:309

void visit(
    llvm::function_ref<bool(ModuleFile&)> Visitor,
    llvm::SmallPtrSetImpl<ModuleFile*>*
        ModuleFilesHit = nullptr)

Description

Visit each of the modules. This routine visits each of the modules, starting with the "root" modules that no other loaded modules depend on, and proceeding to the leaf modules, visiting each module only once during the traversal. This traversal is intended to support various "lookup" operations that can find data in any of the loaded modules.

Declared at: clang/include/clang/Serialization/ModuleManager.h:285

Parameters

llvm::function_ref<bool(ModuleFile&)> Visitor
A visitor function that will be invoked with each module. The return value must be convertible to bool; when false, the visitation continues to modules that the current module depends on. When true, the visitation skips any modules that the current module depends on.
llvm::SmallPtrSetImpl<ModuleFile*>* ModuleFilesHit = nullptr
If non-NULL, contains the set of module files that we know we need to visit because the global module index told us to. Any module that is known to both the global module index and the module manager that is *not* in this set can be skipped.