[cfe-commits] r146159 - in /cfe/trunk: lib/Basic/Module.cpp lib/Lex/ModuleMap.cpp test/Modules/Inputs/DependsOnModule.framework/module.map test/Modules/Inputs/normal-module-map/Umbrella/module.map test/Modules/Inputs/normal-module-map/Umbrella2/module.map
Douglas Gregor
dgregor at apple.com
Thu Dec 8 10:00:48 PST 2011
Author: dgregor
Date: Thu Dec 8 12:00:48 2011
New Revision: 146159
URL: http://llvm.org/viewvc/llvm-project?rev=146159&view=rev
Log:
Tweak the syntax of umbrella headers, so that "umbrella" is treated as
a modifier for a header declarartion, e.g.,
umbrella header "headername"
Collapse the umbrella-handling code in the parser into the
header-handling code, so we don't duplicate the header-search logic.
Modified:
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map
cfe/trunk/test/Modules/Inputs/normal-module-map/Umbrella/module.map
cfe/trunk/test/Modules/Inputs/normal-module-map/Umbrella2/module.map
Modified: cfe/trunk/lib/Basic/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=146159&r1=146158&r2=146159&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Thu Dec 8 12:00:48 2011
@@ -90,9 +90,14 @@
if (const FileEntry *UmbrellaHeader = getUmbrellaHeader()) {
OS.indent(Indent + 2);
- OS << "umbrella \"";
+ OS << "umbrella header \"";
OS.write_escaped(UmbrellaHeader->getName());
OS << "\"\n";
+ } else if (const DirectoryEntry *UmbrellaDir = getUmbrellaDir()) {
+ OS.indent(Indent + 2);
+ OS << "umbrella \"";
+ OS.write_escaped(UmbrellaDir->getName());
+ OS << "\"\n";
}
for (unsigned I = 0, N = Headers.size(); I != N; ++I) {
Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=146159&r1=146158&r2=146159&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Thu Dec 8 12:00:48 2011
@@ -259,7 +259,7 @@
else
Modules[ModuleName] = Result;
- // umbrella "umbrella-header-name"
+ // umbrella header "umbrella-header-name"
Result->Umbrella = UmbrellaHeader;
Headers[UmbrellaHeader] = Result;
UmbrellaDirs[FrameworkDir] = Result;
@@ -493,8 +493,7 @@
ModuleId;
bool parseModuleId(ModuleId &Id);
void parseModuleDecl();
- void parseUmbrellaDecl();
- void parseHeaderDecl();
+ void parseHeaderDecl(SourceLocation UmbrellaLoc);
void parseExportDecl();
void parseInferredSubmoduleDecl(bool Explicit);
@@ -656,7 +655,6 @@
/// 'explicit'[opt] 'framework'[opt] 'module' module-id { module-member* }
///
/// module-member:
-/// umbrella-declaration
/// header-declaration
/// submodule-declaration
/// export-declaration
@@ -798,14 +796,14 @@
parseExportDecl();
break;
- case MMToken::HeaderKeyword:
- parseHeaderDecl();
+ case MMToken::UmbrellaKeyword:
+ parseHeaderDecl(consumeToken());
break;
- case MMToken::UmbrellaKeyword:
- parseUmbrellaDecl();
+ case MMToken::HeaderKeyword:
+ parseHeaderDecl(SourceLocation());
break;
-
+
default:
Diags.Report(Tok.getLocation(), diag::err_mmap_expected_member);
consumeToken();
@@ -845,115 +843,35 @@
}
}
-/// \brief Parse an umbrella header declaration.
+/// \brief Parse a header declaration.
///
-/// umbrella-declaration:
-/// 'umbrella' string-literal
-void ModuleMapParser::parseUmbrellaDecl() {
- assert(Tok.is(MMToken::UmbrellaKeyword));
- SourceLocation UmbrellaLoc = consumeToken();
+/// header-declaration:
+/// 'umbrella'[opt] 'header' string-literal
+void ModuleMapParser::parseHeaderDecl(SourceLocation UmbrellaLoc) {
+ assert(Tok.is(MMToken::HeaderKeyword));
+ consumeToken();
+
+ bool Umbrella = UmbrellaLoc.isValid();
// Parse the header name.
if (!Tok.is(MMToken::StringLiteral)) {
Diags.Report(Tok.getLocation(), diag::err_mmap_expected_header)
- << "umbrella";
+ << "header";
HadError = true;
return;
}
std::string FileName = Tok.getString();
SourceLocation FileNameLoc = consumeToken();
-
+
// Check whether we already have an umbrella header.
- if (ActiveModule->getUmbrellaHeader()) {
+ if (Umbrella && ActiveModule->getUmbrellaHeader()) {
Diags.Report(FileNameLoc, diag::err_mmap_umbrella_header_conflict)
<< ActiveModule->getFullModuleName()
<< ActiveModule->getUmbrellaHeader()->getName();
HadError = true;
return;
}
-
- // Look for this file.
- llvm::SmallString<128> PathName;
- const FileEntry *File = 0;
-
- 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()) {
- appendSubframeworkPaths(ActiveModule, PathName);
-
- // 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");
- llvm::sys::path::append(PathName, FileName);
- File = SourceMgr.getFileManager().getFile(PathName);
- }
- } 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.
- // Come up with a lazy way to do this.
- if (File) {
- const DirectoryEntry *UmbrellaDir = File->getDir();
- if (ActiveModule->IsFramework) {
- // For framework modules, use the framework directory as the umbrella
- // directory.
- UmbrellaDir = SourceMgr.getFileManager().getDirectory(
- llvm::sys::path::parent_path(UmbrellaDir->getName()));
- }
-
- if (const Module *OwningModule = Map.Headers[File]) {
- Diags.Report(FileNameLoc, diag::err_mmap_header_conflict)
- << FileName << OwningModule->getFullModuleName();
- HadError = true;
- } else if ((OwningModule = Map.UmbrellaDirs[UmbrellaDir])) {
- Diags.Report(UmbrellaLoc, diag::err_mmap_umbrella_clash)
- << OwningModule->getFullModuleName();
- HadError = true;
- } else {
- // Record this umbrella header.
- Map.setUmbrellaHeader(ActiveModule, File);
- }
- } else {
- Diags.Report(FileNameLoc, diag::err_mmap_header_not_found)
- << true << FileName;
- HadError = true;
- }
-}
-
-/// \brief Parse a header declaration.
-///
-/// header-declaration:
-/// 'header' string-literal
-void ModuleMapParser::parseHeaderDecl() {
- assert(Tok.is(MMToken::HeaderKeyword));
- consumeToken();
-
- // Parse the header name.
- if (!Tok.is(MMToken::StringLiteral)) {
- Diags.Report(Tok.getLocation(), diag::err_mmap_expected_header)
- << "header";
- HadError = true;
- return;
- }
- std::string FileName = Tok.getString();
- SourceLocation FileNameLoc = consumeToken();
-
// Look for this file.
const FileEntry *File = 0;
llvm::SmallString<128> PathName;
@@ -994,8 +912,25 @@
Diags.Report(FileNameLoc, diag::err_mmap_header_conflict)
<< FileName << OwningModule->getFullModuleName();
HadError = true;
+ } else if (Umbrella) {
+ const DirectoryEntry *UmbrellaDir = File->getDir();
+ if (ActiveModule->IsFramework) {
+ // For framework modules, use the framework directory as the umbrella
+ // directory.
+ UmbrellaDir = SourceMgr.getFileManager().getDirectory(
+ llvm::sys::path::parent_path(UmbrellaDir->getName()));
+ }
+
+ if ((OwningModule = Map.UmbrellaDirs[UmbrellaDir])) {
+ Diags.Report(UmbrellaLoc, diag::err_mmap_umbrella_clash)
+ << OwningModule->getFullModuleName();
+ HadError = true;
+ } else {
+ // Record this umbrella header.
+ Map.setUmbrellaHeader(ActiveModule, File);
+ }
} else {
- // Record this file.
+ // Record this header.
Map.addHeader(ActiveModule, File);
}
} else {
Modified: cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map?rev=146159&r1=146158&r2=146159&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map Thu Dec 8 12:00:48 2011
@@ -1,11 +1,11 @@
framework module DependsOnModule {
- umbrella "DependsOnModule.h"
+ umbrella header "DependsOnModule.h"
header "other.h"
module * {
export *
}
explicit framework module SubFramework {
- umbrella "SubFramework.h"
+ umbrella header "SubFramework.h"
module * {
export *
Modified: cfe/trunk/test/Modules/Inputs/normal-module-map/Umbrella/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/normal-module-map/Umbrella/module.map?rev=146159&r1=146158&r2=146159&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/normal-module-map/Umbrella/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/normal-module-map/Umbrella/module.map Thu Dec 8 12:00:48 2011
@@ -1,3 +1,3 @@
module Umbrella {
- umbrella "Umbrella.h"
+ umbrella header "Umbrella.h"
}
\ No newline at end of file
Modified: cfe/trunk/test/Modules/Inputs/normal-module-map/Umbrella2/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/normal-module-map/Umbrella2/module.map?rev=146159&r1=146158&r2=146159&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/normal-module-map/Umbrella2/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/normal-module-map/Umbrella2/module.map Thu Dec 8 12:00:48 2011
@@ -1,3 +1,3 @@
module Umbrella2 {
- umbrella "Umbrella2.h"
-}
\ No newline at end of file
+ umbrella header "Umbrella2.h"
+}
More information about the cfe-commits
mailing list