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;
48 virtual void anchor();
95 Module *SourceModule =
nullptr;
102 llvm::StringMap<Module *> Modules;
108 unsigned NumCreatedModules = 0;
112 llvm::StringMap<llvm::StringSet<>> PendingLinkAsModule;
117 void resolveLinkAsDependencies(
Module *Mod);
121 void addLinkAsDependency(
Module *Mod);
152 llvm::PointerIntPair<Module *, 2, ModuleHeaderRole> Storage;
159 return A.Storage == B.Storage;
162 return A.Storage != B.Storage;
173 return getModule()->isAvailable();
178 return !(getRole() & PrivateHeader) ||
184 explicit operator bool()
const {
185 return Storage.getPointer() !=
nullptr;
195 llvm::DenseMap<const FileEntry *, SmallVector<KnownHeader, 1>>;
202 mutable llvm::DenseMap<off_t, llvm::TinyPtrVector<Module*>> LazyHeadersBySize;
205 mutable llvm::DenseMap<time_t, llvm::TinyPtrVector<Module*>>
206 LazyHeadersByModTime;
214 llvm::DenseMap<const DirectoryEntry *, Module *> UmbrellaDirs;
221 unsigned CurrentModuleScopeID = 0;
223 llvm::DenseMap<Module *, unsigned> ModuleScopeIDs;
228 unsigned IsSystem : 1;
231 unsigned IsExternC : 1;
234 unsigned IsExhaustive : 1;
238 unsigned NoUndeclaredIncludes : 1;
242 NoUndeclaredIncludes(
false) {}
246 struct InferredDirectory {
248 unsigned InferModules : 1;
261 InferredDirectory() : InferModules(
false) {}
266 llvm::DenseMap<const DirectoryEntry *, InferredDirectory> InferredDirectories;
270 llvm::DenseMap<const Module *, const FileEntry *> InferredModuleAllowedBy;
272 llvm::DenseMap<const Module *, AdditionalModMapsSet> AdditionalModMaps;
276 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMap;
292 bool Complain)
const;
314 void addUnresolvedHeader(
Module *Mod,
316 bool &NeedsFramework);
330 bool &NeedsFramework);
339 bool &NeedsFramework);
344 bool resolveAsBuiltinHeader(
Module *M,
352 HeadersMap::iterator findKnownHeader(
const FileEntry *File);
369 bool isHeaderInUmbrellaDirs(
const FileEntry *File) {
371 return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs));
402 BuiltinIncludeDir = Dir;
407 return BuiltinIncludeDir;
411 static bool isBuiltinHeader(StringRef FileName);
415 Callbacks.push_back(std::move(Callback));
430 bool AllowTextual =
false);
444 void resolveHeaderDirectives(
const FileEntry *File)
const;
447 void resolveHeaderDirectives(
Module *Mod)
const;
463 void diagnoseHeaderInclusion(
Module *RequestingModule,
464 bool RequestingModuleIsModuleInterface,
470 bool isHeaderInUnavailableModule(
const FileEntry *Header)
const;
474 bool isHeaderUnavailableInModule(
const FileEntry *Header,
475 const Module *RequestingModule)
const;
482 Module *findModule(StringRef Name)
const;
493 Module *lookupModuleUnqualified(StringRef Name,
Module *Context)
const;
504 Module *lookupModuleQualified(StringRef Name,
Module *Context)
const;
520 std::pair<Module *, bool> findOrCreateModule(StringRef Name,
Module *
Parent,
547 bool IsSystem,
Module *Parent);
551 Module *createShadowedModule(StringRef Name,
bool IsFramework,
562 assert(!ExistingModule->
Parent &&
"expected top-level module");
563 assert(ModuleScopeIDs.count(ExistingModule) &&
"unknown module");
564 return ModuleScopeIDs[ExistingModule] < CurrentModuleScopeID;
585 const FileEntry *getModuleMapFileForUniquing(
const Module *M)
const;
587 void setInferredModuleAllowedBy(Module *M,
const FileEntry *ModMap);
594 auto I = AdditionalModMaps.find(M);
595 if (I == AdditionalModMaps.end())
601 AdditionalModMaps[M].insert(ModuleMap);
612 bool resolveExports(Module *Mod,
bool Complain);
622 bool resolveUses(Module *Mod,
bool Complain);
632 bool resolveConflicts(Module *Mod,
bool Complain);
636 void setUmbrellaHeader(Module *Mod,
const FileEntry *UmbrellaHeader,
637 Twine NameAsWritten);
641 void setUmbrellaDir(Module *Mod,
const DirectoryEntry *UmbrellaDir,
642 Twine NameAsWritten);
672 bool parseModuleMapFile(
const FileEntry *File,
bool IsSystem,
688 #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.