diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-11-29 21:59:16 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-11-29 21:59:16 +0000 |
commit | 18ee547b6926cacefa15eed8ca60ff73d22e279b (patch) | |
tree | cf56b8b78c3291b7e14e031ff20ad0e9714a1ca0 /lib/Lex/ModuleMap.cpp | |
parent | 214323b78b01ef9c1ad226f0eb5bd1187f3efa70 (diff) |
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
Diffstat (limited to 'lib/Lex/ModuleMap.cpp')
-rw-r--r-- | lib/Lex/ModuleMap.cpp | 54 |
1 files changed, 32 insertions, 22 deletions
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. |