diff options
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 9ac554a..c5e317a 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -19,6 +19,7 @@ #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" @@ -648,7 +649,7 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName, bool IsFrameworkDir = Parent.endswith(".framework"); if (const FileEntry *ModMapFile = HeaderInfo.lookupModuleMapFile(ParentDir, IsFrameworkDir)) { - parseModuleMapFile(ModMapFile, IsSystem); + parseModuleMapFile(ModMapFile, IsSystem, ParentDir); inferred = InferredDirectories.find(ParentDir); } @@ -1024,7 +1025,8 @@ namespace clang { /// \brief The current module map file. const FileEntry *ModuleMapFile; - /// \brief The directory that this module map resides in. + /// \brief The directory that file names in this module map file should + /// be resolved relative to. const DirectoryEntry *Directory; /// \brief The directory containing Clang-supplied headers. @@ -1591,7 +1593,11 @@ void ModuleMapParser::parseExternModuleDecl() { FileNameRef = ModuleMapFileName.str(); } if (const FileEntry *File = SourceMgr.getFileManager().getFile(FileNameRef)) - Map.parseModuleMapFile(File, /*IsSystem=*/false); + Map.parseModuleMapFile( + File, /*IsSystem=*/false, + Map.HeaderInfo.getHeaderSearchOpts().ModuleMapFileHomeIsCwd + ? Directory + : File->getDir()); } /// \brief Parse a requires declaration. @@ -2333,7 +2339,8 @@ bool ModuleMapParser::parseModuleMapFile() { } while (true); } -bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem) { +bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem, + const DirectoryEntry *Dir) { llvm::DenseMap<const FileEntry *, bool>::iterator Known = ParsedModuleMap.find(File); if (Known != ParsedModuleMap.end()) @@ -2346,17 +2353,6 @@ 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, |