clang API Documentation
#include <ModuleMap.h>
Classes | |
struct | InferredDirectory |
A directory for which framework modules can be inferred. | |
class | KnownHeader |
A header that is known to reside within a given module, whether it was included or excluded. More... | |
Public Types | |
enum | ModuleHeaderRole { NormalHeader = 0x0, PrivateHeader = 0x1, TextualHeader = 0x2 } |
Flags describing the role of a module header. More... | |
typedef llvm::SmallPtrSet < const FileEntry *, 1 > | AdditionalModMapsSet |
typedef llvm::StringMap < Module * >::const_iterator | module_iterator |
Public Member Functions | |
ModuleMap (SourceManager &SourceMgr, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const TargetInfo *Target, HeaderSearch &HeaderInfo) | |
Construct a new module map. | |
~ModuleMap () | |
Destroy the module map. | |
void | setTarget (const TargetInfo &Target) |
Set the target information. | |
void | setBuiltinIncludeDir (const DirectoryEntry *Dir) |
Set the directory that contains Clang-supplied include files, such as our stdarg.h or tgmath.h. | |
KnownHeader | findModuleForHeader (const FileEntry *File, Module *RequestingModule=nullptr, bool IncludeTextualHeaders=false) |
Retrieve the module that owns the given header file, if any. | |
void | diagnoseHeaderInclusion (Module *RequestingModule, SourceLocation FilenameLoc, StringRef Filename, const FileEntry *File) |
Reports errors if a module must not include a specific file. | |
bool | isHeaderInUnavailableModule (const FileEntry *Header) const |
Determine whether the given header is part of a module marked 'unavailable'. | |
bool | isHeaderUnavailableInModule (const FileEntry *Header, const Module *RequestingModule) const |
Determine whether the given header is unavailable as part of the specified module. | |
Module * | findModule (StringRef Name) const |
Retrieve a module with the given name. | |
Module * | lookupModuleUnqualified (StringRef Name, Module *Context) const |
Retrieve a module with the given name using lexical name lookup, starting at the given context. | |
Module * | lookupModuleQualified (StringRef Name, Module *Context) const |
Retrieve a module with the given name within the given context, using direct (qualified) name lookup. | |
std::pair< Module *, bool > | findOrCreateModule (StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit) |
Find a new module or submodule, or create it if it does not already exist. | |
bool | canInferFrameworkModule (const DirectoryEntry *ParentDir, StringRef Name, bool &IsSystem) const |
Determine whether we can infer a framework module a framework with the given name in the given. | |
Module * | inferFrameworkModule (StringRef ModuleName, const DirectoryEntry *FrameworkDir, bool IsSystem, Module *Parent) |
Infer the contents of a framework module map from the given framework directory. | |
const FileEntry * | getContainingModuleMapFile (const Module *Module) const |
Retrieve the module map file containing the definition of the given module. | |
const FileEntry * | getModuleMapFileForUniquing (const Module *M) const |
Get the module map file that (along with the module name) uniquely identifies this module. | |
void | setInferredModuleAllowedBy (Module *M, const FileEntry *ModuleMap) |
AdditionalModMapsSet * | getAdditionalModuleMapFiles (const Module *M) |
Get any module map files other than getModuleMapFileForUniquing(M) that define submodules of a top-level module M . This is cheaper than getting the module map file for each submodule individually, since the expected number of results is very small. | |
void | addAdditionalModuleMapFile (const Module *M, const FileEntry *ModuleMap) |
bool | resolveExports (Module *Mod, bool Complain) |
Resolve all of the unresolved exports in the given module. | |
bool | resolveUses (Module *Mod, bool Complain) |
Resolve all of the unresolved uses in the given module. | |
bool | resolveConflicts (Module *Mod, bool Complain) |
Resolve all of the unresolved conflicts in the given module. | |
Module * | inferModuleFromLocation (FullSourceLoc Loc) |
Infers the (sub)module based on the given source location and source manager. | |
void | setUmbrellaHeader (Module *Mod, const FileEntry *UmbrellaHeader) |
Sets the umbrella header of the given module to the given header. | |
void | setUmbrellaDir (Module *Mod, const DirectoryEntry *UmbrellaDir) |
Sets the umbrella directory of the given module to the given directory. | |
void | addHeader (Module *Mod, const FileEntry *Header, ModuleHeaderRole Role) |
Adds this header to the given module. | |
void | excludeHeader (Module *Mod, const FileEntry *Header) |
Marks this header as being excluded from the given module. | |
bool | parseModuleMapFile (const FileEntry *File, bool IsSystem) |
Parse the given module map file, and record any modules we encounter. | |
void | dump () |
Dump the contents of the module map, for debugging purposes. | |
module_iterator | module_begin () const |
module_iterator | module_end () const |
Public Attributes | |
Module * | SourceModule |
std::string | SourceModuleName |
Friends | |
class | ModuleMapParser |
Definition at line 39 of file ModuleMap.h.
typedef llvm::SmallPtrSet<const FileEntry *, 1> clang::ModuleMap::AdditionalModMapsSet |
Definition at line 112 of file ModuleMap.h.
typedef llvm::StringMap<Module *>::const_iterator clang::ModuleMap::module_iterator |
Definition at line 463 of file ModuleMap.h.
Flags describing the role of a module header.
Definition at line 69 of file ModuleMap.h.
ModuleMap::ModuleMap | ( | SourceManager & | SourceMgr, |
DiagnosticsEngine & | Diags, | ||
const LangOptions & | LangOpts, | ||
const TargetInfo * | Target, | ||
HeaderSearch & | HeaderInfo | ||
) |
Construct a new module map.
SourceMgr | The source manager used to find module files and headers. This source manager should be shared with the header-search mechanism, since they will refer to the same headers. |
Diags | A diagnostic engine used for diagnostics. |
LangOpts | Language options for this translation unit. |
Target | The target for this translation unit. |
Definition at line 86 of file ModuleMap.cpp.
Destroy the module map.
Definition at line 93 of file ModuleMap.cpp.
void clang::ModuleMap::addAdditionalModuleMapFile | ( | const Module * | M, |
const FileEntry * | ModuleMap | ||
) | [inline] |
Definition at line 389 of file ModuleMap.h.
void ModuleMap::addHeader | ( | Module * | Mod, |
const FileEntry * | Header, | ||
ModuleHeaderRole | Role | ||
) |
Adds this header to the given module.
Role | The role of the header wrt the module. |
Definition at line 781 of file ModuleMap.cpp.
References clang::Module::getTopLevelModule(), clang::HeaderSearch::MarkFileModuleHeader(), NormalHeader, clang::Module::NormalHeaders, PrivateHeader, clang::Module::PrivateHeaders, clang::Module::PrivateTextualHeaders, TextualHeader, and clang::Module::TextualHeaders.
Referenced by clang::serialization::reader::HeaderFileInfoTrait::ReadData().
bool ModuleMap::canInferFrameworkModule | ( | const DirectoryEntry * | ParentDir, |
StringRef | Name, | ||
bool & | IsSystem | ||
) | const |
Determine whether we can infer a framework module a framework with the given name in the given.
ParentDir | The directory that is the parent of the framework directory. |
Name | The name of the module. |
IsSystem | Will be set to 'true' if the inferred module must be a system module. |
Definition at line 563 of file ModuleMap.cpp.
void ModuleMap::diagnoseHeaderInclusion | ( | Module * | RequestingModule, |
SourceLocation | FilenameLoc, | ||
StringRef | Filename, | ||
const FileEntry * | File | ||
) |
Reports errors if a module must not include a specific file.
RequestingModule | The module including a file. |
FilenameLoc | The location of the inclusion's filename. |
Filename | The included filename as written. |
File | The included file. |
Definition at line 239 of file ModuleMap.cpp.
References directlyUses(), clang::Module::getFullModuleName(), clang::ModuleMap::KnownHeader::getModule(), clang::ModuleMap::KnownHeader::getRole(), clang::Module::getTopLevelModule(), getTopLevelOrNull(), clang::Module::IsFramework, clang::DiagnosticsEngine::Report(), resolveUses(), SourceModule, and violatesPrivateInclude().
Referenced by clang::Preprocessor::LookupFile().
void ModuleMap::dump | ( | ) |
Dump the contents of the module map, for debugging purposes.
Definition at line 839 of file ModuleMap.cpp.
void ModuleMap::excludeHeader | ( | Module * | Mod, |
const FileEntry * | Header | ||
) |
Marks this header as being excluded from the given module.
Definition at line 807 of file ModuleMap.cpp.
References clang::Module::ExcludedHeaders.
Module * ModuleMap::findModule | ( | StringRef | Name | ) | const |
Retrieve a module with the given name.
Name | The name of the module to look up. |
Definition at line 514 of file ModuleMap.cpp.
Referenced by clang::HeaderSearch::lookupModule(), lookupModuleQualified(), lookupModuleUnqualified(), and clang::serialization::ModuleManager::removeModules().
ModuleMap::KnownHeader ModuleMap::findModuleForHeader | ( | const FileEntry * | File, |
Module * | RequestingModule = nullptr , |
||
bool | IncludeTextualHeaders = false |
||
) |
Retrieve the module that owns the given header file, if any.
File | The header file that is likely to be included. |
RequestingModule | Specifies the module the header is intended to be used from. Used to disambiguate if a header is present in multiple modules. |
IncludeTextualHeaders | If true , also find textual headers. By default, these are treated like excluded headers and result in no known header being found. |
Definition at line 315 of file ModuleMap.cpp.
References clang::Module::addTopHeader(), directlyUses(), clang::Module::Exports, findOrCreateModule(), clang::ModuleMap::KnownHeader::getModule(), getModuleMapFileForUniquing(), clang::FileEntry::getName(), clang::ModuleMap::KnownHeader::getRole(), clang::Module::getUmbrellaDir(), clang::Module::InferExplicitSubmodules, clang::Module::InferExportWildcard, clang::Module::InferSubmodules, clang::Module::isAvailable(), clang::Module::IsInferred, NormalHeader, clang::Module::Parent, PrivateHeader, sanitizeFilenameAsIdentifier(), and TextualHeader.
Referenced by clang::HeaderSearch::findModuleForHeader(), and inferModuleFromLocation().
std::pair< Module *, bool > ModuleMap::findOrCreateModule | ( | StringRef | Name, |
Module * | Parent, | ||
bool | IsFramework, | ||
bool | IsExplicit | ||
) |
Find a new module or submodule, or create it if it does not already exist.
Name | The name of the module to find or create. |
Parent | The module that will act as the parent of this submodule, or NULL to indicate that this is a top-level module. |
IsFramework | Whether this is a framework module. |
IsExplicit | Whether this is an explicit submodule. |
Definition at line 540 of file ModuleMap.cpp.
References clang::LangOptions::CurrentModule, lookupModuleQualified(), SourceModule, and SourceModuleName.
Referenced by findModuleForHeader().
AdditionalModMapsSet* clang::ModuleMap::getAdditionalModuleMapFiles | ( | const Module * | M | ) | [inline] |
Get any module map files other than getModuleMapFileForUniquing(M) that define submodules of a top-level module M
. This is cheaper than getting the module map file for each submodule individually, since the expected number of results is very small.
Definition at line 382 of file ModuleMap.h.
const FileEntry * ModuleMap::getContainingModuleMapFile | ( | const Module * | Module | ) | const |
Retrieve the module map file containing the definition of the given module.
Module | The module whose module map file will be returned, if known. |
Definition at line 818 of file ModuleMap.cpp.
References clang::Module::DefinitionLoc, clang::SourceManager::getFileEntryForID(), clang::SourceManager::getFileID(), and clang::SourceLocation::isInvalid().
Referenced by compileModuleImpl(), and getModuleMapFileForUniquing().
const FileEntry * ModuleMap::getModuleMapFileForUniquing | ( | const Module * | M | ) | const |
Get the module map file that (along with the module name) uniquely identifies this module.
The particular module that Name
refers to may depend on how the module was found in header search. However, the combination of Name
and this module map will be globally unique for top-level modules. In the case of inferred modules, returns the module map that allowed the inference (e.g. contained 'module *'). Otherwise, returns getContainingModuleMapFile().
Definition at line 826 of file ModuleMap.cpp.
References getContainingModuleMapFile(), and clang::Module::IsInferred.
Referenced by compileModuleImpl(), findModuleForHeader(), clang::HeaderSearch::getModuleFileName(), and inferFrameworkModule().
Module * ModuleMap::inferFrameworkModule | ( | StringRef | ModuleName, |
const DirectoryEntry * | FrameworkDir, | ||
bool | IsSystem, | ||
Module * | Parent | ||
) |
Infer the contents of a framework module map from the given framework directory.
Definition at line 605 of file ModuleMap.cpp.
References clang::LangOptions::CurrentModule, clang::Module::Exports, clang::FileManager::getCanonicalName(), clang::FileEntry::getDir(), clang::FileManager::getDirectory(), clang::FileManager::getFile(), clang::SourceManager::getFileManager(), getModuleMapFileForUniquing(), clang::DirectoryEntry::getName(), clang::Module::InferExportWildcard, inferFrameworkLink(), clang::Module::InferSubmodules, clang::Module::IsInferred, clang::Module::isSubFramework(), clang::Module::IsSystem, clang::HeaderSearch::lookupModuleMapFile(), lookupModuleQualified(), NormalHeader, parseModuleMapFile(), sanitizeFilenameAsIdentifier(), SourceModule, SourceModuleName, and clang::Module::Umbrella.
Infers the (sub)module based on the given source location and source manager.
Loc | The location within the source that we are querying, along with its source manager. |
Definition at line 908 of file ModuleMap.cpp.
References findModuleForHeader(), clang::FullSourceLoc::getExpansionLoc(), clang::SourceManager::getFileEntryForID(), clang::FullSourceLoc::getFileID(), clang::SourceManager::getFileID(), clang::SourceManager::getIncludeLoc(), clang::FullSourceLoc::getManager(), clang::ModuleMap::KnownHeader::getModule(), clang::SourceLocation::isFileID(), and clang::SourceLocation::isInvalid().
Referenced by clang::ASTWriter::inferSubmoduleIDFromLocation().
bool ModuleMap::isHeaderInUnavailableModule | ( | const FileEntry * | Header | ) | const |
Determine whether the given header is part of a module marked 'unavailable'.
Definition at line 428 of file ModuleMap.cpp.
References isHeaderUnavailableInModule().
Referenced by clang::Preprocessor::HandleEndOfFile().
bool ModuleMap::isHeaderUnavailableInModule | ( | const FileEntry * | Header, |
const Module * | RequestingModule | ||
) | const |
Determine whether the given header is unavailable as part of the specified module.
Definition at line 433 of file ModuleMap.cpp.
References clang::FileEntry::getDir(), clang::FileManager::getDirectory(), clang::SourceManager::getFileManager(), clang::DirectoryEntry::getName(), clang::FileEntry::getName(), clang::Module::getUmbrellaDir(), clang::Module::InferSubmodules, clang::Module::isSubModuleOf(), lookupModuleQualified(), clang::Module::Parent, and sanitizeFilenameAsIdentifier().
Referenced by collectModuleHeaderIncludes(), and isHeaderInUnavailableModule().
Module * ModuleMap::lookupModuleQualified | ( | StringRef | Name, |
Module * | Context | ||
) | const |
Retrieve a module with the given name within the given context, using direct (qualified) name lookup.
Name | The name of the module to look up. |
Context | The module for which we will look for a submodule. If null, we will look for a top-level module. |
Definition at line 532 of file ModuleMap.cpp.
References findModule(), and clang::Module::findSubmodule().
Referenced by findOrCreateModule(), inferFrameworkModule(), isHeaderUnavailableInModule(), and lookupModuleUnqualified().
Module * ModuleMap::lookupModuleUnqualified | ( | StringRef | Name, |
Module * | Context | ||
) | const |
Retrieve a module with the given name using lexical name lookup, starting at the given context.
Name | The name of the module to look up. |
Context | The module context, from which we will perform lexical name lookup. |
Definition at line 522 of file ModuleMap.cpp.
References Context, findModule(), lookupModuleQualified(), and clang::Module::Parent.
module_iterator clang::ModuleMap::module_begin | ( | ) | const [inline] |
Definition at line 464 of file ModuleMap.h.
Referenced by clang::HeaderSearch::collectAllModules(), and clang::CompilerInstance::loadGlobalModuleIndex().
module_iterator clang::ModuleMap::module_end | ( | ) | const [inline] |
Definition at line 465 of file ModuleMap.h.
Referenced by clang::HeaderSearch::collectAllModules(), and clang::CompilerInstance::loadGlobalModuleIndex().
bool ModuleMap::parseModuleMapFile | ( | const FileEntry * | File, |
bool | IsSystem | ||
) |
Parse the given module map file, and record any modules we encounter.
File | The file to be parsed. |
IsSystem | Whether this module map file is in a system header directory, and therefore should be considered a system module. |
Definition at line 2319 of file ModuleMap.cpp.
References clang::SrcMgr::C_System, clang::SrcMgr::C_User, clang::SourceManager::createFileID(), clang::SourceManager::getBuffer(), clang::FileEntry::getDir(), clang::FileManager::getDirectory(), clang::SourceManager::getFileManager(), and clang::DirectoryEntry::getName().
Referenced by inferFrameworkModule().
bool ModuleMap::resolveConflicts | ( | Module * | Mod, |
bool | Complain | ||
) |
Resolve all of the unresolved conflicts in the given module.
Mod | The module whose conflicts should be resolved. |
Complain | Whether to emit diagnostics for failures. |
Definition at line 889 of file ModuleMap.cpp.
References clang::Module::Conflicts, clang::Module::Conflict::Message, clang::Module::Conflict::Other, and clang::Module::UnresolvedConflicts.
Referenced by clang::Sema::ActOnEndOfTranslationUnit().
bool ModuleMap::resolveExports | ( | Module * | Mod, |
bool | Complain | ||
) |
Resolve all of the unresolved exports in the given module.
Mod | The module whose exports should be resolved. |
Complain | Whether to emit diagnostics for failures. |
Definition at line 861 of file ModuleMap.cpp.
References clang::Module::Exports, and clang::Module::UnresolvedExports.
Referenced by clang::Sema::ActOnEndOfTranslationUnit().
bool ModuleMap::resolveUses | ( | Module * | Mod, |
bool | Complain | ||
) |
Resolve all of the unresolved uses in the given module.
Mod | The module whose uses should be resolved. |
Complain | Whether to emit diagnostics for failures. |
Definition at line 875 of file ModuleMap.cpp.
References clang::Module::DirectUses, and clang::Module::UnresolvedDirectUses.
Referenced by clang::Sema::ActOnEndOfTranslationUnit(), and diagnoseHeaderInclusion().
void clang::ModuleMap::setBuiltinIncludeDir | ( | const DirectoryEntry * | Dir | ) | [inline] |
Set the directory that contains Clang-supplied include files, such as our stdarg.h or tgmath.h.
Definition at line 242 of file ModuleMap.h.
Referenced by clang::ApplyHeaderSearchOptions().
void ModuleMap::setInferredModuleAllowedBy | ( | Module * | M, |
const FileEntry * | ModuleMap | ||
) |
Definition at line 834 of file ModuleMap.cpp.
References clang::Module::IsInferred.
Referenced by clang::GenerateModuleAction::BeginSourceFileAction().
void ModuleMap::setTarget | ( | const TargetInfo & | Target | ) |
Set the target information.
Definition at line 101 of file ModuleMap.cpp.
Referenced by clang::HeaderSearch::setTarget().
void ModuleMap::setUmbrellaDir | ( | Module * | Mod, |
const DirectoryEntry * | UmbrellaDir | ||
) |
Sets the umbrella directory of the given module to the given directory.
Definition at line 776 of file ModuleMap.cpp.
References clang::Module::Umbrella.
void ModuleMap::setUmbrellaHeader | ( | Module * | Mod, |
const FileEntry * | UmbrellaHeader | ||
) |
Sets the umbrella header of the given module to the given header.
Definition at line 770 of file ModuleMap.cpp.
References clang::FileEntry::getDir(), NormalHeader, and clang::Module::Umbrella.
friend class ModuleMapParser [friend] |
Definition at line 163 of file ModuleMap.h.
Definition at line 60 of file ModuleMap.h.
Referenced by diagnoseHeaderInclusion(), findOrCreateModule(), and inferFrameworkModule().
std::string clang::ModuleMap::SourceModuleName |
Definition at line 61 of file ModuleMap.h.
Referenced by findOrCreateModule(), and inferFrameworkModule().