diff options
Diffstat (limited to 'include/clang/Basic/Module.h')
-rw-r--r-- | include/clang/Basic/Module.h | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/include/clang/Basic/Module.h b/include/clang/Basic/Module.h index d2a43f0..e8d774e 100644 --- a/include/clang/Basic/Module.h +++ b/include/clang/Basic/Module.h @@ -16,6 +16,7 @@ #define LLVM_CLANG_BASIC_MODULE_H #include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SetVector.h" @@ -37,6 +38,7 @@ class FileEntry; class FileManager; class LangOptions; class TargetInfo; +class IdentifierInfo; /// \brief Describes the name of a module. typedef SmallVector<std::pair<std::string, SourceLocation>, 2> ModuleId; @@ -75,19 +77,28 @@ private: /// \brief top-level header filenames that aren't resolved to FileEntries yet. std::vector<std::string> TopHeaderNames; + /// \brief Cache of modules visible to lookup in this module. + mutable llvm::DenseSet<const Module*> VisibleModulesCache; + public: /// \brief The headers that are part of this module. - SmallVector<const FileEntry *, 2> Headers; + SmallVector<const FileEntry *, 2> NormalHeaders; /// \brief The headers that are explicitly excluded from this module. SmallVector<const FileEntry *, 2> ExcludedHeaders; + /// \brief The headers that are private to this module. + llvm::SmallVector<const FileEntry *, 2> PrivateHeaders; + + /// \brief An individual requirement: a feature name and a flag indicating + /// the required state of that feature. + typedef std::pair<std::string, bool> Requirement; + /// \brief The set of language features required to use this module. /// - /// If any of these features is not present, the \c IsAvailable bit - /// will be false to indicate that this (sub)module is not - /// available. - SmallVector<std::string, 2> Requires; + /// If any of these requirements are not available, the \c IsAvailable bit + /// will be false to indicate that this (sub)module is not available. + SmallVector<Requirement, 2> Requirements; /// \brief Whether this module is available in the current /// translation unit. @@ -176,6 +187,12 @@ public: /// \brief The set of export declarations that have yet to be resolved. SmallVector<UnresolvedExportDecl, 2> UnresolvedExports; + /// \brief The directly used modules. + SmallVector<Module *, 2> DirectUses; + + /// \brief The set of use declarations that have yet to be resolved. + SmallVector<ModuleId, 2> UnresolvedDirectUses; + /// \brief A library or framework to link against when an entity from this /// module is used. struct LinkLibrary { @@ -254,12 +271,12 @@ public: /// /// \param Target The target options used for the current translation unit. /// - /// \param Feature If this module is unavailable, this parameter - /// will be set to one of the features that is required for use of - /// this module (but is not available). + /// \param Req If this module is unavailable, this parameter + /// will be set to one of the requirements that is not met for use of + /// this module. bool isAvailable(const LangOptions &LangOpts, const TargetInfo &Target, - StringRef &Feature) const; + Requirement &Req) const; /// \brief Determine whether this module is a submodule. bool isSubModule() const { return Parent != 0; } @@ -353,12 +370,16 @@ public: /// \param Feature The feature that is required by this module (and /// its submodules). /// + /// \param RequiredState The required state of this feature: \c true + /// if it must be present, \c false if it must be absent. + /// /// \param LangOpts The set of language options that will be used to /// evaluate the availability of this feature. /// /// \param Target The target options that will be used to evaluate the /// availability of this feature. - void addRequirement(StringRef Feature, const LangOptions &LangOpts, + void addRequirement(StringRef Feature, bool RequiredState, + const LangOptions &LangOpts, const TargetInfo &Target); /// \brief Find the submodule with the given name. @@ -366,6 +387,14 @@ public: /// \returns The submodule if found, or NULL otherwise. Module *findSubmodule(StringRef Name) const; + /// \brief Determine whether the specified module would be visible to + /// a lookup at the end of this module. + bool isModuleVisible(const Module *M) const { + if (VisibleModulesCache.empty()) + buildVisibleModulesCache(); + return VisibleModulesCache.count(M); + } + typedef std::vector<Module *>::iterator submodule_iterator; typedef std::vector<Module *>::const_iterator submodule_const_iterator; @@ -374,7 +403,10 @@ public: submodule_iterator submodule_end() { return SubModules.end(); } submodule_const_iterator submodule_end() const { return SubModules.end(); } - /// \brief Returns the exported modules based on the wildcard restrictions. + /// \brief Appends this module's list of exported modules to \p Exported. + /// + /// This provides a subset of immediately imported modules (the ones that are + /// directly exported), not the complete set of exported modules. void getExportedModules(SmallVectorImpl<Module *> &Exported) const; static StringRef getModuleInputBufferName() { @@ -387,6 +419,9 @@ public: /// \brief Dump the contents of this module to the given output stream. void dump() const; + +private: + void buildVisibleModulesCache() const; }; } // end namespace clang |