diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-12-09 06:35:37 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-12-09 06:35:37 +0000 |
| commit | 00a4da73d5e3c59e5130d0213bbbfa907ba2f56b (patch) | |
| tree | a136aa7a1fa7bcd74ecc845d76b5d49018335539 /clang/lib/Lex | |
| parent | e38c32ffec40af106cddd95cec87355ce41129f6 (diff) | |
| download | bcm5719-llvm-00a4da73d5e3c59e5130d0213bbbfa907ba2f56b.tar.gz bcm5719-llvm-00a4da73d5e3c59e5130d0213bbbfa907ba2f56b.zip | |
Revert "[modules] Add experimental -fmodule-map-file-home-is-cwd flag to -cc1."
This reverts commit r223753. It broke the Green Dragon build for a few
hours:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/2259/
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/2259/consoleFull#43901905849ba4694-19c4-4d7e-bec5-911270d8a58c
I suspect `clang-tools-extra` just needs a follow-up for an API change,
but I'm not the right one to look into it.
llvm-svn: 223759
Diffstat (limited to 'clang/lib/Lex')
| -rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 40 | ||||
| -rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 26 |
2 files changed, 26 insertions, 40 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 02fd87c8226..a3f3737521e 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -1113,10 +1113,11 @@ HeaderSearch::findModuleForHeader(const FileEntry *File) const { return ModMap.findModuleForHeader(File); } -static const FileEntry *getPrivateModuleMap(const FileEntry *File, +static const FileEntry *getPrivateModuleMap(StringRef ModuleMapPath, + const DirectoryEntry *Directory, FileManager &FileMgr) { - StringRef Filename = llvm::sys::path::filename(File->getName()); - SmallString<128> PrivateFilename(File->getDir()->getName()); + StringRef Filename = llvm::sys::path::filename(ModuleMapPath); + SmallString<128> PrivateFilename(Directory->getName()); if (Filename == "module.map") llvm::sys::path::append(PrivateFilename, "module_private.map"); else if (Filename == "module.modulemap") @@ -1127,25 +1128,7 @@ static const FileEntry *getPrivateModuleMap(const FileEntry *File, } bool HeaderSearch::loadModuleMapFile(const FileEntry *File, bool IsSystem) { - // Find the directory for the module. For frameworks, that may require going - // up from the 'Modules' directory. - const DirectoryEntry *Dir = nullptr; - if (getHeaderSearchOpts().ModuleMapFileHomeIsCwd) - Dir = FileMgr.getDirectory("."); - else { - Dir = File->getDir(); - StringRef DirName(Dir->getName()); - if (llvm::sys::path::filename(DirName) == "Modules") { - DirName = llvm::sys::path::parent_path(DirName); - if (DirName.endswith(".framework")) - Dir = FileMgr.getDirectory(DirName); - // FIXME: This assert can fail if there's a race between the above check - // and the removal of the directory. - assert(Dir && "parent must exist"); - } - } - - switch (loadModuleMapFileImpl(File, IsSystem, Dir)) { + switch (loadModuleMapFileImpl(File, IsSystem)) { case LMM_AlreadyLoaded: case LMM_NewlyLoaded: return false; @@ -1157,8 +1140,7 @@ bool HeaderSearch::loadModuleMapFile(const FileEntry *File, bool IsSystem) { } HeaderSearch::LoadModuleMapResult -HeaderSearch::loadModuleMapFileImpl(const FileEntry *File, bool IsSystem, - const DirectoryEntry *Dir) { +HeaderSearch::loadModuleMapFileImpl(const FileEntry *File, bool IsSystem) { assert(File && "expected FileEntry"); // Check whether we've already loaded this module map, and mark it as being @@ -1167,14 +1149,15 @@ HeaderSearch::loadModuleMapFileImpl(const FileEntry *File, bool IsSystem, if (!AddResult.second) return AddResult.first->second ? LMM_AlreadyLoaded : LMM_InvalidModuleMap; - if (ModMap.parseModuleMapFile(File, IsSystem, Dir)) { + if (ModMap.parseModuleMapFile(File, IsSystem)) { LoadedModuleMaps[File] = false; return LMM_InvalidModuleMap; } // Try to load a corresponding private module map. - if (const FileEntry *PMMFile = getPrivateModuleMap(File, FileMgr)) { - if (ModMap.parseModuleMapFile(PMMFile, IsSystem, Dir)) { + if (const FileEntry *PMMFile = + getPrivateModuleMap(File->getName(), File->getDir(), FileMgr)) { + if (ModMap.parseModuleMapFile(PMMFile, IsSystem)) { LoadedModuleMaps[File] = false; return LMM_InvalidModuleMap; } @@ -1248,8 +1231,7 @@ HeaderSearch::loadModuleMapFile(const DirectoryEntry *Dir, bool IsSystem, return KnownDir->second ? LMM_AlreadyLoaded : LMM_InvalidModuleMap; if (const FileEntry *ModuleMapFile = lookupModuleMapFile(Dir, IsFramework)) { - LoadModuleMapResult Result = - loadModuleMapFileImpl(ModuleMapFile, IsSystem, Dir); + LoadModuleMapResult Result = loadModuleMapFileImpl(ModuleMapFile, IsSystem); // Add Dir explicitly in case ModuleMapFile is in a subdirectory. // E.g. Foo.framework/Modules/module.modulemap // ^Dir ^ModuleMapFile diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index c5e317a0ba6..9ac554ae96c 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -19,7 +19,6 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetOptions.h" #include "clang/Lex/HeaderSearch.h" -#include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/LexDiagnostic.h" #include "clang/Lex/Lexer.h" #include "clang/Lex/LiteralSupport.h" @@ -649,7 +648,7 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName, bool IsFrameworkDir = Parent.endswith(".framework"); if (const FileEntry *ModMapFile = HeaderInfo.lookupModuleMapFile(ParentDir, IsFrameworkDir)) { - parseModuleMapFile(ModMapFile, IsSystem, ParentDir); + parseModuleMapFile(ModMapFile, IsSystem); inferred = InferredDirectories.find(ParentDir); } @@ -1025,8 +1024,7 @@ namespace clang { /// \brief The current module map file. const FileEntry *ModuleMapFile; - /// \brief The directory that file names in this module map file should - /// be resolved relative to. + /// \brief The directory that this module map resides in. const DirectoryEntry *Directory; /// \brief The directory containing Clang-supplied headers. @@ -1593,11 +1591,7 @@ void ModuleMapParser::parseExternModuleDecl() { FileNameRef = ModuleMapFileName.str(); } if (const FileEntry *File = SourceMgr.getFileManager().getFile(FileNameRef)) - Map.parseModuleMapFile( - File, /*IsSystem=*/false, - Map.HeaderInfo.getHeaderSearchOpts().ModuleMapFileHomeIsCwd - ? Directory - : File->getDir()); + Map.parseModuleMapFile(File, /*IsSystem=*/false); } /// \brief Parse a requires declaration. @@ -2339,8 +2333,7 @@ bool ModuleMapParser::parseModuleMapFile() { } while (true); } -bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem, - const DirectoryEntry *Dir) { +bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem) { llvm::DenseMap<const FileEntry *, bool>::iterator Known = ParsedModuleMap.find(File); if (Known != ParsedModuleMap.end()) @@ -2353,6 +2346,17 @@ bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem, if (!Buffer) return ParsedModuleMap[File] = true; + // Find the directory for the module. For frameworks, that may require going + // up from the 'Modules' directory. + const DirectoryEntry *Dir = File->getDir(); + StringRef DirName(Dir->getName()); + if (llvm::sys::path::filename(DirName) == "Modules") { + DirName = llvm::sys::path::parent_path(DirName); + if (DirName.endswith(".framework")) + Dir = SourceMgr.getFileManager().getDirectory(DirName); + assert(Dir && "parent must exist"); + } + // Parse this module map file. Lexer L(ID, SourceMgr.getBuffer(ID), SourceMgr, MMapLangOpts); ModuleMapParser Parser(L, SourceMgr, Target, Diags, *this, File, Dir, |

