16 #ifndef LLVM_CLANG_LEX_MODULEMAP_H
17 #define LLVM_CLANG_LEX_MODULEMAP_H
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/IntrusiveRefCntPtr.h"
24 #include "llvm/ADT/SmallVector.h"
25 #include "llvm/ADT/StringMap.h"
26 #include "llvm/ADT/StringRef.h"
34 class DiagnosticConsumer;
35 class DiagnosticsEngine;
37 class ModuleMapParser;
65 llvm::StringMap<Module *> Modules;
68 unsigned NumCreatedModules;
91 llvm::PointerIntPair<Module *, 2, ModuleHeaderRole> Storage;
110 explicit operator bool()
const {
111 return Storage.getPointer() !=
nullptr;
118 typedef llvm::DenseMap<const FileEntry *, SmallVector<KnownHeader, 1> >
131 llvm::DenseMap<const DirectoryEntry *, Module *> UmbrellaDirs;
135 Attributes() : IsSystem(), IsExternC(), IsExhaustive() {}
138 unsigned IsSystem : 1;
141 unsigned IsExternC : 1;
144 unsigned IsExhaustive : 1;
148 struct InferredDirectory {
149 InferredDirectory() : InferModules() {}
152 unsigned InferModules : 1;
159 const FileEntry *ModuleMapFile;
163 SmallVector<std::string, 2> ExcludedModules;
168 llvm::DenseMap<const DirectoryEntry *, InferredDirectory> InferredDirectories;
172 llvm::DenseMap<const Module *, const FileEntry *> InferredModuleAllowedBy;
174 llvm::DenseMap<const Module *, AdditionalModMapsSet> AdditionalModMaps;
178 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMap;
196 bool Complain)
const;
216 HeadersMap::iterator findKnownHeader(
const FileEntry *File);
229 bool isHeaderInUmbrellaDirs(
const FileEntry *File) {
231 return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs));
235 Attributes Attrs,
Module *Parent);
263 BuiltinIncludeDir = Dir;
295 const Module *RequestingModule)
const;
347 bool IsSystem,
Module *Parent);
376 auto I = AdditionalModMaps.find(M);
377 if (I == AdditionalModMaps.end())
383 AdditionalModMaps[M].insert(ModuleMap);
429 Twine NameAsWritten);
434 Twine NameAsWritten);
void addHeader(Module *Mod, Module::Header Header, ModuleHeaderRole Role)
Adds this header to the given module.
ModuleMap(SourceManager &SourceMgr, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const TargetInfo *Target, HeaderSearch &HeaderInfo)
Construct a new module map.
Module * lookupModuleQualified(StringRef Name, Module *Context) const
Retrieve a module with the given name within the given context, using direct (qualified) name lookup...
This header is included but private.
bool parseModuleMapFile(const FileEntry *File, bool IsSystem, const DirectoryEntry *HomeDir, SourceLocation ExternModuleLoc=SourceLocation())
Parse the given module map file, and record any modules we encounter.
module_iterator module_begin() const
Module * findModule(StringRef Name) const
Retrieve a module with the given name.
This header is part of the module (for layering purposes) but should be textually included...
bool isHeaderInUnavailableModule(const FileEntry *Header) const
Determine whether the given header is part of a module marked 'unavailable'.
Defines the SourceManager interface.
llvm::SmallPtrSet< const FileEntry *, 1 > AdditionalModMapsSet
Defines the clang::Module class, which describes a module in the source code.
void excludeHeader(Module *Mod, Module::Header Header)
Marks this header as being excluded from the given module.
bool resolveUses(Module *Mod, bool Complain)
Resolve all of the unresolved uses in the given module.
bool isHeaderUnavailableInModule(const FileEntry *Header, const Module *RequestingModule) const
Determine whether the given header is unavailable as part of the specified module.
bool resolveConflicts(Module *Mod, bool Complain)
Resolve all of the unresolved conflicts in the given module.
void setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir, Twine NameAsWritten)
Sets the umbrella directory of the given module to the given directory.
std::string SourceModuleName
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Describes a module or submodule.
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
Concrete class used by the front-end to report problems and issues.
module_iterator module_end() const
const FileEntry * getContainingModuleMapFile(const Module *Module) const
Retrieve the module map file containing the definition of the given module.
void setTarget(const TargetInfo &Target)
Set the target information.
llvm::StringMap< Module * >::const_iterator module_iterator
void diagnoseHeaderInclusion(Module *RequestingModule, SourceLocation FilenameLoc, StringRef Filename, const FileEntry *File)
Reports errors if a module must not include a specific file.
ModuleHeaderRole
Flags describing the role of a module header.
Exposes information about the current target.
Defines the clang::LangOptions interface.
void dump()
Dump the contents of the module map, for debugging purposes.
Module * lookupModuleUnqualified(StringRef Name, Module *Context) const
Retrieve a module with the given name using lexical name lookup, starting at the given context...
bool resolveExports(Module *Mod, bool Complain)
Resolve all of the unresolved exports in the given module.
SmallVector< std::pair< std::string, SourceLocation >, 2 > ModuleId
Describes the name of a module.
void setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader, Twine NameAsWritten)
Sets the umbrella header of the given module to the given header.
void addAdditionalModuleMapFile(const Module *M, const FileEntry *ModuleMap)
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.
void setBuiltinIncludeDir(const DirectoryEntry *Dir)
Set the directory that contains Clang-supplied include files, such as our stdarg.h or tgmath...
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
Cached information about one file (either on disk or in the virtual file system). ...
This header is normally included in the module.
Module * inferModuleFromLocation(FullSourceLoc Loc)
Infers the (sub)module based on the given source location and source manager.
const FileEntry * getModuleMapFileForUniquing(const Module *M) const
Get the module map file that (along with the module name) uniquely identifies this module...
AdditionalModMapsSet * getAdditionalModuleMapFiles(const Module *M)
Get any module map files other than getModuleMapFileForUniquing(M) that define submodules of a top-le...
Describes an exported module that has not yet been resolved (perhaps because the module it refers to ...
KnownHeader findModuleForHeader(const FileEntry *File)
Retrieve the module that owns the given header file, if any.
Cached information about one directory (either on disk or in the virtual file system).
llvm::PointerIntPair< Module *, 1, bool > ExportDecl
Describes an exported module.
A SourceLocation and its associated SourceManager.
~ModuleMap()
Destroy the module map.
void setInferredModuleAllowedBy(Module *M, const FileEntry *ModuleMap)
This class handles loading and caching of source files into memory.