diff options
author | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
commit | 173a4f43a911175643bda81ee675e8d9269056ea (patch) | |
tree | 47df2c12b57214af6c31e47404b005675b8b7ffc /include/clang/Lex/ModuleMap.h | |
parent | 88f7a7d5251a2d813460274c92decc143a11569b (diff) | |
download | FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz |
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'include/clang/Lex/ModuleMap.h')
-rw-r--r-- | include/clang/Lex/ModuleMap.h | 66 |
1 files changed, 58 insertions, 8 deletions
diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h index 3a17157..a86a927 100644 --- a/include/clang/Lex/ModuleMap.h +++ b/include/clang/Lex/ModuleMap.h @@ -38,7 +38,7 @@ class ModuleMapParser; class ModuleMap { SourceManager &SourceMgr; - IntrusiveRefCntPtr<DiagnosticsEngine> Diags; + DiagnosticsEngine &Diags; const LangOptions &LangOpts; const TargetInfo *Target; HeaderSearch &HeaderInfo; @@ -86,7 +86,7 @@ public: llvm::PointerIntPair<Module *, 2, ModuleHeaderRole> Storage; public: - KnownHeader() : Storage(0, NormalHeader) { } + KnownHeader() : Storage(nullptr, NormalHeader) { } KnownHeader(Module *M, ModuleHeaderRole Role) : Storage(M, Role) { } /// \brief Retrieve the module the header is stored in. @@ -102,7 +102,9 @@ public: // \brief Whether this known header is valid (i.e., it has an // associated module). - LLVM_EXPLICIT operator bool() const { return Storage.getPointer() != 0; } + LLVM_EXPLICIT operator bool() const { + return Storage.getPointer() != nullptr; + } }; private: @@ -131,6 +133,10 @@ private: /// \brief Whether the modules we infer are [system] modules. unsigned InferSystemModules : 1; + /// \brief If \c InferModules is non-zero, the module map file that allowed + /// inferred modules. Otherwise, nullptr. + const FileEntry *ModuleMapFile; + /// \brief The names of modules that cannot be inferred within this /// directory. SmallVector<std::string, 2> ExcludedModules; @@ -175,6 +181,29 @@ private: /// resolved. Module *resolveModuleId(const ModuleId &Id, Module *Mod, bool Complain) const; + /// \brief Looks up the modules that \p File corresponds to. + /// + /// If \p File represents a builtin header within Clang's builtin include + /// directory, this also loads all of the module maps to see if it will get + /// associated with a specific module (e.g. in /usr/include). + HeadersMap::iterator findKnownHeader(const FileEntry *File); + + /// \brief Searches for a module whose umbrella directory contains \p File. + /// + /// \param File The header to search for. + /// + /// \param IntermediateDirs On success, contains the set of directories + /// searched before finding \p File. + KnownHeader findHeaderInUmbrellaDirs(const FileEntry *File, + SmallVectorImpl<const DirectoryEntry *> &IntermediateDirs); + + /// \brief A convenience method to determine if \p File is (possibly nested) + /// in an umbrella directory. + bool isHeaderInUmbrellaDirs(const FileEntry *File) { + SmallVector<const DirectoryEntry *, 2> IntermediateDirs; + return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs)); + } + public: /// \brief Construct a new module map. /// @@ -182,13 +211,12 @@ public: /// This source manager should be shared with the header-search mechanism, /// since they will refer to the same headers. /// - /// \param DC A diagnostic consumer that will be cloned for use in generating - /// diagnostics. + /// \param Diags A diagnostic engine used for diagnostics. /// /// \param LangOpts Language options for this translation unit. /// /// \param Target The target for this translation unit. - ModuleMap(SourceManager &SourceMgr, DiagnosticConsumer &DC, + ModuleMap(SourceManager &SourceMgr, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const TargetInfo *Target, HeaderSearch &HeaderInfo); @@ -217,12 +245,30 @@ public: /// given header file. The KnownHeader is default constructed to indicate /// that no module owns this header file. KnownHeader findModuleForHeader(const FileEntry *File, - Module *RequestingModule = NULL); + Module *RequestingModule = nullptr); + + /// \brief Reports errors if a module must not include a specific file. + /// + /// \param RequestingModule The module including a file. + /// + /// \param FilenameLoc The location of the inclusion's filename. + /// + /// \param Filename The included filename as written. + /// + /// \param File The included file. + void diagnoseHeaderInclusion(Module *RequestingModule, + SourceLocation FilenameLoc, StringRef Filename, + const FileEntry *File); /// \brief Determine whether the given header is part of a module /// marked 'unavailable'. bool isHeaderInUnavailableModule(const FileEntry *Header) const; + /// \brief Determine whether the given header is unavailable as part + /// of the specified module. + bool isHeaderUnavailableInModule(const FileEntry *Header, + const Module *RequestingModule) const; + /// \brief Retrieve a module with the given name. /// /// \param Name The name of the module to look up. @@ -260,13 +306,17 @@ public: /// \param Parent The module that will act as the parent of this submodule, /// or NULL to indicate that this is a top-level module. /// + /// \param ModuleMap The module map that defines or allows the inference of + /// this module. + /// /// \param IsFramework Whether this is a framework module. /// /// \param IsExplicit Whether this is an explicit submodule. /// /// \returns The found or newly-created module, along with a boolean value /// that will be true if the module is newly-created. - std::pair<Module *, bool> findOrCreateModule(StringRef Name, Module *Parent, + std::pair<Module *, bool> findOrCreateModule(StringRef Name, Module *Parent, + const FileEntry *ModuleMap, bool IsFramework, bool IsExplicit); |