15 #ifndef LLVM_CLANG_LEX_MODULEMAP_H 16 #define LLVM_CLANG_LEX_MODULEMAP_H 21 #include "llvm/ADT/ArrayRef.h" 22 #include "llvm/ADT/DenseMap.h" 23 #include "llvm/ADT/PointerIntPair.h" 24 #include "llvm/ADT/StringSet.h" 25 #include "llvm/ADT/SmallPtrSet.h" 26 #include "llvm/ADT/SmallVector.h" 27 #include "llvm/ADT/StringMap.h" 28 #include "llvm/ADT/StringRef.h" 29 #include "llvm/ADT/TinyPtrVector.h" 30 #include "llvm/ADT/Twine.h" 38 class DiagnosticsEngine;
93 Module *SourceModule =
nullptr;
97 std::unique_ptr<Module> PendingGlobalModule;
100 llvm::StringMap<Module *> Modules;
106 unsigned NumCreatedModules = 0;
110 llvm::StringMap<llvm::StringSet<>> PendingLinkAsModule;
115 void resolveLinkAsDependencies(
Module *Mod);
119 void addLinkAsDependency(
Module *Mod);
150 llvm::PointerIntPair<Module *, 2, ModuleHeaderRole> Storage;
157 return A.Storage == B.Storage;
160 return A.Storage != B.Storage;
171 return getModule()->isAvailable();
176 return !(getRole() & PrivateHeader) ||
182 explicit operator bool()
const {
183 return Storage.getPointer() !=
nullptr;
193 llvm::DenseMap<const FileEntry *, SmallVector<KnownHeader, 1>>;
200 mutable llvm::DenseMap<off_t, llvm::TinyPtrVector<Module*>> LazyHeadersBySize;
203 mutable llvm::DenseMap<time_t, llvm::TinyPtrVector<Module*>>
204 LazyHeadersByModTime;
212 llvm::DenseMap<const DirectoryEntry *, Module *> UmbrellaDirs;
219 unsigned CurrentModuleScopeID = 0;
221 llvm::DenseMap<Module *, unsigned> ModuleScopeIDs;
226 unsigned IsSystem : 1;
229 unsigned IsExternC : 1;
232 unsigned IsExhaustive : 1;
236 unsigned NoUndeclaredIncludes : 1;
240 NoUndeclaredIncludes(
false) {}
244 struct InferredDirectory {
246 unsigned InferModules : 1;
259 InferredDirectory() : InferModules(
false) {}
264 llvm::DenseMap<const DirectoryEntry *, InferredDirectory> InferredDirectories;
268 llvm::DenseMap<const Module *, const FileEntry *> InferredModuleAllowedBy;
270 llvm::DenseMap<const Module *, AdditionalModMapsSet> AdditionalModMaps;
274 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMap;
290 bool Complain)
const;
312 void addUnresolvedHeader(
Module *Mod,
314 bool &NeedsFramework);
328 bool &NeedsFramework);
337 bool &NeedsFramework);
342 bool resolveAsBuiltinHeader(
Module *M,
350 HeadersMap::iterator findKnownHeader(
const FileEntry *File);
367 bool isHeaderInUmbrellaDirs(
const FileEntry *File) {
369 return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs));
400 BuiltinIncludeDir = Dir;
405 return BuiltinIncludeDir;
409 static bool isBuiltinHeader(StringRef FileName);
413 Callbacks.push_back(std::move(Callback));
428 bool AllowTextual =
false);
442 void resolveHeaderDirectives(
const FileEntry *File)
const;
445 void resolveHeaderDirectives(
Module *Mod)
const;
461 void diagnoseHeaderInclusion(
Module *RequestingModule,
462 bool RequestingModuleIsModuleInterface,
468 bool isHeaderInUnavailableModule(
const FileEntry *Header)
const;
472 bool isHeaderUnavailableInModule(
const FileEntry *Header,
473 const Module *RequestingModule)
const;
480 Module *findModule(StringRef Name)
const;
491 Module *lookupModuleUnqualified(StringRef Name,
Module *Context)
const;
502 Module *lookupModuleQualified(StringRef Name,
Module *Context)
const;
518 std::pair<Module *, bool> findOrCreateModule(StringRef Name,
Module *
Parent,
543 bool IsSystem,
Module *Parent);
547 Module *createShadowedModule(StringRef Name,
bool IsFramework,
558 assert(!ExistingModule->
Parent &&
"expected top-level module");
559 assert(ModuleScopeIDs.count(ExistingModule) &&
"unknown module");
560 return ModuleScopeIDs[ExistingModule] < CurrentModuleScopeID;
581 const FileEntry *getModuleMapFileForUniquing(
const Module *M)
const;
590 auto I = AdditionalModMaps.find(M);
591 if (I == AdditionalModMaps.end())
597 AdditionalModMaps[M].insert(ModuleMap);
608 bool resolveExports(Module *Mod,
bool Complain);
618 bool resolveUses(Module *Mod,
bool Complain);
628 bool resolveConflicts(Module *Mod,
bool Complain);
632 void setUmbrellaHeader(Module *Mod,
const FileEntry *UmbrellaHeader,
633 Twine NameAsWritten);
637 void setUmbrellaDir(Module *Mod,
const DirectoryEntry *UmbrellaDir,
638 Twine NameAsWritten);
668 bool parseModuleMapFile(
const FileEntry *File,
bool IsSystem,
684 #endif // LLVM_CLANG_LEX_MODULEMAP_H
Implements support for file system lookup, file system caching, and directory search management...
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
Defines the clang::Module class, which describes a module in the source code.
llvm::StringMap< Module * >::const_iterator module_iterator
void finishModuleDeclarationScope()
Creates a new declaration scope for module names, allowing previously defined modules to shadow defin...
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.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Concrete class used by the front-end to report problems and issues.
Module * Parent
The parent of this module.
void addModuleMapCallbacks(std::unique_ptr< ModuleMapCallbacks > Callback)
Add a module map callback.
ModuleHeaderRole
Flags describing the role of a module header.
SmallVector< std::pair< std::string, SourceLocation >, 2 > ModuleId
Describes the name of a module.
Exposes information about the current target.
Defines the clang::LangOptions interface.
virtual void moduleMapFileRead(SourceLocation FileStart, const FileEntry &File, bool IsSystem)
Called when a module map file has been read.
llvm::SmallPtrSet< const FileEntry *, 1 > AdditionalModMapsSet
module_iterator module_begin() const
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)
const DirectoryEntry * getBuiltinDir() const
Get the directory that contains Clang-supplied include files.
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.
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.
module_iterator module_end() const
bool mayShadowNewModule(Module *ExistingModule)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Dataflow Directional Tag Classes.
virtual ~ModuleMapCallbacks()=default
llvm::PointerIntPair< Module *, 1, bool > ExportDecl
Describes an exported 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 ...
Cached information about one directory (either on disk or in the virtual file system).
Defines the clang::SourceLocation class and associated facilities.
This class handles loading and caching of source files into memory.