clang API Documentation

Classes | Public Types | Public Member Functions | Static Public Member Functions
clang::GlobalModuleIndex Class Reference

A global index for a set of module files, providing information about the identifiers within those module files. More...

#include <GlobalModuleIndex.h>

List of all members.

Classes

struct  ModuleInfo
 Information about a given module file.

Public Types

enum  ErrorCode { EC_None, EC_NotFound, EC_Building, EC_IOError }
 An error code returned when trying to read an index. More...
typedef llvm::SmallPtrSet
< ModuleFile *, 4 > 
HitSet
 A set of module files in which we found a result.

Public Member Functions

 ~GlobalModuleIndex ()
IdentifierIteratorcreateIdentifierIterator () const
 Returns an iterator for identifiers stored in the index table.
void getKnownModules (SmallVectorImpl< ModuleFile * > &ModuleFiles)
 Retrieve the set of modules that have up-to-date indexes.
void getModuleDependencies (ModuleFile *File, SmallVectorImpl< ModuleFile * > &Dependencies)
 Retrieve the set of module files on which the given module file directly depends.
bool lookupIdentifier (StringRef Name, HitSet &Hits)
 Look for all of the module files with information about the given identifier, e.g., a global function, variable, or type with that name.
bool loadedModuleFile (ModuleFile *File)
 Note that the given module file has been loaded.
void printStats ()
 Print statistics to standard error.
void dump ()
 Print debugging view to standard error.

Static Public Member Functions

static std::pair
< GlobalModuleIndex
*, ErrorCode
readIndex (StringRef Path)
 Read a global index file for the given directory.
static ErrorCode writeIndex (FileManager &FileMgr, StringRef Path)
 Write a global index into the given.

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

Definition at line 59 of file GlobalModuleIndex.h.


Member Typedef Documentation

typedef llvm::SmallPtrSet<ModuleFile *, 4> clang::GlobalModuleIndex::HitSet

A set of module files in which we found a result.

Definition at line 167 of file GlobalModuleIndex.h.


Member Enumeration Documentation

An error code returned when trying to read an index.

Enumerator:
EC_None 

No error occurred.

EC_NotFound 

No index was found.

EC_Building 

Some other process is currently building the index; it is not available yet.

EC_IOError 

There was an unspecified I/O error reading or writing the index.

Definition at line 128 of file GlobalModuleIndex.h.


Constructor & Destructor Documentation

Definition at line 230 of file GlobalModuleIndex.cpp.


Member Function Documentation

Returns an iterator for identifiers stored in the index table.

The caller accepts ownership of the returned object.

Definition at line 882 of file GlobalModuleIndex.cpp.

Print debugging view to standard error.

Definition at line 356 of file GlobalModuleIndex.cpp.

void GlobalModuleIndex::getKnownModules ( SmallVectorImpl< ModuleFile * > &  ModuleFiles)

Retrieve the set of modules that have up-to-date indexes.

Parameters:
ModuleFilesWill be populated with the set of module files that have been indexed.

Definition at line 267 of file GlobalModuleIndex.cpp.

void GlobalModuleIndex::getModuleDependencies ( ModuleFile *  File,
SmallVectorImpl< ModuleFile * > &  Dependencies 
)

Retrieve the set of module files on which the given module file directly depends.

Definition at line 275 of file GlobalModuleIndex.cpp.

bool GlobalModuleIndex::loadedModuleFile ( ModuleFile *  File)

Note that the given module file has been loaded.

Returns:
false if the global module index has information about this module file, and true otherwise.

Definition at line 319 of file GlobalModuleIndex.cpp.

Referenced by clang::serialization::ModuleManager::moduleFileAccepted(), and clang::serialization::ModuleManager::setGlobalIndex().

bool GlobalModuleIndex::lookupIdentifier ( StringRef  Name,
HitSet Hits 
)

Look for all of the module files with information about the given identifier, e.g., a global function, variable, or type with that name.

Parameters:
NameThe identifier to look for.
HitsWill 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.

Definition at line 293 of file GlobalModuleIndex.cpp.

Referenced by clang::CompilerInstance::lookupMissingImports().

Print statistics to standard error.

Definition at line 346 of file GlobalModuleIndex.cpp.

std::pair< GlobalModuleIndex *, GlobalModuleIndex::ErrorCode > GlobalModuleIndex::readIndex ( StringRef  Path) [static]

Read a global index file for the given directory.

Parameters:
PathThe 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 code.

The bitstream reader from which we'll read the AST file.

The main bitstream cursor for the main block.

Definition at line 235 of file GlobalModuleIndex.cpp.

References EC_IOError, EC_None, EC_NotFound, and IndexFileName.

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

GlobalModuleIndex::ErrorCode GlobalModuleIndex::writeIndex ( FileManager FileMgr,
StringRef  Path 
) [static]

Write a global index into the given.

Parameters:
FileMgrThe file manager to use to load module files.
PathThe path to the directory containing module files, into which the global index will be written.

Definition at line 767 of file GlobalModuleIndex.cpp.

References Builder, clang::FileManager::getFile(), and IndexFileName.

Referenced by clang::FrontendAction::Execute(), and clang::CompilerInstance::loadGlobalModuleIndex().


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