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/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;
92 Module *SourceModule =
nullptr;
96 std::unique_ptr<Module> PendingGlobalModule;
99 llvm::StringMap<Module *> Modules;
102 unsigned NumCreatedModules = 0;
134 llvm::PointerIntPair<Module *, 2, ModuleHeaderRole> Storage;
141 return A.Storage == B.Storage;
144 return A.Storage != B.Storage;
155 return getModule()->isAvailable();
160 return !(getRole() & PrivateHeader) ||
166 explicit operator bool()
const {
167 return Storage.getPointer() !=
nullptr;
177 llvm::DenseMap<const FileEntry *, SmallVector<KnownHeader, 1>>;
184 mutable llvm::DenseMap<off_t, llvm::TinyPtrVector<Module*>> LazyHeadersBySize;
187 mutable llvm::DenseMap<time_t, llvm::TinyPtrVector<Module*>>
188 LazyHeadersByModTime;
196 llvm::DenseMap<const DirectoryEntry *, Module *> UmbrellaDirs;
201 unsigned IsSystem : 1;
204 unsigned IsExternC : 1;
207 unsigned IsExhaustive : 1;
211 unsigned NoUndeclaredIncludes : 1;
215 NoUndeclaredIncludes(
false) {}
219 struct InferredDirectory {
221 unsigned InferModules : 1;
234 InferredDirectory() : InferModules(
false) {}
239 llvm::DenseMap<const DirectoryEntry *, InferredDirectory> InferredDirectories;
243 llvm::DenseMap<const Module *, const FileEntry *> InferredModuleAllowedBy;
245 llvm::DenseMap<const Module *, AdditionalModMapsSet> AdditionalModMaps;
249 llvm::DenseMap<const FileEntry *, bool> ParsedModuleMap;
265 bool Complain)
const;
281 void addUnresolvedHeader(
Module *Mod,
296 void resolveHeader(
Module *M,
302 bool resolveAsBuiltinHeader(
Module *M,
310 HeadersMap::iterator findKnownHeader(
const FileEntry *File);
327 bool isHeaderInUmbrellaDirs(
const FileEntry *File) {
329 return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs));
360 BuiltinIncludeDir = Dir;
365 return BuiltinIncludeDir;
369 static bool isBuiltinHeader(StringRef FileName);
373 Callbacks.push_back(std::move(Callback));
388 bool AllowTextual =
false);
402 void resolveHeaderDirectives(
const FileEntry *File)
const;
405 void resolveHeaderDirectives(
Module *Mod)
const;
421 void diagnoseHeaderInclusion(
Module *RequestingModule,
422 bool RequestingModuleIsModuleInterface,
428 bool isHeaderInUnavailableModule(
const FileEntry *Header)
const;
432 bool isHeaderUnavailableInModule(
const FileEntry *Header,
433 const Module *RequestingModule)
const;
440 Module *findModule(StringRef Name)
const;
451 Module *lookupModuleUnqualified(StringRef Name,
Module *Context)
const;
462 Module *lookupModuleQualified(StringRef Name,
Module *Context)
const;
478 std::pair<Module *, bool> findOrCreateModule(StringRef Name,
Module *
Parent,
503 bool IsSystem,
Module *Parent);
523 const FileEntry *getModuleMapFileForUniquing(
const Module *M)
const;
532 auto I = AdditionalModMaps.find(M);
533 if (I == AdditionalModMaps.end())
539 AdditionalModMaps[M].insert(ModuleMap);
550 bool resolveExports(Module *Mod,
bool Complain);
560 bool resolveUses(Module *Mod,
bool Complain);
570 bool resolveConflicts(Module *Mod,
bool Complain);
574 void setUmbrellaHeader(Module *Mod,
const FileEntry *UmbrellaHeader,
575 Twine NameAsWritten);
579 void setUmbrellaDir(Module *Mod,
const DirectoryEntry *UmbrellaDir,
580 Twine NameAsWritten);
610 bool parseModuleMapFile(
const FileEntry *File,
bool IsSystem,
612 unsigned *
Offset =
nullptr,
626 #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
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.
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
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.