clang API Documentation

Public Types | Public Member Functions
clang::serialization::ModuleManager Class Reference

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

#include <ModuleManager.h>

List of all members.

Public Types

typedef SmallVector
< ModuleFile *, 2 >::iterator 
ModuleIterator
typedef SmallVector
< ModuleFile *, 2 >
::const_iterator 
ModuleConstIterator
typedef SmallVector
< ModuleFile *, 2 >
::reverse_iterator 
ModuleReverseIterator
typedef std::pair< uint32_t,
StringRef > 
ModuleOffset

Public Member Functions

 ModuleManager (const FileSystemOptions &FSO)
 ~ModuleManager ()
ModuleIterator begin ()
 Forward iterator to traverse all loaded modules. This is reverse source-order.
ModuleIterator end ()
 Forward iterator end-point to traverse all loaded modules.
ModuleConstIterator begin () const
 Const forward iterator to traverse all loaded modules. This is in reverse source-order.
ModuleConstIterator end () const
 Const forward iterator end-point to traverse all loaded modules.
ModuleReverseIterator rbegin ()
 Reverse iterator to traverse all loaded modules. This is in source order.
ModuleReverseIterator rend ()
 Reverse iterator end-point to traverse all loaded modules.
ModuleFilegetPrimaryModule ()
 Returns the primary module associated with the manager, that is, the first module loaded.
ModuleFilegetPrimaryModule () const
 Returns the primary module associated with the manager, that is, the first module loaded.
ModuleFileoperator[] (unsigned Index) const
 Returns the module associated with the given index.
ModuleFilelookup (StringRef Name)
 Returns the module associated with the given name.
llvm::MemoryBuffer * lookupBuffer (StringRef Name)
 Returns the in-memory (virtual file) buffer with the given name.
unsigned size () const
 Number of modules loaded.
std::pair< ModuleFile *, bool > addModule (StringRef FileName, ModuleKind Type, ModuleFile *ImportedBy, unsigned Generation, std::string &ErrorStr)
 Attempts to create a new module and add it to the list of known modules.
void addInMemoryBuffer (StringRef FileName, llvm::MemoryBuffer *Buffer)
 Add an in-memory buffer the list of known buffers.
void visit (bool(*Visitor)(ModuleFile &M, void *UserData), void *UserData)
 Visit each of the modules.
void visitDepthFirst (bool(*Visitor)(ModuleFile &M, bool Preorder, void *UserData), void *UserData)
 Visit each of the modules with a depth-first traversal.
void viewGraph ()
 View the graphviz representation of the module graph.

Detailed Description

Manages the set of modules loaded by an AST reader.

Definition at line 27 of file ModuleManager.h.


Member Typedef Documentation

typedef SmallVector<ModuleFile*, 2>::const_iterator clang::serialization::ModuleManager::ModuleConstIterator

Definition at line 44 of file ModuleManager.h.

Definition at line 43 of file ModuleManager.h.

typedef std::pair<uint32_t, StringRef> clang::serialization::ModuleManager::ModuleOffset

Definition at line 46 of file ModuleManager.h.

typedef SmallVector<ModuleFile*, 2>::reverse_iterator clang::serialization::ModuleManager::ModuleReverseIterator

Definition at line 45 of file ModuleManager.h.


Constructor & Destructor Documentation

ModuleManager::ModuleManager ( const FileSystemOptions FSO)

Definition at line 98 of file ModuleManager.cpp.

ModuleManager::~ModuleManager ( )

Definition at line 100 of file ModuleManager.cpp.


Member Function Documentation

void ModuleManager::addInMemoryBuffer ( StringRef  FileName,
llvm::MemoryBuffer *  Buffer 
)

Add an in-memory buffer the list of known buffers.

Definition at line 90 of file ModuleManager.cpp.

References clang::FileManager::getVirtualFile().

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

std::pair< ModuleFile *, bool > ModuleManager::addModule ( StringRef  FileName,
ModuleKind  Type,
ModuleFile ImportedBy,
unsigned  Generation,
std::string &  ErrorStr 
)

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

Parameters:
FileNameThe file name of the module to be loaded.
TypeThe kind of module being loaded.
ImportedByThe module that is importing this module, or NULL if this module is imported directly by the user.
GenerationThe generation in which this module was loaded.
ErrorStrWill 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 boolean indicating whether the module was newly added.

Definition at line 37 of file ModuleManager.cpp.

References clang::serialization::ModuleFile::Buffer, clang::serialization::ModuleFile::DirectlyImported, clang::serialization::ModuleFile::FileName, clang::FileManager::getBufferForFile(), clang::FileManager::getFile(), clang::serialization::ModuleFile::ImportedBy, clang::serialization::ModuleFile::Imports, lookupBuffer(), and clang::serialization::ModuleFile::StreamFile.

ModuleIterator clang::serialization::ModuleManager::begin ( ) [inline]

Forward iterator to traverse all loaded modules. This is reverse source-order.

Definition at line 53 of file ModuleManager.h.

Referenced by clang::ASTReader::getTotalNumPreprocessedEntities(), llvm::GraphTraits< ModuleManager >::nodes_begin(), and visit().

ModuleConstIterator clang::serialization::ModuleManager::begin ( ) const [inline]

Const forward iterator to traverse all loaded modules. This is in reverse source-order.

Definition at line 59 of file ModuleManager.h.

ModuleIterator clang::serialization::ModuleManager::end ( ) [inline]

Forward iterator end-point to traverse all loaded modules.

Definition at line 55 of file ModuleManager.h.

Referenced by clang::ASTReader::getTotalNumPreprocessedEntities(), llvm::GraphTraits< ModuleManager >::nodes_end(), and visit().

ModuleConstIterator clang::serialization::ModuleManager::end ( ) const [inline]

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

Definition at line 61 of file ModuleManager.h.

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

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

Definition at line 71 of file ModuleManager.h.

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

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

Definition at line 75 of file ModuleManager.h.

ModuleFile * ModuleManager::lookup ( StringRef  Name)

Returns the module associated with the given name.

Definition at line 26 of file ModuleManager.cpp.

References clang::FileManager::getFile().

llvm::MemoryBuffer * ModuleManager::lookupBuffer ( StringRef  Name)

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

Definition at line 31 of file ModuleManager.cpp.

References clang::FileManager::getFile().

Referenced by addModule().

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

Returns the module associated with the given index.

Definition at line 78 of file ModuleManager.h.

References Index.

ModuleReverseIterator clang::serialization::ModuleManager::rbegin ( ) [inline]

Reverse iterator to traverse all loaded modules. This is in source order.

Definition at line 65 of file ModuleManager.h.

ModuleReverseIterator clang::serialization::ModuleManager::rend ( ) [inline]

Reverse iterator end-point to traverse all loaded modules.

Definition at line 67 of file ModuleManager.h.

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

Number of modules loaded.

Definition at line 87 of file ModuleManager.h.

Referenced by visit().

void ModuleManager::viewGraph ( )

View the graphviz representation of the module graph.

Definition at line 251 of file ModuleManager.cpp.

void ModuleManager::visit ( bool(*)(ModuleFile &M, void *UserData)  Visitor,
void *  UserData 
)

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:
VisitorA visitor function that will be invoked with each module and the given user data pointer. 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.
UserDataUser data associated with the visitor object, which will be passed along to the visitor.

Definition at line 105 of file ModuleManager.cpp.

References begin(), end(), clang::serialization::ModuleFile::Imports, and size().

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

void ModuleManager::visitDepthFirst ( bool(*)(ModuleFile &M, bool Preorder, void *UserData)  Visitor,
void *  UserData 
)

Visit each of the modules with a depth-first traversal.

This routine visits each of the modules known to the module manager using a depth-first search, starting with the first loaded module. The traversal invokes the callback both before traversing the children (preorder traversal) and after traversing the children (postorder traversal).

Parameters:
VisitorA visitor function that will be invoked with each module and given a Preorder flag that indicates whether we're visiting the module before or after visiting its children. The visitor may return true at any time to abort the depth-first visitation.
UserDataUser data ssociated with the visitor object, which will be passed along to the user.

Definition at line 198 of file ModuleManager.cpp.


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