]> granicus.if.org Git - clang/commitdiff
When building the main file to parse given a module map, don't skip
authorDouglas Gregor <dgregor@apple.com>
Tue, 6 Dec 2011 17:15:11 +0000 (17:15 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 6 Dec 2011 17:15:11 +0000 (17:15 +0000)
explicit submodules or umbrella headers from submodules. Instead,
build the entire module at once, and let the name-hiding mechanisms
hide the contents of explicit submodules at load time.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145940 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/FrontendActions.cpp
test/Modules/auto-module-import.c

index 5c4e447ef5fd2d63f452f89c2e6baeb9e4228bba..1a2df01bdfd551d47a12d1aad9d1d47337c822ec 100644 (file)
@@ -129,32 +129,38 @@ ASTConsumer *GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
 /// module.
 ///
 /// \param Module The module we're collecting includes from.
-/// \param ExplicitOnly Whether we should only add headers from explicit 
+///
+/// \param Includes Will be augmented with the set of #includes or #imports
+/// needed to load all of the named headers.
 static void collectModuleHeaderIncludes(const LangOptions &LangOpts,
                                         clang::Module *Module,
-                                        bool ExplicitOnly,
                                         llvm::SmallString<256> &Includes) {
-  if (!ExplicitOnly || Module->IsExplicit) {
-    // Add includes for each of these headers.
-    for (unsigned I = 0, N = Module->Headers.size(); I != N; ++I) {
-      if (LangOpts.ObjC1)
-        Includes += "#import \"";
-      else
-        Includes += "#include \"";
-      Includes += Module->Headers[I]->getName();
-      Includes += "\"\n";
-    }
+  // Add includes for each of these headers.
+  for (unsigned I = 0, N = Module->Headers.size(); I != N; ++I) {
+    if (LangOpts.ObjC1)
+      Includes += "#import \"";
+    else
+      Includes += "#include \"";
+    Includes += Module->Headers[I]->getName();
+    Includes += "\"\n";
+  }
+
+  if (Module->UmbrellaHeader && Module->Parent) {
+    // Include the umbrella header for submodules.
+    if (LangOpts.ObjC1)
+      Includes += "#import \"";
+    else
+      Includes += "#include \"";
+    Includes += Module->UmbrellaHeader->getName();
+    Includes += "\"\n";    
   }
   
   // Recurse into submodules.
   for (llvm::StringMap<clang::Module *>::iterator
             Sub = Module->SubModules.begin(),
          SubEnd = Module->SubModules.end();
-       Sub != SubEnd; ++Sub) {
-    collectModuleHeaderIncludes(LangOpts, Sub->getValue(), 
-                                ExplicitOnly && !Module->IsExplicit,
-                                Includes);
-  }
+       Sub != SubEnd; ++Sub)
+    collectModuleHeaderIncludes(LangOpts, Sub->getValue(), Includes);
 }
 
 bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI, 
@@ -193,8 +199,7 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI,
   
   // Collect the set of #includes we need to build the module.
   llvm::SmallString<256> HeaderContents;
-  collectModuleHeaderIncludes(CI.getLangOpts(), Module, 
-                              Module->UmbrellaHeader != 0, HeaderContents);
+  collectModuleHeaderIncludes(CI.getLangOpts(), Module, HeaderContents);
   if (Module->UmbrellaHeader && HeaderContents.empty()) {
     // Simple case: we have an umbrella header and there are no additional
     // includes, we can just parse the umbrella header directly.
index cebfbc6d29f6f69514b8235ae5cdcb333e11d066..51e9ee2d03504cb785a2adfe2a0a03a1cfb0bba9 100644 (file)
@@ -17,3 +17,4 @@ Module *mod; // expected-error{{unknown type name 'Module'}}
 #import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-warning{{treating #import as an import of module 'AlsoDependsOnModule'}}
 Module *mod2;
 
+int getDependsOther() { return depends_on_module_other; }