From 18ee547b6926cacefa15eed8ca60ff73d22e279b Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 29 Nov 2011 21:59:16 +0000 Subject: Switch on-demand module building over to use module maps, always. When we infer the module map, we'll just print the module map to a temporary file and generate the module using that. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145436 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/ModuleMap.cpp | 54 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'lib/Lex/ModuleMap.cpp') diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp index 3cc6478acf..60c797c362 100644 --- a/lib/Lex/ModuleMap.cpp +++ b/lib/Lex/ModuleMap.cpp @@ -69,7 +69,7 @@ StringRef ModuleMap::Module::getTopLevelModuleName() const { } static void indent(llvm::raw_ostream &OS, unsigned Spaces) { - OS << std::string(' ', Spaces); + OS << std::string(Spaces, ' '); } void ModuleMap::Module::print(llvm::raw_ostream &OS, unsigned Indent) const { @@ -78,7 +78,7 @@ void ModuleMap::Module::print(llvm::raw_ostream &OS, unsigned Indent) const { OS << "framework "; if (IsExplicit) OS << "explicit "; - OS << Name << " {\n"; + OS << "module " << Name << " {\n"; if (UmbrellaHeader) { indent(OS, Indent + 2); @@ -586,28 +586,35 @@ void ModuleMapParser::parseUmbrellaDecl() { // Look for this file. llvm::SmallString<128> PathName; - PathName += Directory->getName(); - unsigned PathLength = PathName.size(); const FileEntry *File = 0; - if (ActiveModule->isPartOfFramework()) { - // Check whether this file is in the public headers. - llvm::sys::path::append(PathName, "Headers"); - llvm::sys::path::append(PathName, FileName); + + if (llvm::sys::path::is_absolute(FileName)) { + PathName = FileName; File = SourceMgr.getFileManager().getFile(PathName); + } else { + // Search for the header file within the search directory. + PathName += Directory->getName(); + unsigned PathLength = PathName.size(); + if (ActiveModule->isPartOfFramework()) { + // Check whether this file is in the public headers. + llvm::sys::path::append(PathName, "Headers"); + llvm::sys::path::append(PathName, FileName); + File = SourceMgr.getFileManager().getFile(PathName); - if (!File) { - // Check whether this file is in the private headers. - PathName.resize(PathLength); - llvm::sys::path::append(PathName, "PrivateHeaders"); + if (!File) { + // Check whether this file is in the private headers. + PathName.resize(PathLength); + llvm::sys::path::append(PathName, "PrivateHeaders"); + llvm::sys::path::append(PathName, FileName); + File = SourceMgr.getFileManager().getFile(PathName); + } + + // FIXME: Deal with subframeworks. + } else { + // Lookup for normal headers. llvm::sys::path::append(PathName, FileName); File = SourceMgr.getFileManager().getFile(PathName); } - - // FIXME: Deal with subframeworks. - } else { - // Lookup for normal headers. - llvm::sys::path::append(PathName, FileName); - File = SourceMgr.getFileManager().getFile(PathName); } // FIXME: We shouldn't be eagerly stat'ing every file named in a module map. @@ -654,11 +661,14 @@ void ModuleMapParser::parseHeaderDecl() { // Look for this file. llvm::SmallString<128> PathName; - PathName += Directory->getName(); + if (llvm::sys::path::is_relative(FileName)) { + // FIXME: Change this search to also look for private headers! + PathName += Directory->getName(); + + if (ActiveModule->isPartOfFramework()) + llvm::sys::path::append(PathName, "Headers"); + } - if (ActiveModule->isPartOfFramework()) - llvm::sys::path::append(PathName, "Headers"); - llvm::sys::path::append(PathName, FileName); // FIXME: We shouldn't be eagerly stat'ing every file named in a module map. -- cgit v1.2.3-18-g5258