clang: clang::serialization::ModuleManager Class Reference (original) (raw)

Manages the set of modules loaded by an AST reader. More...

#include "[clang/Serialization/ModuleManager.h](ModuleManager%5F8h%5Fsource.html)"

Public Types
enum AddModuleResult { AlreadyLoaded, NewlyLoaded, Missing, OutOfDate }
The result of attempting to add a new module. More...
using ModuleIterator = llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::iterator >
using ModuleConstIterator = llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::const_iterator >
using ModuleReverseIterator = llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::reverse_iterator >
using ModuleOffset = std::pair< uint32_t, StringRef >
using ASTFileSignatureReader = ASTFileSignature(*)(StringRef)
Public Member Functions
ModuleManager (FileManager &FileMgr, InMemoryModuleCache &ModuleCache, const PCHContainerReader &PCHContainerRdr, const HeaderSearch &HeaderSearchInfo)
ModuleIterator begin ()
Forward iterator to traverse all loaded modules.
ModuleIterator end ()
Forward iterator end-point to traverse all loaded modules.
ModuleConstIterator begin () const
Const forward iterator to traverse all loaded modules.
ModuleConstIterator end () const
Const forward iterator end-point to traverse all loaded modules.
ModuleReverseIterator rbegin ()
Reverse iterator to traverse all loaded modules.
ModuleReverseIterator rend ()
Reverse iterator end-point to traverse all loaded modules.
llvm::iterator_range< SmallVectorImpl< ModuleFile * >::const_iterator > pch_modules () const
A range covering the PCH and preamble module files loaded.
ModuleFile & getPrimaryModule ()
Returns the primary module associated with the manager, that is, the first module loaded.
ModuleFile & getPrimaryModule () const
Returns the primary module associated with the manager, that is, the first module loaded.
ModuleFile & operator[] (unsigned Index) const
Returns the module associated with the given index.
ModuleFile * lookupByFileName (StringRef FileName) const
Returns the module associated with the given file name.
ModuleFile * lookupByModuleName (StringRef ModName) const
Returns the module associated with the given module name.
ModuleFile * lookup (const FileEntry *File) const
Returns the module associated with the given module file.
std::unique_ptr< llvm::MemoryBuffer > lookupBuffer (StringRef Name)
Returns the in-memory (virtual file) buffer with the given name.
unsigned size () const
Number of modules loaded.
AddModuleResult addModule (StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, ModuleFile *ImportedBy, unsigned Generation, off_t ExpectedSize, time_t ExpectedModTime, ASTFileSignature ExpectedSignature, ASTFileSignatureReader ReadSignature, ModuleFile *&Module, std::string &ErrorStr)
Attempts to create a new module and add it to the list of known modules.
void removeModules (ModuleIterator First)
Remove the modules starting from First (to the end).
void addInMemoryBuffer (StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add an in-memory buffer the list of known buffers.
void setGlobalIndex (GlobalModuleIndex *Index)
Set the global module index.
void moduleFileAccepted (ModuleFile *MF)
Notification from the AST reader that the given module file has been "accepted", and will not (can not) be unloaded.
void visit (llvm::function_ref< bool(ModuleFile &M)> Visitor, llvm::SmallPtrSetImpl< ModuleFile * > *ModuleFilesHit=nullptr)
Visit each of the modules.
bool lookupModuleFile (StringRef FileName, off_t ExpectedSize, time_t ExpectedModTime, OptionalFileEntryRef &File)
Attempt to resolve the given module file name to a file entry.
void viewGraph ()
View the graphviz representation of the module graph.
InMemoryModuleCache & getModuleCache () const

Manages the set of modules loaded by an AST reader.

Definition at line 46 of file ModuleManager.h.

ASTFileSignatureReader

ModuleConstIterator

ModuleIterator

ModuleOffset

ModuleReverseIterator

AddModuleResult

The result of attempting to add a new module.

Enumerator
AlreadyLoaded The module file had already been loaded.
NewlyLoaded The module file was just loaded in response to this call.
Missing The module file is missing.
OutOfDate The module file is out-of-date.

Definition at line 191 of file ModuleManager.h.

addInMemoryBuffer()

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

addModule()

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

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

Parameters

FileName The file name of the module to be loaded.
Type The kind of module being loaded.
ImportLoc The location at which the module is imported.
ImportedBy The module that is importing this module, or NULL if this module is imported directly by the user.
Generation The generation in which this module was loaded.
ExpectedSize The expected size of the module file, used for validation. This will be zero if unknown.
ExpectedModTime The expected modification time of the module file, used for validation. This will be zero if unknown.
ExpectedSignature The expected signature of the module file, used for validation. This will be zero if unknown.
ReadSignature Reads the signature from an AST file without actually loading it.
Module A pointer to the module file if the module was successfully loaded.
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.

Definition at line 99 of file ModuleManager.cpp.

References clang::InMemoryModuleCache::addPCM(), AlreadyLoaded, checkSignature(), clang::FileEntryRef::closeFile(), clang::PCHContainerReader::ExtractPCH(), clang::FileName, clang::FileManager::getBufferForFile(), getModuleCache(), clang::FileManager::getNoncachedStatValue(), clang::serialization::ModuleFile::getTimestampFilename(), lookupBuffer(), lookupModuleFile(), Missing, clang::serialization::MK_ExplicitModule, clang::serialization::MK_ImplicitModule, clang::serialization::MK_PrebuiltModule, NewlyLoaded, OutOfDate, and updateModuleImports().

begin() [1/2]

begin() [2/2]

Const forward iterator to traverse all loaded modules.

Definition at line 147 of file ModuleManager.h.

end() [1/2]

end() [2/2]

Const forward iterator end-point to traverse all loaded modules.

Definition at line 150 of file ModuleManager.h.

getModuleCache()

getPrimaryModule() [1/2]

ModuleFile & clang::serialization::ModuleManager::getPrimaryModule ( ) inline

getPrimaryModule() [2/2]

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

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

Definition at line 170 of file ModuleManager.h.

lookup()

lookupBuffer()

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

lookupByFileName()

ModuleFile * ModuleManager::lookupByFileName ( StringRef FileName ) const

lookupByModuleName()

ModuleFile * ModuleManager::lookupByModuleName ( StringRef ModName ) const

lookupModuleFile()

bool ModuleManager::lookupModuleFile ( StringRef FileName,
off_t ExpectedSize,
time_t ExpectedModTime,
OptionalFileEntryRef & File
)

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

Parameters

FileName The name of the module file.
ExpectedSize The size that the module file is expected to have. If the actual size differs, the resolver should return true.
ExpectedModTime The modification time that the module file is expected to have. If the actual modification time differs, the resolver should return true.
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.

Definition at line 435 of file ModuleManager.cpp.

References clang::File, clang::FileName, clang::FileManager::getOptionalFileRef(), and clang::FileManager::getSTDIN().

Referenced by addModule().

moduleFileAccepted()

void ModuleManager::moduleFileAccepted ( ModuleFile * MF )

operator[]()

ModuleFile & clang::serialization::ModuleManager::operator[] ( unsigned Index) const inline

Returns the module associated with the given index.

Definition at line 173 of file ModuleManager.h.

pch_modules()

llvm::iterator_range< SmallVectorImpl< ModuleFile * >::const_iterator > clang::serialization::ModuleManager::pch_modules ( ) const inline

rbegin()

removeModules()

rend()

Reverse iterator end-point to traverse all loaded modules.

Definition at line 156 of file ModuleManager.h.

setGlobalIndex()

size()

unsigned clang::serialization::ModuleManager::size ( ) const inline

viewGraph()

void ModuleManager::viewGraph ( )

View the graphviz representation of the module graph.

Definition at line 498 of file ModuleManager.cpp.

visit()

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

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.

Parameters

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

Definition at line 334 of file ModuleManager.cpp.

References clang::serialization::ModuleFile::ImportedBy, clang::serialization::ModuleFile::Imports, clang::serialization::ModuleFile::Index, and size().

Referenced by clang::ASTReader::ReadMethodPool().


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