From 984e1df77a9e7e22629fc3820dec761dabd3339e Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Wed, 19 Mar 2014 20:23:34 +0000 Subject: Add a new spelling for module map files 'module.modulemap' This name, while more verbose, plays more nicely with tools that use file extensions to determine file types. The existing spelling 'module.map' will continue to work, but the new spelling will take precedence. In frameworks, this new filename will only go in a new 'Modules' sub-directory. Similarly, add a module.private.modulemap corresponding to module_private.map. llvm-svn: 204261 --- clang/lib/Lex/ModuleMap.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'clang/lib/Lex/ModuleMap.cpp') diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index d5e8af95fe6..e78806dc50b 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -594,9 +594,9 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName, if (inferred == InferredDirectories.end()) { // We haven't looked here before. Load a module map, if there is // one. - SmallString<128> ModMapPath = Parent; - llvm::sys::path::append(ModMapPath, "module.map"); - if (const FileEntry *ModMapFile = FileMgr.getFile(ModMapPath)) { + bool IsFrameworkDir = Parent.endswith(".framework"); + if (const FileEntry *ModMapFile = + HeaderInfo.lookupModuleMapFile(ParentDir, IsFrameworkDir)) { parseModuleMapFile(ModMapFile, IsSystem); inferred = InferredDirectories.find(ParentDir); } @@ -2219,10 +2219,21 @@ bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem) { const llvm::MemoryBuffer *Buffer = SourceMgr.getBuffer(ID); 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->getDir(), + ModuleMapParser Parser(L, SourceMgr, Target, Diags, *this, Dir, BuiltinIncludeDir, IsSystem); bool Result = Parser.parseModuleMapFile(); ParsedModuleMap[File] = Result; -- cgit v1.2.3