diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-11-06 19:39:40 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-11-06 19:39:40 +0000 |
commit | 82e52377bd76ed71e8c09edc5f2f452e388b16ad (patch) | |
tree | d948502e6bf97f1cbc452f410e5cdea4d53797bf /include | |
parent | f64231e9f47234826fbcdc3b4fe0370ef6c9961d (diff) |
Introduce inferred framework modules into the module map file,
allowing a module map to be placed one level above the '.framework'
directories to specify that all .frameworks within that directory can
be inferred as framework modules. One can also specifically exclude
frameworks known not to work.
This makes explicit (and more restricted) behavior modules have had
"forever", where *any* .framework was assumed to be able to be built
as a module. That's not necessarily true, so we white-list directories
(with exclusions) when those directories have been audited.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167482 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Basic/DiagnosticLexKinds.td | 12 | ||||
-rw-r--r-- | include/clang/Lex/ModuleMap.h | 39 |
2 files changed, 46 insertions, 5 deletions
diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 77db0a3290..16b1fad770 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -491,15 +491,21 @@ def err_mmap_missing_module_unqualified : Error< def err_mmap_missing_module_qualified : Error< "no module named '%0' in '%1'">; def err_mmap_top_level_inferred_submodule : Error< - "only submodules may be inferred with wildcard syntax">; + "only submodules and framework modules may be inferred with wildcard syntax">; def err_mmap_inferred_no_umbrella : Error< "inferred submodules require a module with an umbrella">; +def err_mmap_inferred_framework_submodule : Error< + "inferred submodule cannot be a framework submodule">; +def err_mmap_explicit_inferred_framework : Error< + "inferred framework modules cannot be 'explicit'">; +def err_mmap_missing_exclude_name : Error< + "expected excluded module name">; def err_mmap_inferred_redef : Error< "redefinition of inferred submodule">; def err_mmap_expected_lbrace_wildcard : Error< "expected '{' to start inferred submodule">; -def err_mmap_expected_wildcard_member : Error< - "expected module export wildcard">; +def err_mmap_expected_inferred_member : Error< + "expected %select{module exclusion with 'exclude'|'export *'}0">; def err_mmap_expected_export_wildcard : Error< "only '*' can be exported from an inferred submodule">; def err_mmap_explicit_top_level : Error< diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h index dc9670f953..082408d83c 100644 --- a/include/clang/Lex/ModuleMap.h +++ b/include/clang/Lex/ModuleMap.h @@ -91,7 +91,26 @@ class ModuleMap { /// in the module map over to the module that includes them via its umbrella /// header. llvm::DenseMap<const DirectoryEntry *, Module *> UmbrellaDirs; - + + /// \brief A directory for which framework modules can be inferred. + struct InferredDirectory { + InferredDirectory() : InferModules(), InferSystemModules() { } + + /// \brief Whether to infer modules from this directory. + unsigned InferModules : 1; + + /// \brief Whether the modules we infer are [system] modules. + unsigned InferSystemModules : 1; + + /// \brief The names of modules that cannot be inferred within this + /// directory. + llvm::SmallVector<std::string, 2> ExcludedModules; + }; + + /// \brief A mapping from directories to information about inferring + /// framework modules from within those directories. + llvm::DenseMap<const DirectoryEntry *, InferredDirectory> InferredDirectories; + friend class ModuleMapParser; /// \brief Resolve the given export declaration into an actual export @@ -197,7 +216,23 @@ public: std::pair<Module *, bool> findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit); - + + /// \brief Determine whether we can infer a framework module a framework + /// with the given name in the given + /// + /// \param ParentDir The directory that is the parent of the framework + /// directory. + /// + /// \param Name The name of the module. + /// + /// \param IsSystem Will be set to 'true' if the inferred module must be a + /// system module. + /// + /// \returns true if we are allowed to infer a framework module, and false + /// otherwise. + bool canInferFrameworkModule(const DirectoryEntry *ParentDir, + StringRef Name, bool &IsSystem); + /// \brief Infer the contents of a framework module map from the given /// framework directory. Module *inferFrameworkModule(StringRef ModuleName, |