15 #ifndef LLVM_CLANG_BASIC_MODULE_H
16 #define LLVM_CLANG_BASIC_MODULE_H
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/DenseSet.h"
21 #include "llvm/ADT/PointerIntPair.h"
22 #include "llvm/ADT/PointerUnion.h"
23 #include "llvm/ADT/SetVector.h"
24 #include "llvm/ADT/SmallVector.h"
25 #include "llvm/ADT/STLExtras.h"
26 #include "llvm/ADT/StringMap.h"
27 #include "llvm/ADT/StringRef.h"
67 llvm::PointerUnion<const DirectoryEntry *, const FileEntry *>
Umbrella;
77 std::vector<Module *> SubModules;
81 llvm::StringMap<unsigned> SubModuleIndex;
91 std::vector<std::string> TopHeaderNames;
97 unsigned VisibilityID;
260 : Library(Library), IsFramework(IsFramework) { }
329 UnresolvedHeaderDirective &MissingHeader)
const;
343 if (Mod->IsFramework)
362 return const_cast<Module *
>(
383 assert((File ==
nullptr ||
getASTFile() ==
nullptr ||
384 getASTFile() == File) &&
"file path changed");
409 TopHeaders.insert(File);
414 TopHeaderNames.push_back(Filename);
457 if (VisibleModulesCache.empty())
458 buildVisibleModulesCache();
459 return VisibleModulesCache.count(M);
479 return "<module-includes>";
484 void print(raw_ostream &OS,
unsigned Indent = 0)
const;
490 void buildVisibleModulesCache()
const;
498 : ImportLocs(std::move(O.ImportLocs)), Generation(O.Generation ? 1 : 0) {
499 O.ImportLocs.clear();
506 ImportLocs = std::move(O.ImportLocs);
507 O.ImportLocs.clear();
535 typedef llvm::function_ref<void(ArrayRef<Module *> Path,
536 Module *Conflict, StringRef Message)>
547 std::vector<SourceLocation> ImportLocs;
555 #endif // LLVM_CLANG_BASIC_MODULE_H
SourceLocation ExportLoc
The location of the 'export' keyword in the module map file.
unsigned IsAvailable
Whether this module is available in the current translation unit.
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
std::string Name
The name of this module.
A set of visible modules.
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
std::string Message
The message provided to the user when there is a conflict.
Implements support for file system lookup, file system caching, and directory search management...
An unresolved conflict with another module.
submodule_iterator submodule_begin()
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "...
void addTopHeaderFilename(StringRef Filename)
Add a top-level header filename associated with this module.
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
std::vector< UnresolvedConflict > UnresolvedConflicts
The list of conflicts for which the module-id has not yet been resolved.
unsigned getVisibilityID() const
unsigned IsFramework
Whether this is a framework module.
bool isModuleVisible(const Module *M) const
Determine whether the specified module would be visible to a lookup at the end of this module...
void addRequirement(StringRef Feature, bool RequiredState, const LangOptions &LangOpts, const TargetInfo &Target)
Add the given feature requirement to the list of features required by this module.
void getExportedModules(SmallVectorImpl< Module * > &Exported) const
Appends this module's list of exported modules to Exported.
const FileEntry * getASTFile() const
The serialized AST file for this module, if one was created.
llvm::function_ref< void(Module *M)> VisibleCallback
A callback to call when a module is made visible (directly or indirectly) by a call to setVisible...
static const int NumHeaderKinds
void markUnavailable(bool MissingRequirement=false)
Mark this module and all of its submodules as unavailable.
std::string getFullModuleName() const
Retrieve the full name of this module, including the path from its top-level module.
A library or framework to link against when an entity from this module is used.
static StringRef getModuleInputBufferName()
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
bool isVisible(const Module *M) const
Determine whether a module is visible.
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 directlyUses(const Module *Requested) const
Determine whether this module has declared its intention to directly use another module.
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e...
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
std::string Message
The message provided to the user when there is a conflict.
ModuleId Id
The (unresolved) module id.
Module * Parent
The parent of this module. This will be NULL for the top-level module.
unsigned IsInferred
Whether this is an inferred submodule (module * { ... }).
unsigned IsFromModuleFile
Whether this module was loaded from a module file.
submodule_iterator submodule_end()
LinkLibrary(const std::string &Library, bool IsFramework)
VisibleModuleSet(VisibleModuleSet &&O)
std::vector< Module * >::iterator submodule_iterator
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers)...
Module * findSubmodule(StringRef Name) const
Find the submodule with the given name.
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
std::string Library
The library to link against.
bool isSubModule() const
Determine whether this module is a submodule.
bool isPartOfFramework() const
Determine whether this module is a part of a framework, either because it is a framework module or be...
const DirectoryEntry * Entry
void setVisible(Module *M, SourceLocation Loc, VisibleCallback Vis=[](Module *){}, ConflictCallback Cb=[](ArrayRef< Module * >, Module *, StringRef){})
Make a specific module visible.
void dump() const
Dump the contents of this module to the given output stream.
Exposes information about the current target.
uint64_t Signature
The module signature.
SmallVector< ModuleId, 2 > UnresolvedDirectUses
The set of use declarations that have yet to be resolved.
ModuleId Id
The name of the module.
VisibleModuleSet & operator=(VisibleModuleSet &&O)
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
ArrayRef< const FileEntry * > getTopHeaders(FileManager &FileMgr)
The top-level headers associated with this module.
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used...
Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, bool IsFramework, bool IsExplicit, unsigned VisibilityID)
Construct a new module or submodule.
SmallVector< std::pair< std::string, SourceLocation >, 2 > ModuleId
Describes the name of a module.
bool isSubModuleOf(const Module *Other) const
Determine whether this module is a submodule of the given other module.
std::vector< Module * >::const_iterator submodule_const_iterator
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
SmallVector< ExportDecl, 2 > Exports
The set of export declarations.
const DirectoryEntry * Directory
The build directory of this module. This is the directory in which the module is notionally built...
void setASTFile(const FileEntry *File)
Set the serialized AST file for the top-level module of this module.
void print(raw_ostream &OS, unsigned Indent=0) const
Print the module map for this module to the given stream.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
submodule_const_iterator submodule_begin() const
bool isValid() const
Return true if this is a valid SourceLocation object.
NameVisibilityKind NameVisibility
The visibility of names within this particular module.
All of the names in this module are hidden.
Information about a directory name as found in the module map file.
Cached information about one file (either on disk or in the virtual file system). ...
SmallVector< Header, 2 > Headers[5]
The headers that are part of this module.
bool isSubFramework() const
Determine whether this module is a subframework of another framework.
bool Wildcard
Whether this export declaration ends in a wildcard, indicating that all of its submodules should be e...
submodule_const_iterator submodule_end() const
A conflict between two modules.
SourceLocation getImportLoc(const Module *M) const
Get the location at which the import of a module was triggered.
unsigned IsMissingRequirement
Whether this module is missing a feature from Requirements.
llvm::PointerUnion< const DirectoryEntry *, const FileEntry * > Umbrella
The umbrella header or directory.
SourceLocation InferredSubmoduleLoc
The location of the inferred submodule.
bool hasUmbrellaDir() const
Determine whether this module has an umbrella directory that is not based on an umbrella header...
void addTopHeader(const FileEntry *File)
Add a top-level header associated with this module.
llvm::function_ref< void(ArrayRef< Module * > Path, Module *Conflict, StringRef Message)> ConflictCallback
A callback to call when a module conflict is found. Path consists of a sequence of modules from the c...
All of the names in this module are visible.
SourceLocation DefinitionLoc
The location of the module definition.
std::vector< Conflict > Conflicts
The list of conflicts.
SmallVector< Module *, 2 > DirectUses
The directly used modules.
Describes an exported module that has not yet been resolved (perhaps because the module it refers to ...
std::pair< std::string, bool > Requirement
An individual requirement: a feature name and a flag indicating the required state of that feature...
std::string NameAsWritten
Cached information about one directory (either on disk or in the virtual file system).
Defines the clang::SourceLocation class and associated facilities.
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
llvm::PointerIntPair< Module *, 1, bool > ExportDecl
Describes an exported module.
NameVisibilityKind
Describes the visibility of the various names within a particular module.
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
unsigned getGeneration() const
Get the current visibility generation. Incremented each time the set of visible modules changes in an...
std::string UmbrellaAsWritten
The name of the umbrella entry, as written in the module map.
Module * Other
The module that this module conflicts with.
bool IsFramework
Whether this is a framework rather than a library.
unsigned IsExplicit
Whether this is an explicit submodule.
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.