Go to the documentation of this file.
14 #ifndef LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H
15 #define LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H
21 #include "llvm/ADT/DenseMap.h"
22 #include "llvm/ADT/IntrusiveRefCntPtr.h"
23 #include "llvm/ADT/STLExtras.h"
24 #include "llvm/ADT/SmallPtrSet.h"
25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/StringRef.h"
27 #include "llvm/ADT/iterator.h"
28 #include "llvm/ADT/iterator_range.h"
39 class GlobalModuleIndex;
41 class InMemoryModuleCache;
43 class PCHContainerReader;
45 namespace serialization {
63 llvm::DenseMap<const FileEntry *, ModuleFile *> Modules;
79 llvm::DenseMap<const FileEntry *, std::unique_ptr<llvm::MemoryBuffer>>
104 explicit VisitState(
unsigned N) : VisitNumber(N, 0) {
117 unsigned NextVisitNumber = 1;
120 std::unique_ptr<VisitState> NextState;
124 std::unique_ptr<VisitState> FirstVisitState;
126 std::unique_ptr<VisitState> allocateVisitState();
127 void returnVisitState(std::unique_ptr<VisitState>
State);
161 llvm::iterator_range<SmallVectorImpl<ModuleFile *>::const_iterator>
163 return llvm::make_range(PCHChain.begin(), PCHChain.end());
187 std::unique_ptr<llvm::MemoryBuffer>
lookupBuffer(StringRef Name);
190 unsigned size()
const {
return Chain.size(); }
246 off_t ExpectedSize, time_t ExpectedModTime,
257 std::unique_ptr<llvm::MemoryBuffer> Buffer);
286 llvm::SmallPtrSetImpl<ModuleFile *> *ModuleFilesHit =
nullptr);
318 #endif // LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H
A global index for a set of module files, providing information about the identifiers within those mo...
void setGlobalIndex(GlobalModuleIndex *Index)
Set the global module index.
Manages the set of modules loaded by an AST reader.
@ OutOfDate
The module file is out-of-date.
void addInMemoryBuffer(StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add an in-memory buffer the list of known buffers.
Encodes a location in the source.
void removeModules(ModuleIterator First, ModuleMap *modMap)
Remove the modules starting from First (to the end).
unsigned size() const
Number of modules loaded.
@ AlreadyLoaded
The module file had already been loaded.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::reverse_iterator > ModuleReverseIterator
ModuleManager(FileManager &FileMgr, InMemoryModuleCache &ModuleCache, const PCHContainerReader &PCHContainerRdr, const HeaderSearch &HeaderSearchInfo)
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
The base class of the type hierarchy.
Describes a module or submodule.
ModuleFile & getPrimaryModule() const
Returns the primary module associated with the manager, that is, the first module loaded.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::iterator > ModuleIterator
std::unique_ptr< llvm::MemoryBuffer > lookupBuffer(StringRef Name)
Returns the in-memory (virtual file) buffer with the given name.
void visit(llvm::function_ref< bool(ModuleFile &M)> Visitor, llvm::SmallPtrSetImpl< ModuleFile * > *ModuleFilesHit=nullptr)
Visit each of the modules.
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 viewGraph()
View the graphviz representation of the module graph.
The signature of a module, which is a hash of the AST content.
Cached information about one file (either on disk or in the virtual file system).
llvm::iterator_range< SmallVectorImpl< ModuleFile * >::const_iterator > pch_modules() const
A range covering the PCH and preamble module files loaded.
@ Missing
The module file is missing.
ModuleFile & operator[](unsigned Index) const
Returns the module associated with the given index.
InMemoryModuleCache & getModuleCache() const
ModuleFile * lookupByModuleName(StringRef ModName) const
Returns the module associated with the given module name.
bool lookupModuleFile(StringRef FileName, off_t ExpectedSize, time_t ExpectedModTime, Optional< FileEntryRef > &File)
Attempt to resolve the given module file name to a file entry.
ModuleFile * lookupByFileName(StringRef FileName) const
Returns the module associated with the given file name.
ASTFileSignature(*)(StringRef) ASTFileSignatureReader
void moduleFileAccepted(ModuleFile *MF)
Notification from the AST reader that the given module file has been "accepted", and will not (can no...
@ NewlyLoaded
The module file was just loaded in response to this call.
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::const_iterator > ModuleConstIterator
ModuleIterator begin()
Forward iterator 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.
std::pair< uint32_t, StringRef > ModuleOffset
Implements support for file system lookup, file system caching, and directory search management.
AddModuleResult
The result of attempting to add a new module.
In-memory cache for modules.
ModuleFile * lookup(const FileEntry *File) const
Returns the module associated with the given module file.
ModuleConstIterator begin() const
Const forward iterator to traverse all loaded modules.
ModuleIterator end()
Forward iterator end-point to traverse all loaded modules.
ModuleKind
Specifies the kind of module that has been loaded.
ModuleConstIterator end() const
Const forward iterator end-point to traverse all loaded modules.
Information about a module that has been loaded by the ASTReader.