14#ifndef LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H
15#define LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H
21#include "llvm/ADT/DenseMap.h"
22#include "llvm/ADT/STLExtras.h"
23#include "llvm/ADT/SmallPtrSet.h"
24#include "llvm/ADT/SmallVector.h"
25#include "llvm/ADT/StringRef.h"
26#include "llvm/ADT/iterator.h"
27#include "llvm/ADT/iterator_range.h"
66 assert(K ==
Missing && !Module);
77 return ValidationStatus;
82 return SignatureError;
87 ValidationStatus = Status;
97 std::string BufferError;
98 std::string SignatureError;
117 llvm::DenseMap<ModuleFileKey, ModuleFile *> Modules;
134 llvm::DenseMap<const FileEntry *, std::unique_ptr<llvm::MemoryBuffer>>
156 bool isModuleFileOutOfDate(off_t Size, time_t ModTime, off_t ExpectedSize,
166 explicit VisitState(
unsigned N) : VisitNumber(N, 0) {
179 unsigned NextVisitNumber = 1;
182 std::unique_ptr<VisitState> NextState;
186 std::unique_ptr<VisitState> FirstVisitState;
188 std::unique_ptr<VisitState> allocateVisitState();
189 void returnVisitState(std::unique_ptr<VisitState> State);
223 llvm::iterator_range<SmallVectorImpl<ModuleFile *>::const_iterator>
225 return llvm::make_range(PCHChain.begin(), PCHChain.end());
249 std::unique_ptr<llvm::MemoryBuffer>
lookupBuffer(StringRef Name, off_t &Size,
253 unsigned size()
const {
return Chain.size(); }
287 unsigned Generation, off_t ExpectedSize,
288 time_t ExpectedModTime,
297 std::unique_ptr<llvm::MemoryBuffer> Buffer);
326 llvm::SmallPtrSetImpl<ModuleFile *> *ModuleFilesHit =
nullptr);
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Cached information about one file (either on disk or in the virtual file system).
Implements support for file system lookup, file system caching, and directory search management.
A global index for a set of module files, providing information about the identifiers within those mo...
The module cache used for compiling modules implicitly.
Deduplication key for a loaded module file in ModuleManager.
Identifies a module file to be loaded.
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
Encodes a location in the source.
The base class of the type hierarchy.
The result of attempting to add a new module.
StringRef getSignatureError() const
InputFilesValidation getValidationStatus() const
ModuleFile * getModule() const
friend class ModuleManager
const SmallVector< Change, 2 > & getChanges() const
void setOutOfDate(InputFilesValidation Status)
StringRef getBufferError() const
@ Missing
The module file is missing.
@ OutOfDate
The module file is out-of-date.
@ NewlyLoaded
The module file was just loaded in response to this call.
@ None
State at construction.
@ AlreadyLoaded
The module file had already been loaded.
Information about a module that has been loaded by the ASTReader.
std::unique_ptr< llvm::MemoryBuffer > lookupBuffer(StringRef Name, off_t &Size, time_t &ModTime)
Returns the in-memory (virtual file) buffer with the given name.
AddModuleResult addModule(ModuleFileName FileName, ModuleKind Type, SourceLocation ImportLoc, ModuleFile *ImportedBy, unsigned Generation, off_t ExpectedSize, time_t ExpectedModTime, ASTFileSignature ExpectedSignature, ASTFileSignatureReader ReadSignature)
Attempts to create a new module and add it to the list of known modules.
ModuleFile * lookup(ModuleFileKey Key) const
Returns the module associated with the given module file key.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::iterator > ModuleIterator
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
ModuleFile & getPrimaryModule() const
Returns the primary module associated with the manager, that is, the first module loaded.
llvm::iterator_range< SmallVectorImpl< ModuleFile * >::const_iterator > pch_modules() const
A range covering the PCH and preamble module files loaded.
void moduleFileAccepted(ModuleFile *MF)
Notification from the AST reader that the given module file has been "accepted", and will not (can no...
ModuleReverseIterator rbegin()
Reverse iterator to traverse all loaded modules.
ModuleManager(FileManager &FileMgr, ModuleCache &ModCache, const PCHContainerReader &PCHContainerRdr, const HeaderSearch &HeaderSearchInfo)
std::pair< uint32_t, StringRef > ModuleOffset
void viewGraph()
View the graphviz representation of the module graph.
ModuleConstIterator begin() const
Const forward iterator to traverse all loaded modules.
ModuleCache & getModuleCache() const
ModuleFile & operator[](unsigned Index) const
Returns the module associated with the given index.
ModuleIterator begin()
Forward iterator to traverse all loaded modules.
void setGlobalIndex(GlobalModuleIndex *Index)
Set the global module index.
void removeModules(ModuleIterator First)
Remove the modules starting from First (to the end).
ModuleConstIterator end() const
Const forward iterator end-point to traverse all loaded modules.
ModuleIterator end()
Forward iterator end-point to traverse all loaded modules.
void addInMemoryBuffer(StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add an in-memory buffer the list of known buffers.
ModuleReverseIterator rend()
Reverse iterator end-point to traverse all loaded modules.
void visit(llvm::function_ref< bool(ModuleFile &M)> Visitor, llvm::SmallPtrSetImpl< ModuleFile * > *ModuleFilesHit=nullptr)
Visit each of the modules.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::reverse_iterator > ModuleReverseIterator
unsigned size() const
Number of modules loaded.
ModuleFile * lookupByFileName(ModuleFileName FileName) const
Returns the module associated with the given module file name.
ASTFileSignature(*)(StringRef) ASTFileSignatureReader
ModuleFile * lookupByModuleName(StringRef ModName) const
Returns the module associated with the given module name.
InputFilesValidation
Specifies the high-level result of validating input files.
@ NotStarted
Initial value, before the validation has been performed.
ModuleKind
Specifies the kind of module that has been loaded.
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
The signature of a module, which is a hash of the AST content.