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;
90 llvm::StringMap<Module *> Modules;
93 unsigned NumCreatedModules;
116 llvm::PointerIntPair<Module *, 2, ModuleHeaderRole> Storage;
123 return A.Storage == B.Storage;
126 return A.Storage != B.Storage;
148 explicit operator bool()
const {
149 return Storage.getPointer() !=
nullptr;
156 typedef llvm::DenseMap<const FileEntry *, SmallVector<KnownHeader, 1> >
169 llvm::DenseMap<const DirectoryEntry *, Module *> UmbrellaDirs;
173 Attributes() : IsSystem(), IsExternC(), IsExhaustive() {}
176 unsigned IsSystem : 1;
179 unsigned IsExternC : 1;
182 unsigned IsExhaustive : 1;
186 struct InferredDirectory {
187 InferredDirectory() : InferModules() {}
190 unsigned InferModules : 1;
197 const FileEntry *ModuleMapFile;
201 SmallVector<std::string, 2> ExcludedModules;
206 llvm::DenseMap<const DirectoryEntry *, InferredDirectory> InferredDirectories;
210 llvm::DenseMap<const Module *, const FileEntry *> InferredModuleAllowedBy;
212 llvm::DenseMap<const Module *, AdditionalModMapsSet> AdditionalModMaps;
216 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMap;
234 bool Complain)
const;
271 bool isHeaderInUmbrellaDirs(
const FileEntry *File) {
273 return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs));
277 Attributes Attrs,
Module *Parent);
305 BuiltinIncludeDir = Dir;
310 Callbacks.push_back(std::move(Callback));
345 bool RequestingModuleIsModuleInterface,
356 const Module *RequestingModule)
const;
408 bool IsSystem,
Module *Parent);
437 auto I = AdditionalModMaps.find(M);
438 if (
I == AdditionalModMaps.end())
444 AdditionalModMaps[M].insert(ModuleMap);
490 Twine NameAsWritten);
495 Twine NameAsWritten);
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
Implements support for file system lookup, file system caching, and directory search management...
void dump()
Dump the contents of the module map, for debugging purposes.
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'.
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
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.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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.
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...
ArrayRef< KnownHeader > findAllModulesForHeader(const FileEntry *File) const
Retrieve all the modules that contain the given header file.
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 addModuleMapCallbacks(std::unique_ptr< ModuleMapCallbacks > Callback)
Add a module map callback.
detail::InMemoryDirectory::const_iterator I
void setTarget(const TargetInfo &Target)
Set the target information.
llvm::StringMap< Module * >::const_iterator module_iterator
ModuleHeaderRole
Flags describing the role of a module header.
Exposes information about the current target.
void diagnoseHeaderInclusion(Module *RequestingModule, bool RequestingModuleIsModuleInterface, SourceLocation FilenameLoc, StringRef Filename, const FileEntry *File)
Reports errors if a module must not include a specific file.
Defines the clang::LangOptions interface.
MatchFinder::MatchCallback * Callback
Module * lookupModuleUnqualified(StringRef Name, Module *Context) const
Retrieve a module with the given name using lexical name lookup, starting at the given context...
virtual void moduleMapFileRead(SourceLocation FileStart, const FileEntry &File, bool IsSystem)
Called when a module map file has been read.
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.
A mechanism to observe the actions of the module map parser as it reads module map files...
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.
virtual void moduleMapAddUmbrellaHeader(FileManager *FileMgr, const FileEntry *Header)
Called when an umbrella header is added during module map parsing.
const TemplateArgument * iterator
Cached information about one file (either on disk or in the virtual file system). ...
virtual void moduleMapAddHeader(StringRef Filename)
Called when a header is added during module map parsing.
This header is normally included in the module.
void addHeader(Module *Mod, Module::Header Header, ModuleHeaderRole Role, bool Imported=false)
Adds this header to the given 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.
virtual ~ModuleMapCallbacks()
void setInferredModuleAllowedBy(Module *M, const FileEntry *ModuleMap)
This class handles loading and caching of source files into memory.