14 #ifndef LLVM_CLANG_LEX_MODULEMAP_H 15 #define LLVM_CLANG_LEX_MODULEMAP_H 20 #include "llvm/ADT/ArrayRef.h" 21 #include "llvm/ADT/DenseMap.h" 22 #include "llvm/ADT/PointerIntPair.h" 23 #include "llvm/ADT/StringSet.h" 24 #include "llvm/ADT/SmallPtrSet.h" 25 #include "llvm/ADT/SmallVector.h" 26 #include "llvm/ADT/StringMap.h" 27 #include "llvm/ADT/StringRef.h" 28 #include "llvm/ADT/TinyPtrVector.h" 29 #include "llvm/ADT/Twine.h" 37 class DiagnosticsEngine;
47 virtual void anchor();
94 Module *SourceModule =
nullptr;
101 llvm::StringMap<Module *> Modules;
107 unsigned NumCreatedModules = 0;
111 llvm::StringMap<llvm::StringSet<>> PendingLinkAsModule;
116 void resolveLinkAsDependencies(
Module *Mod);
120 void addLinkAsDependency(
Module *Mod);
151 llvm::PointerIntPair<Module *, 2, ModuleHeaderRole> Storage;
158 return A.Storage == B.Storage;
161 return A.Storage != B.Storage;
172 return getModule()->isAvailable();
177 return !(getRole() & PrivateHeader) ||
183 explicit operator bool()
const {
184 return Storage.getPointer() !=
nullptr;
194 llvm::DenseMap<const FileEntry *, SmallVector<KnownHeader, 1>>;
201 mutable llvm::DenseMap<off_t, llvm::TinyPtrVector<Module*>> LazyHeadersBySize;
204 mutable llvm::DenseMap<time_t, llvm::TinyPtrVector<Module*>>
205 LazyHeadersByModTime;
213 llvm::DenseMap<const DirectoryEntry *, Module *> UmbrellaDirs;
220 unsigned CurrentModuleScopeID = 0;
222 llvm::DenseMap<Module *, unsigned> ModuleScopeIDs;
227 unsigned IsSystem : 1;
230 unsigned IsExternC : 1;
233 unsigned IsExhaustive : 1;
237 unsigned NoUndeclaredIncludes : 1;
241 NoUndeclaredIncludes(
false) {}
245 struct InferredDirectory {
247 unsigned InferModules : 1;
260 InferredDirectory() : InferModules(
false) {}
265 llvm::DenseMap<const DirectoryEntry *, InferredDirectory> InferredDirectories;
269 llvm::DenseMap<const Module *, const FileEntry *> InferredModuleAllowedBy;
271 llvm::DenseMap<const Module *, AdditionalModMapsSet> AdditionalModMaps;
275 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMap;
291 bool Complain)
const;
313 void addUnresolvedHeader(
Module *Mod,
315 bool &NeedsFramework);
329 bool &NeedsFramework);
338 bool &NeedsFramework);
343 bool resolveAsBuiltinHeader(
Module *M,
351 HeadersMap::iterator findKnownHeader(
const FileEntry *File);
368 bool isHeaderInUmbrellaDirs(
const FileEntry *File) {
370 return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs));
401 BuiltinIncludeDir = Dir;
406 return BuiltinIncludeDir;
410 static bool isBuiltinHeader(StringRef FileName);
414 Callbacks.push_back(std::move(Callback));
429 bool AllowTextual =
false);
443 void resolveHeaderDirectives(
const FileEntry *File)
const;
446 void resolveHeaderDirectives(
Module *Mod)
const;
462 void diagnoseHeaderInclusion(
Module *RequestingModule,
463 bool RequestingModuleIsModuleInterface,
469 bool isHeaderInUnavailableModule(
const FileEntry *Header)
const;
473 bool isHeaderUnavailableInModule(
const FileEntry *Header,
474 const Module *RequestingModule)
const;
481 Module *findModule(StringRef Name)
const;
492 Module *lookupModuleUnqualified(StringRef Name,
Module *Context)
const;
503 Module *lookupModuleQualified(StringRef Name,
Module *Context)
const;
519 std::pair<Module *, bool> findOrCreateModule(StringRef Name,
Module *
Parent,
531 Module *createPrivateModuleFragmentForInterfaceUnit(
Module *Parent,
550 bool IsSystem,
Module *Parent);
554 Module *createShadowedModule(StringRef Name,
bool IsFramework,
565 assert(!ExistingModule->
Parent &&
"expected top-level module");
566 assert(ModuleScopeIDs.count(ExistingModule) &&
"unknown module");
567 return ModuleScopeIDs[ExistingModule] < CurrentModuleScopeID;
588 const FileEntry *getModuleMapFileForUniquing(
const Module *M)
const;
590 void setInferredModuleAllowedBy(Module *M,
const FileEntry *ModMap);
597 auto I = AdditionalModMaps.find(M);
598 if (I == AdditionalModMaps.end())
604 AdditionalModMaps[M].insert(ModuleMap);
615 bool resolveExports(Module *Mod,
bool Complain);
625 bool resolveUses(Module *Mod,
bool Complain);
635 bool resolveConflicts(Module *Mod,
bool Complain);
639 void setUmbrellaHeader(Module *Mod,
const FileEntry *UmbrellaHeader,
640 Twine NameAsWritten);
644 void setUmbrellaDir(Module *Mod,
const DirectoryEntry *UmbrellaDir,
645 Twine NameAsWritten);
675 bool parseModuleMapFile(
const FileEntry *File,
bool IsSystem,
691 #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.
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.