class GlobalModuleIndex
Declaration
class GlobalModuleIndex { /* full declaration omitted */ };
Description
A global index for a set of module files, providing information about the identifiers within those module files. The global index is an aid for name lookup into modules, offering a central place where one can look for identifiers determine which module files contain any information about that identifier. This allows the client to restrict the search to only those module files known to have a information about that identifier, improving performance. Moreover, the global module index may know about module files that have not been imported, and can be queried to determine which modules the current translation could or should load to fix a problem.
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:54
Member Variables
- private std::unique_ptr<llvm::MemoryBuffer> Buffer
- Buffer containing the index file, which is lazily accessed so long as the global module index is live.
- private void* IdentifierIndex
- This pointer actually points to a IdentifierIndexTable object, but that type is only accessible within the implementation of GlobalModuleIndex.
- private llvm::SmallVector<ModuleInfo, 16> Modules
- This vector may have gaps, if module files have been removed or have been updated since the index was built. A gap is indicated by an empty file name.
- private llvm::DenseMap<ModuleFile*, unsigned int> ModulesByFile
- Lazily-populated mapping from module files to their corresponding index into the \c Modules vector.
- private llvm::StringMap<unsigned int> UnresolvedModules
- The string is just the name of the module itself, which maps to the module ID.
- private unsigned int NumIdentifierLookups
- The number of identifier lookups we performed.
- private unsigned int NumIdentifierLookupHits
- The number of identifier lookup hits, where we recognize the identifier.
Method Overview
- private GlobalModuleIndex(std::unique_ptr<llvm::MemoryBuffer> Buffer, llvm::BitstreamCursor Cursor)
- private GlobalModuleIndex(const clang::GlobalModuleIndex &)
- public clang::IdentifierIterator * createIdentifierIterator() const
- public void dump()
- public void getKnownModules(llvm::SmallVectorImpl<ModuleFile *> & ModuleFiles)
- public void getModuleDependencies(clang::GlobalModuleIndex::ModuleFile * File, llvm::SmallVectorImpl<ModuleFile *> & Dependencies)
- public bool loadedModuleFile(clang::GlobalModuleIndex::ModuleFile * File)
- public bool lookupIdentifier(llvm::StringRef Name, clang::GlobalModuleIndex::HitSet & Hits)
- public void printStats()
- public static std::pair<GlobalModuleIndex *, llvm::Error> readIndex(llvm::StringRef Path)
- public static llvm::Error writeIndex(clang::FileManager & FileMgr, const clang::PCHContainerReader & PCHContainerRdr, llvm::StringRef Path)
- public ~GlobalModuleIndex()
Methods
¶GlobalModuleIndex(
std::unique_ptr<llvm::MemoryBuffer> Buffer,
llvm::BitstreamCursor Cursor)
GlobalModuleIndex(
std::unique_ptr<llvm::MemoryBuffer> Buffer,
llvm::BitstreamCursor Cursor)
Description
Internal constructor. Use \c readIndex() to read an index.
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:115
Parameters
- std::unique_ptr<llvm::MemoryBuffer> Buffer
- llvm::BitstreamCursor Cursor
¶GlobalModuleIndex(const clang::GlobalModuleIndex&)
GlobalModuleIndex(const clang::GlobalModuleIndex&)
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:118
Parameters
- const clang::GlobalModuleIndex&
¶clang::IdentifierIterator*
createIdentifierIterator() const
clang::IdentifierIterator*
createIdentifierIterator() const
Description
Returns an iterator for identifiers stored in the index table. The caller accepts ownership of the returned object.
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:137
¶void dump()
void dump()
Description
Print debugging view to standard error.
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:174
¶void getKnownModules(
llvm::SmallVectorImpl<ModuleFile*>&
ModuleFiles)
void getKnownModules(
llvm::SmallVectorImpl<ModuleFile*>&
ModuleFiles)
Description
Retrieve the set of modules that have up-to-date indexes.
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:143
Parameters
- llvm::SmallVectorImpl<ModuleFile*>& ModuleFiles
- Will be populated with the set of module files that have been indexed.
¶void getModuleDependencies(
clang::GlobalModuleIndex::ModuleFile* File,
llvm::SmallVectorImpl<ModuleFile*>&
Dependencies)
void getModuleDependencies(
clang::GlobalModuleIndex::ModuleFile* File,
llvm::SmallVectorImpl<ModuleFile*>&
Dependencies)
Description
Retrieve the set of module files on which the given module file directly depends.
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:147
Parameters
- clang::GlobalModuleIndex::ModuleFile* File
- llvm::SmallVectorImpl<ModuleFile*>& Dependencies
¶bool loadedModuleFile(
clang::GlobalModuleIndex::ModuleFile* File)
bool loadedModuleFile(
clang::GlobalModuleIndex::ModuleFile* File)
Description
Note that the given module file has been loaded.
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:168
Parameters
Returns
false if the global module index has information about this module file, and true otherwise.
¶bool lookupIdentifier(
llvm::StringRef Name,
clang::GlobalModuleIndex::HitSet& Hits)
bool lookupIdentifier(
llvm::StringRef Name,
clang::GlobalModuleIndex::HitSet& Hits)
Description
Look for all of the module files with information about the given identifier, e.g., a global function, variable, or type with that name.
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:162
Parameters
- llvm::StringRef Name
- The identifier to look for.
- clang::GlobalModuleIndex::HitSet& Hits
- Will be populated with the set of module files that have information about this name.
Returns
true if the identifier is known to the index, false otherwise.
¶void printStats()
void printStats()
Description
Print statistics to standard error.
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:171
¶static std::pair<GlobalModuleIndex*, llvm::Error>
readIndex(llvm::StringRef Path)
static std::pair<GlobalModuleIndex*, llvm::Error>
readIndex(llvm::StringRef Path)
Description
Read a global index file for the given directory.
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:132
Parameters
- llvm::StringRef Path
- The path to the specific module cache where the module files for the intended configuration reside.
Returns
A pair containing the global module index (if it exists) and the error.
¶static llvm::Error writeIndex(
clang::FileManager& FileMgr,
const clang::PCHContainerReader&
PCHContainerRdr,
llvm::StringRef Path)
static llvm::Error writeIndex(
clang::FileManager& FileMgr,
const clang::PCHContainerReader&
PCHContainerRdr,
llvm::StringRef Path)
Description
Write a global index into the given
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:183
Parameters
- clang::FileManager& FileMgr
- The file manager to use to load module files.
- const clang::PCHContainerReader& PCHContainerRdr
- - The PCHContainerOperations to use for loading and creating modules.
- llvm::StringRef Path
- The path to the directory containing module files, into which the global index will be written.
¶~GlobalModuleIndex()
~GlobalModuleIndex()
Declared at: clang/include/clang/Serialization/GlobalModuleIndex.h:122