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 /lib/Lex/HeaderSearch.cpp | |
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 'lib/Lex/HeaderSearch.cpp')
-rw-r--r-- | lib/Lex/HeaderSearch.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index 935b5ea547..67000b6829 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -939,7 +939,33 @@ Module *HeaderSearch::loadFrameworkModule(StringRef Name, TopFrameworkDir = Dir; } } while (true); - + + // Determine whether we're allowed to infer a module map. + bool canInfer = false; + if (llvm::sys::path::has_parent_path(TopFrameworkDir->getName())) { + // Figure out the parent path. + StringRef Parent = llvm::sys::path::parent_path(TopFrameworkDir->getName()); + if (const DirectoryEntry *ParentDir = FileMgr.getDirectory(Parent)) { + // If there's a module map file in the parent directory, it can + // explicitly allow us to infer framework modules. + switch (loadModuleMapFile(ParentDir)) { + case LMM_AlreadyLoaded: + case LMM_NewlyLoaded: { + StringRef Name = llvm::sys::path::stem(TopFrameworkDir->getName()); + canInfer = ModMap.canInferFrameworkModule(ParentDir, Name, IsSystem); + break; + } + case LMM_InvalidModuleMap: + case LMM_NoDirectory: + break; + } + } + } + + // If we're not allowed to infer a module map, we're done. + if (!canInfer) + return 0; + // Try to infer a module map from the top-level framework directory. Module *Result = ModMap.inferFrameworkModule(SubmodulePath.back(), TopFrameworkDir, |