clang 22.0.0git
clang::ModuleMap Class Reference

#include "clang/Lex/ModuleMap.h"

Classes

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 , ExcludedHeader = 0x4 }
 Flags describing the role of a module header. More...
using AdditionalModMapsSet = llvm::DenseSet<FileEntryRef>
using module_iterator = llvm::StringMap<Module *>::const_iterator

Public Member Functions

void resolveLinkAsDependencies (Module *Mod)
 Use PendingLinkAsModule information to mark top level link names that are going to be replaced by export_as aliases.
void addLinkAsDependency (Module *Mod)
 Make module to use export_as as the link dependency name if enough information is available or add it to a pending list otherwise.
 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 (DirectoryEntryRef Dir)
 Set the directory that contains Clang-supplied include files, such as our stdarg.h or tgmath.h.
OptionalDirectoryEntryRef getBuiltinDir () const
 Get the directory that contains Clang-supplied include files.
bool isBuiltinHeader (FileEntryRef File)
 Is this a compiler builtin header?
bool shouldImportRelativeToBuiltinIncludeDir (StringRef FileName, Module *Module) const
void addModuleMapCallbacks (std::unique_ptr< ModuleMapCallbacks > Callback)
 Add a module map callback.
KnownHeader findModuleForHeader (FileEntryRef File, bool AllowTextual=false, bool AllowExcluded=false)
 Retrieve the module that owns the given header file, if any.
ArrayRef< KnownHeaderfindAllModulesForHeader (FileEntryRef File)
 Retrieve all the modules that contain the given header file.
ArrayRef< KnownHeaderfindResolvedModulesForHeader (FileEntryRef File) const
 Like findAllModulesForHeader, but do not attempt to infer module ownership from umbrella headers if we've not already done so.
void resolveHeaderDirectives (const FileEntry *File) const
 Resolve all lazy header directives for the specified file.
void resolveHeaderDirectives (Module *Mod, std::optional< const FileEntry * > File) const
 Resolve lazy header directives for the specified module.
void diagnoseHeaderInclusion (Module *RequestingModule, bool RequestingModuleIsModuleInterface, SourceLocation FilenameLoc, StringRef Filename, FileEntryRef File)
 Reports errors if a module must not include a specific file.
bool isHeaderInUnavailableModule (FileEntryRef Header) const
 Determine whether the given header is part of a module marked 'unavailable'.
bool isHeaderUnavailableInModule (FileEntryRef Header, const Module *RequestingModule) const
 Determine whether the given header is unavailable as part of the specified module.
ModulefindModule (StringRef Name) const
 Retrieve a module with the given name.
ModulefindOrLoadModule (StringRef Name)
ModulefindOrInferSubmodule (Module *Parent, StringRef Name)
ModulelookupModuleUnqualified (StringRef Name, Module *Context) const
 Retrieve a module with the given name using lexical name lookup, starting at the given context.
ModulelookupModuleQualified (StringRef Name, Module *Context) const
 Retrieve a module with the given name within the given context, using direct (qualified) name lookup.
std::pair< Module *, boolfindOrCreateModule (StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit)
 Find a new module or submodule, or create it if it does not already exist.
ModulefindOrCreateModuleFirst (StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit)
 Call ModuleMap::findOrCreateModule and throw away the information whether the module was found or created.
ModulecreateModule (StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit)
 Create new submodule, assuming it does not exist.
ModulecreateGlobalModuleFragmentForModuleUnit (SourceLocation Loc, Module *Parent=nullptr)
 Create a global module fragment for a C++ module unit.
ModulecreateImplicitGlobalModuleFragmentForModuleUnit (SourceLocation Loc, Module *Parent)
ModulecreatePrivateModuleFragmentForInterfaceUnit (Module *Parent, SourceLocation Loc)
 Create a global module fragment for a C++ module interface unit.
ModulecreateModuleUnitWithKind (SourceLocation Loc, StringRef Name, Module::ModuleKind Kind)
 Create a new C++ module with the specified kind, and reparent any pending global module fragment(s) to it.
ModulecreateModuleForInterfaceUnit (SourceLocation Loc, StringRef Name)
 Create a new module for a C++ module interface unit.
ModulecreateModuleForImplementationUnit (SourceLocation Loc, StringRef Name)
 Create a new module for a C++ module implementation unit.
ModulecreateHeaderUnit (SourceLocation Loc, StringRef Name, Module::Header H)
 Create a C++20 header unit.
ModuleinferFrameworkModule (DirectoryEntryRef FrameworkDir, bool IsSystem, Module *Parent)
 Infer the contents of a framework module map from the given framework directory.
ModulecreateShadowedModule (StringRef Name, bool IsFramework, Module *ShadowingModule)
 Create a new top-level module that is shadowed by ShadowingModule.
void finishModuleDeclarationScope ()
 Creates a new declaration scope for module names, allowing previously defined modules to shadow definitions from the new scope.
bool mayShadowNewModule (Module *ExistingModule)
bool canInferFrameworkModule (const DirectoryEntry *Dir) const
 Check whether a framework module can be inferred in the given directory.
FileID getContainingModuleMapFileID (const Module *Module) const
 Retrieve the module map file containing the definition of the given module.
OptionalFileEntryRef getContainingModuleMapFile (const Module *Module) const
FileID getModuleMapFileIDForUniquing (const Module *M) const
 Get the module map file that (along with the module name) uniquely identifies this module.
OptionalFileEntryRef getModuleMapFileForUniquing (const Module *M) const
void setInferredModuleAllowedBy (Module *M, FileID ModMapFID)
std::error_code canonicalizeModuleMapPath (SmallVectorImpl< char > &Path)
 Canonicalize Path in a manner suitable for a module map file.
AdditionalModMapsSetgetAdditionalModuleMapFiles (const Module *M)
 Get any module map files other than getModuleMapFileForUniquing(M) that define submodules of a top-level module M.
void addAdditionalModuleMapFile (const Module *M, FileEntryRef 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.
void setUmbrellaHeaderAsWritten (Module *Mod, FileEntryRef UmbrellaHeader, const Twine &NameAsWritten, const Twine &PathRelativeToRootModuleDirectory)
 Sets the umbrella header of the given module to the given header.
void setUmbrellaDirAsWritten (Module *Mod, DirectoryEntryRef UmbrellaDir, const Twine &NameAsWritten, const Twine &PathRelativeToRootModuleDirectory)
 Sets the umbrella directory of the given module to the given directory.
void addHeader (Module *Mod, Module::Header Header, ModuleHeaderRole Role, bool Imported=false)
 Adds this header to the given module.
bool parseModuleMapFile (FileEntryRef File, bool IsSystem, DirectoryEntryRef Dir, FileID ID=FileID(), SourceLocation ExternModuleLoc=SourceLocation())
 Parse a module map without creating clang::Module instances.
bool parseAndLoadModuleMapFile (FileEntryRef File, bool IsSystem, DirectoryEntryRef HomeDir, FileID ID=FileID(), unsigned *Offset=nullptr, SourceLocation ExternModuleLoc=SourceLocation())
 Load 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
llvm::iterator_range< module_iteratormodules () const
void cacheModuleLoad (const IdentifierInfo &II, Module *M)
 Cache a module load. M might be nullptr.
std::optional< Module * > getCachedModuleLoad (const IdentifierInfo &II)
 Return a cached module load.

Static Public Member Functions

static ModuleHeaderRole headerKindToRole (Module::HeaderKind Kind)
 Convert a header kind to a role. Requires Kind to not be HK_Excluded.
static Module::HeaderKind headerRoleToKind (ModuleHeaderRole Role)
 Convert a header role to a kind.
static bool isModular (ModuleHeaderRole Role)
 Check if the header with the given role is a modular one.

Friends

class ModuleMapLoader

Detailed Description

Definition at line 75 of file ModuleMap.h.

Member Typedef Documentation

◆ AdditionalModMapsSet

Definition at line 196 of file ModuleMap.h.

◆ module_iterator

using clang::ModuleMap::module_iterator = llvm::StringMap<Module *>::const_iterator

Definition at line 745 of file ModuleMap.h.

Member Enumeration Documentation

◆ ModuleHeaderRole

Flags describing the role of a module header.

Enumerator
NormalHeader 

This header is normally included in the module.

PrivateHeader 

This header is included but private.

TextualHeader 

This header is part of the module (for layering purposes) but should be textually included.

ExcludedHeader 

This header is explicitly excluded from the module.

Definition at line 126 of file ModuleMap.h.

Constructor & Destructor Documentation

◆ ModuleMap()

ModuleMap::ModuleMap ( SourceManager & SourceMgr,
DiagnosticsEngine & Diags,
const LangOptions & LangOpts,
const TargetInfo * Target,
HeaderSearch & HeaderInfo )

Construct a new module map.

Parameters
SourceMgrThe 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.
DiagsA diagnostic engine used for diagnostics.
LangOptsLanguage options for this translation unit.
TargetThe target for this translation unit.

Definition at line 351 of file ModuleMap.cpp.

Referenced by addAdditionalModuleMapFile(), findOrLoadModule(), and resolveHeaderDirectives().

◆ ~ModuleMap()

ModuleMap::~ModuleMap ( )
default

Destroy the module map.

Member Function Documentation

◆ addAdditionalModuleMapFile()

void ModuleMap::addAdditionalModuleMapFile ( const Module * M,
FileEntryRef ModuleMap )

Definition at line 1464 of file ModuleMap.cpp.

References ModuleMap().

◆ addHeader()

void ModuleMap::addHeader ( Module * Mod,
Module::Header Header,
ModuleHeaderRole Role,
bool Imported = false )

Adds this header to the given module.

Parameters
RoleThe role of the header wrt the module.

Definition at line 1296 of file ModuleMap.cpp.

References clang::Module::addHeader(), clang::Module::Header::Entry, clang::FileEntryRef::getName(), headerRoleToKind(), clang::Module::isForBuilding(), and Role.

Referenced by createHeaderUnit(), and clang::serialization::reader::HeaderFileInfoTrait::ReadData().

◆ addLinkAsDependency()

void ModuleMap::addLinkAsDependency ( Module * Mod)

Make module to use export_as as the link dependency name if enough information is available or add it to a pending list otherwise.

Definition at line 62 of file ModuleMap.cpp.

References clang::Module::ExportAsModule, findModule(), clang::Module::Name, and clang::Module::UseExportAsModuleLinkName.

◆ addModuleMapCallbacks()

void clang::ModuleMap::addModuleMapCallbacks ( std::unique_ptr< ModuleMapCallbacks > Callback)
inline

Add a module map callback.

Definition at line 413 of file ModuleMap.h.

Referenced by clang::DependencyCollector::attachToPreprocessor(), and clang::ModuleDependencyCollector::attachToPreprocessor().

◆ cacheModuleLoad()

void clang::ModuleMap::cacheModuleLoad ( const IdentifierInfo & II,
Module * M )
inline

Cache a module load. M might be nullptr.

Definition at line 754 of file ModuleMap.h.

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

◆ canInferFrameworkModule()

bool clang::ModuleMap::canInferFrameworkModule ( const DirectoryEntry * Dir) const
inline

Check whether a framework module can be inferred in the given directory.

Definition at line 614 of file ModuleMap.h.

Referenced by loadModuleMapForModuleBuild().

◆ canonicalizeModuleMapPath()

std::error_code ModuleMap::canonicalizeModuleMapPath ( SmallVectorImpl< char > & Path)

Canonicalize Path in a manner suitable for a module map file.

In particular, this canonicalizes the parent directory separately from the filename so that it does not affect header resolution relative to the modulemap.

Returns
an error code if any filesystem operations failed. In this case Path is not modified.

Definition at line 1432 of file ModuleMap.cpp.

References clang::FileManager::getCanonicalName(), and clang::FileManager::getDirectoryRef().

◆ createGlobalModuleFragmentForModuleUnit()

Module * ModuleMap::createGlobalModuleFragmentForModuleUnit ( SourceLocation Loc,
Module * Parent = nullptr )

Create a global module fragment for a C++ module unit.

We model the global module fragment as a submodule of the module interface unit. Unfortunately, we can't create the module interface unit's Module until later, because we don't know what it will be called usually. See C++20 [module.unit]/7.2 for the case we could know its parent.

Definition at line 883 of file ModuleMap.cpp.

References clang::Module::ExplicitGlobalModuleFragment, clang::Module, and clang::Result.

◆ createHeaderUnit()

Module * ModuleMap::createHeaderUnit ( SourceLocation Loc,
StringRef Name,
Module::Header H )

Create a C++20 header unit.

Definition at line 977 of file ModuleMap.cpp.

References addHeader(), clang::Module, clang::Module::ModuleHeaderUnit, NormalHeader, and clang::Result.

◆ createImplicitGlobalModuleFragmentForModuleUnit()

Module * ModuleMap::createImplicitGlobalModuleFragmentForModuleUnit ( SourceLocation Loc,
Module * Parent )

◆ createModule()

Module * ModuleMap::createModule ( StringRef Name,
Module * Parent,
bool IsFramework,
bool IsExplicit )

Create new submodule, assuming it does not exist.

This function can only be called when it is guaranteed that this submodule does not exist yet. The parameters have same semantics as ModuleMap::findOrCreateModule.

Definition at line 866 of file ModuleMap.cpp.

References lookupModuleQualified(), clang::Module, and clang::Result.

Referenced by findOrCreateModule().

◆ createModuleForImplementationUnit()

Module * ModuleMap::createModuleForImplementationUnit ( SourceLocation Loc,
StringRef Name )

Create a new module for a C++ module implementation unit.

The interface module for this implementation (implicitly imported) must exist and be loaded and present in the modules map.

Returns
The newly-created module.

Definition at line 953 of file ModuleMap.cpp.

References createModuleUnitWithKind(), clang::Module::ModuleImplementationUnit, clang::Module::ModuleInterfaceUnit, and clang::Result.

◆ createModuleForInterfaceUnit()

Module * ModuleMap::createModuleForInterfaceUnit ( SourceLocation Loc,
StringRef Name )

Create a new module for a C++ module interface unit.

The module must not already exist, and will be configured for the current compilation.

Note that this also sets the current module to the newly-created module.

Returns
The newly-created module.

Definition at line 935 of file ModuleMap.cpp.

References createModuleUnitWithKind(), clang::Module::ModuleInterfaceUnit, PrivateHeader, and clang::Result.

◆ createModuleUnitWithKind()

Module * ModuleMap::createModuleUnitWithKind ( SourceLocation Loc,
StringRef Name,
Module::ModuleKind Kind )

Create a new C++ module with the specified kind, and reparent any pending global module fragment(s) to it.

Definition at line 921 of file ModuleMap.cpp.

References clang::Module, and clang::Result.

Referenced by createModuleForImplementationUnit(), and createModuleForInterfaceUnit().

◆ createPrivateModuleFragmentForInterfaceUnit()

Module * ModuleMap::createPrivateModuleFragmentForInterfaceUnit ( Module * Parent,
SourceLocation Loc )

Create a global module fragment for a C++ module interface unit.

Definition at line 912 of file ModuleMap.cpp.

References clang::Module, clang::Module::PrivateModuleFragment, and clang::Result.

◆ createShadowedModule()

Module * ModuleMap::createShadowedModule ( StringRef Name,
bool IsFramework,
Module * ShadowingModule )

Create a new top-level module that is shadowed by ShadowingModule.

Definition at line 1185 of file ModuleMap.cpp.

References clang::Module, and clang::Result.

◆ diagnoseHeaderInclusion()

void ModuleMap::diagnoseHeaderInclusion ( Module * RequestingModule,
bool RequestingModuleIsModuleInterface,
SourceLocation FilenameLoc,
StringRef Filename,
FileEntryRef File )

Reports errors if a module must not include a specific file.

Parameters
RequestingModuleThe module including a file.
RequestingModuleIsModuleInterfacetrue if the inclusion is in the interface of RequestingModule, false if it's in the implementation of RequestingModule. Value is ignored and meaningless if RequestingModule is nullptr.
FilenameLocThe location of the inclusion's filename.
FilenameThe included filename as written.
FileThe included file.

Definition at line 484 of file ModuleMap.cpp.

References clang::Module::directlyUses(), ExcludedHeader, clang::File, clang::Module::getFullModuleName(), clang::ModuleMap::KnownHeader::getModule(), clang::ModuleMap::KnownHeader::getRole(), clang::Module::getTopLevelModule(), getTopLevelOrNull(), clang::Module::IsFramework, clang::Module::Name, clang::Private, resolveHeaderDirectives(), resolveUses(), and violatesPrivateInclude().

◆ dump()

LLVM_DUMP_METHOD void ModuleMap::dump ( )

Dump the contents of the module map, for debugging purposes.

Definition at line 1469 of file ModuleMap.cpp.

References clang::Module::print().

◆ findAllModulesForHeader()

ArrayRef< ModuleMap::KnownHeader > ModuleMap::findAllModulesForHeader ( FileEntryRef File)

Retrieve all the modules that contain the given header file.

Note that this does not implicitly load module maps, except for builtin headers, and does not consult the external source. (Those checks are the responsibility of HeaderSearch.)

Typically, findModuleForHeader should be used instead, as it picks the preferred module for the header.

Definition at line 693 of file ModuleMap.cpp.

References clang::File.

◆ findModule()

Module * ModuleMap::findModule ( StringRef Name) const

Retrieve a module with the given name.

Parameters
NameThe name of the module to look up.
Returns
The named module, if known; otherwise, returns null.

Definition at line 812 of file ModuleMap.cpp.

Referenced by addLinkAsDependency(), findOrLoadModule(), lookupModuleQualified(), lookupModuleUnqualified(), and resolveLinkAsDependencies().

◆ findModuleForHeader()

ModuleMap::KnownHeader ModuleMap::findModuleForHeader ( FileEntryRef File,
bool AllowTextual = false,
bool AllowExcluded = false )

Retrieve the module that owns the given header file, if any.

Note that this does not implicitly load module maps, except for builtin headers, and does not consult the external source. (Those checks are the responsibility of HeaderSearch.)

Parameters
FileThe header file that is likely to be included.
AllowTextualIf true and File is a textual header, return its owning module. Otherwise, no KnownHeader will be returned if the file is only known as a textual header.
Returns
The module KnownHeader, which provides the module that owns the given header file. The KnownHeader is default constructed to indicate that no module owns this header file.

Definition at line 594 of file ModuleMap.cpp.

References ExcludedHeader, clang::File, clang::ModuleMap::KnownHeader::getModule(), clang::ModuleMap::KnownHeader::getRole(), clang::Module::getTopLevelModule(), isBetterKnownHeader(), clang::Result, and TextualHeader.

◆ findOrCreateModule()

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.

Parameters
NameThe name of the module to find or create.
ParentThe module that will act as the parent of this submodule, or nullptr to indicate that this is a top-level module.
IsFrameworkWhether this is a framework module.
IsExplicitWhether this is an explicit submodule.
Returns
The found or newly-created module, along with a boolean value that will be true if the module is newly-created.

Definition at line 853 of file ModuleMap.cpp.

References createModule(), and lookupModuleQualified().

Referenced by findOrCreateModuleFirst().

◆ findOrCreateModuleFirst()

Module * clang::ModuleMap::findOrCreateModuleFirst ( StringRef Name,
Module * Parent,
bool IsFramework,
bool IsExplicit )
inline

Call ModuleMap::findOrCreateModule and throw away the information whether the module was found or created.

Definition at line 539 of file ModuleMap.h.

References findOrCreateModule().

◆ findOrInferSubmodule()

Module * ModuleMap::findOrInferSubmodule ( Module * Parent,
StringRef Name )

◆ findOrLoadModule()

◆ findResolvedModulesForHeader()

ArrayRef< ModuleMap::KnownHeader > ModuleMap::findResolvedModulesForHeader ( FileEntryRef File) const

Like findAllModulesForHeader, but do not attempt to infer module ownership from umbrella headers if we've not already done so.

Definition at line 705 of file ModuleMap.cpp.

References clang::File, and resolveHeaderDirectives().

◆ finishModuleDeclarationScope()

void clang::ModuleMap::finishModuleDeclarationScope ( )
inline

Creates a new declaration scope for module names, allowing previously defined modules to shadow definitions from the new scope.

Note
Module names from earlier scopes will shadow names from the new scope, which is the opposite of how shadowing works for variables.

Definition at line 605 of file ModuleMap.h.

Referenced by clang::FrontendAction::BeginSourceFile().

◆ getAdditionalModuleMapFiles()

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 656 of file ModuleMap.h.

◆ getBuiltinDir()

OptionalDirectoryEntryRef clang::ModuleMap::getBuiltinDir ( ) const
inline

Get the directory that contains Clang-supplied include files.

Definition at line 404 of file ModuleMap.h.

◆ getCachedModuleLoad()

std::optional< Module * > clang::ModuleMap::getCachedModuleLoad ( const IdentifierInfo & II)
inline

Return a cached module load.

Definition at line 759 of file ModuleMap.h.

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

◆ getContainingModuleMapFile()

OptionalFileEntryRef ModuleMap::getContainingModuleMapFile ( const Module * Module) const

Definition at line 1409 of file ModuleMap.cpp.

References getContainingModuleMapFileID().

◆ getContainingModuleMapFileID()

FileID ModuleMap::getContainingModuleMapFileID ( const Module * Module) const

Retrieve the module map file containing the definition of the given module.

Parameters
ModuleThe module whose module map file will be returned, if known.
Returns
The FileID for the module map file containing the given module, invalid if the module definition was inferred.

Definition at line 1401 of file ModuleMap.cpp.

References clang::Module::DefinitionLoc, and clang::SourceLocation::isInvalid().

Referenced by clang::CompilerInstance::cloneForModuleCompile(), getContainingModuleMapFile(), and getModuleMapFileIDForUniquing().

◆ getModuleMapFileForUniquing()

◆ getModuleMapFileIDForUniquing()

FileID ModuleMap::getModuleMapFileIDForUniquing ( 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 1413 of file ModuleMap.cpp.

References getContainingModuleMapFileID(), and clang::Module::IsInferred.

Referenced by getModuleMapFileForUniquing().

◆ headerKindToRole()

ModuleMap::ModuleHeaderRole ModuleMap::headerKindToRole ( Module::HeaderKind Kind)
static

Convert a header kind to a role. Requires Kind to not be HK_Excluded.

Definition at line 86 of file ModuleMap.cpp.

References ExcludedHeader, clang::Module::HK_Excluded, clang::Module::HK_Normal, clang::Module::HK_Private, clang::Module::HK_PrivateTextual, clang::Module::HK_Textual, NormalHeader, PrivateHeader, and TextualHeader.

◆ headerRoleToKind()

◆ inferFrameworkModule()

Module * ModuleMap::inferFrameworkModule ( DirectoryEntryRef FrameworkDir,
bool IsSystem,
Module * Parent )

Infer the contents of a framework module map from the given framework directory.

Definition at line 1004 of file ModuleMap.cpp.

References clang::ModuleAttributes::IsSystem.

◆ isBuiltinHeader()

bool ModuleMap::isBuiltinHeader ( FileEntryRef File)

Is this a compiler builtin header?

Definition at line 403 of file ModuleMap.cpp.

References clang::File, and isBuiltinHeaderName().

Referenced by suggestModule().

◆ isHeaderInUnavailableModule()

bool ModuleMap::isHeaderInUnavailableModule ( FileEntryRef Header) const

Determine whether the given header is part of a module marked 'unavailable'.

Definition at line 714 of file ModuleMap.cpp.

References isHeaderUnavailableInModule().

◆ isHeaderUnavailableInModule()

◆ isModular()

bool ModuleMap::isModular ( ModuleHeaderRole Role)
static

Check if the header with the given role is a modular one.

Definition at line 102 of file ModuleMap.cpp.

References ExcludedHeader, Role, and TextualHeader.

Referenced by clang::HeaderFileInfo::mergeModuleMembership(), and moduleMembershipNeedsMerge().

◆ lookupModuleQualified()

Module * ModuleMap::lookupModuleQualified ( StringRef Name,
Module * Context ) const

Retrieve a module with the given name within the given context, using direct (qualified) name lookup.

Parameters
NameThe name of the module to look up.
ContextThe module for which we will look for a submodule. If null, we will look for a top-level module.
Returns
The named submodule, if known; otherwose, returns null.

Definition at line 846 of file ModuleMap.cpp.

References findModule().

Referenced by createModule(), findOrCreateModule(), isHeaderUnavailableInModule(), and lookupModuleUnqualified().

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

Parameters
NameThe name of the module to look up.
ContextThe module context, from which we will perform lexical name lookup.
Returns
The named module, if known; otherwise, returns null.

Definition at line 836 of file ModuleMap.cpp.

References findModule(), and lookupModuleQualified().

◆ mayShadowNewModule()

bool clang::ModuleMap::mayShadowNewModule ( Module * ExistingModule)
inline

Definition at line 607 of file ModuleMap.h.

References clang::Module::Parent.

◆ module_begin()

module_iterator clang::ModuleMap::module_begin ( ) const
inline

Definition at line 747 of file ModuleMap.h.

Referenced by clang::CompilerInstance::loadGlobalModuleIndex(), and modules().

◆ module_end()

module_iterator clang::ModuleMap::module_end ( ) const
inline

Definition at line 748 of file ModuleMap.h.

Referenced by clang::CompilerInstance::loadGlobalModuleIndex(), and modules().

◆ modules()

llvm::iterator_range< module_iterator > clang::ModuleMap::modules ( ) const
inline

Definition at line 749 of file ModuleMap.h.

References module_begin(), and module_end().

◆ parseAndLoadModuleMapFile()

bool ModuleMap::parseAndLoadModuleMapFile ( FileEntryRef File,
bool IsSystem,
DirectoryEntryRef HomeDir,
FileID ID = FileID(),
unsigned * Offset = nullptr,
SourceLocation ExternModuleLoc = SourceLocation() )

Load the given module map file, and record any modules we encounter.

Parameters
FileThe file to be loaded.
IsSystemWhether this module map file is in a system header directory, and therefore should be considered a system module.
HomeDirThe directory in which relative paths within this module map file will be resolved.
IDThe FileID of the file to process, if we've already entered it.
Offset[inout] On input the offset at which to start parsing. On output, the offset at which the module map terminated.
ExternModuleLocThe location of the "extern module" declaration that caused us to load this module map file, if any.
Returns
true if an error occurred, false otherwise.

Definition at line 2237 of file ModuleMap.cpp.

References clang::SrcMgr::C_System_ModuleMap, clang::SrcMgr::C_User_ModuleMap, clang::File, ModuleMapLoader, clang::ModuleMapLoader::parseAndLoadModuleMapFile(), clang::modulemap::parseModuleMap(), and clang::Result.

◆ parseModuleMapFile()

◆ resolveConflicts()

bool ModuleMap::resolveConflicts ( Module * Mod,
bool Complain )

Resolve all of the unresolved conflicts in the given module.

Parameters
ModThe module whose conflicts should be resolved.
ComplainWhether to emit diagnostics for failures.
Returns
true if any errors were encountered while resolving conflicts, false otherwise.

Definition at line 1518 of file ModuleMap.cpp.

References clang::Module::Conflicts, clang::Module::Conflict::Message, clang::Module::Conflict::Other, clang::Unresolved, and clang::Module::UnresolvedConflicts.

Referenced by clang::Sema::ActOnEndOfTranslationUnit(), and clang::Preprocessor::EnterSubmodule().

◆ resolveExports()

bool ModuleMap::resolveExports ( Module * Mod,
bool Complain )

Resolve all of the unresolved exports in the given module.

Parameters
ModThe module whose exports should be resolved.
ComplainWhether to emit diagnostics for failures.
Returns
true if any errors were encountered while resolving exports, false otherwise.

Definition at line 1491 of file ModuleMap.cpp.

References clang::Module::Exports, clang::Unresolved, and clang::Module::UnresolvedExports.

Referenced by clang::Sema::ActOnEndOfTranslationUnit(), and clang::Preprocessor::EnterSubmodule().

◆ resolveHeaderDirectives() [1/2]

void ModuleMap::resolveHeaderDirectives ( const FileEntry * File) const

Resolve all lazy header directives for the specified file.

This ensures that the HeaderFileInfo on HeaderSearch is up to date. This is effectively internal, but is exposed so HeaderSearch can call it.

Definition at line 1261 of file ModuleMap.cpp.

References clang::File, and resolveHeaderDirectives().

Referenced by collectModuleHeaderIncludes(), diagnoseHeaderInclusion(), findResolvedModulesForHeader(), isHeaderUnavailableInModule(), and resolveHeaderDirectives().

◆ resolveHeaderDirectives() [2/2]

void ModuleMap::resolveHeaderDirectives ( Module * Mod,
std::optional< const FileEntry * > File ) const

Resolve lazy header directives for the specified module.

If File is provided, only headers with same size and modtime are resolved. If File is not set, all headers are resolved.

Definition at line 1277 of file ModuleMap.cpp.

References clang::File, clang::Module::UnresolvedHeaderDirective::ModTime, ModuleMap(), clang::Module::UnresolvedHeaderDirective::Size, and clang::Module::UnresolvedHeaders.

◆ resolveLinkAsDependencies()

void ModuleMap::resolveLinkAsDependencies ( Module * Mod)

Use PendingLinkAsModule information to mark top level link names that are going to be replaced by export_as aliases.

Definition at line 51 of file ModuleMap.cpp.

References findModule(), and clang::Module::Name.

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

◆ resolveUses()

bool ModuleMap::resolveUses ( Module * Mod,
bool Complain )

Resolve all of the unresolved uses in the given module.

Parameters
ModThe module whose uses should be resolved.
ComplainWhether to emit diagnostics for failures.
Returns
true if any errors were encountered while resolving uses, false otherwise.

Definition at line 1504 of file ModuleMap.cpp.

References clang::Module::getTopLevelModule(), and clang::Unresolved.

Referenced by clang::Sema::ActOnEndOfTranslationUnit(), diagnoseHeaderInclusion(), clang::Preprocessor::EnterSubmodule(), and suggestModule().

◆ setBuiltinIncludeDir()

void clang::ModuleMap::setBuiltinIncludeDir ( DirectoryEntryRef Dir)
inline

Set the directory that contains Clang-supplied include files, such as our stdarg.h or tgmath.h.

Definition at line 401 of file ModuleMap.h.

Referenced by clang::ApplyHeaderSearchOptions().

◆ setInferredModuleAllowedBy()

void ModuleMap::setInferredModuleAllowedBy ( Module * M,
FileID ModMapFID )

Definition at line 1426 of file ModuleMap.cpp.

References clang::Module::IsInferred.

Referenced by prepareToBuildModule().

◆ setTarget()

void ModuleMap::setTarget ( const TargetInfo & Target)

Set the target information.

Definition at line 360 of file ModuleMap.cpp.

◆ setUmbrellaDirAsWritten()

void ModuleMap::setUmbrellaDirAsWritten ( Module * Mod,
DirectoryEntryRef UmbrellaDir,
const Twine & NameAsWritten,
const Twine & PathRelativeToRootModuleDirectory )

Sets the umbrella directory of the given module to the given directory.

Definition at line 1215 of file ModuleMap.cpp.

References clang::Module::Umbrella, clang::Module::UmbrellaAsWritten, and clang::Module::UmbrellaRelativeToRootModuleDirectory.

◆ setUmbrellaHeaderAsWritten()

void ModuleMap::setUmbrellaHeaderAsWritten ( Module * Mod,
FileEntryRef UmbrellaHeader,
const Twine & NameAsWritten,
const Twine & PathRelativeToRootModuleDirectory )

Sets the umbrella header of the given module to the given header.

Definition at line 1200 of file ModuleMap.cpp.

References clang::FileEntryRef::getDir(), NormalHeader, clang::Module::Umbrella, clang::Module::UmbrellaAsWritten, and clang::Module::UmbrellaRelativeToRootModuleDirectory.

◆ shouldImportRelativeToBuiltinIncludeDir()

bool ModuleMap::shouldImportRelativeToBuiltinIncludeDir ( StringRef FileName,
Module * Module ) const

◆ ModuleMapLoader

friend class ModuleMapLoader
friend

Definition at line 199 of file ModuleMap.h.

References false, and ModuleMapLoader.

Referenced by findOrLoadModule(), ModuleMapLoader, and parseAndLoadModuleMapFile().


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