diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-12-07 02:23:45 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-12-07 02:23:45 +0000 |
commit | e7ab36693b68215065f40d3624a9f92673fd277e (patch) | |
tree | 04a9cb09377c31e03c296c6ad5b50dd3b6219f46 /clang/lib/Lex/HeaderSearch.cpp | |
parent | 9c9e81085fdb7c56ea3cd49c0ef462289d5b2ce7 (diff) | |
download | bcm5719-llvm-e7ab36693b68215065f40d3624a9f92673fd277e.tar.gz bcm5719-llvm-e7ab36693b68215065f40d3624a9f92673fd277e.zip |
Implement basic support for private headers in frameworks. In essence,
when we load a module map (module.map) from a directory, also load a
private module map (module_private.map) for that directory, if
present. That private module map can inject a new submodule that
captures private headers.
llvm-svn: 146012
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 1b969b93bef..7035b9c45d9 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -870,15 +870,33 @@ HeaderSearch::loadModuleMapFile(const DirectoryEntry *Dir) { llvm::SmallString<128> ModuleMapFileName; ModuleMapFileName += Dir->getName(); + unsigned ModuleMapDirNameLen = ModuleMapFileName.size(); llvm::sys::path::append(ModuleMapFileName, "module.map"); if (const FileEntry *ModuleMapFile = FileMgr.getFile(ModuleMapFileName)) { // We have found a module map file. Try to parse it. - if (!ModMap.parseModuleMapFile(ModuleMapFile)) { - // This directory has a module map. - DirectoryHasModuleMap[Dir] = true; - - return LMM_NewlyLoaded; + if (ModMap.parseModuleMapFile(ModuleMapFile)) { + // No suitable module map. + DirectoryHasModuleMap[Dir] = false; + return LMM_InvalidModuleMap; } + + // This directory has a module map. + DirectoryHasModuleMap[Dir] = true; + + // Check whether there is a private module map that we need to load as well. + ModuleMapFileName.erase(ModuleMapFileName.begin() + ModuleMapDirNameLen, + ModuleMapFileName.end()); + llvm::sys::path::append(ModuleMapFileName, "module_private.map"); + if (const FileEntry *PrivateModuleMapFile + = FileMgr.getFile(ModuleMapFileName)) { + if (ModMap.parseModuleMapFile(PrivateModuleMapFile)) { + // No suitable module map. + DirectoryHasModuleMap[Dir] = false; + return LMM_InvalidModuleMap; + } + } + + return LMM_NewlyLoaded; } // No suitable module map. |