[cfe-commits] r147572 - in /cfe/trunk: lib/Frontend/FrontendActions.cpp test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h test/Modules/Inputs/NoUmbrella.framework/module.map

Douglas Gregor dgregor at apple.com
Wed Jan 4 16:04:06 PST 2012


Author: dgregor
Date: Wed Jan  4 18:04:05 2012
New Revision: 147572

URL: http://llvm.org/viewvc/llvm-project?rev=147572&view=rev
Log:
When generating includes for all of the headers we found in an
umbrella directory, skip includes for any headers that are part of an
unavailable module.

Added:
    cfe/trunk/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h
Modified:
    cfe/trunk/lib/Frontend/FrontendActions.cpp
    cfe/trunk/test/Modules/Inputs/NoUmbrella.framework/module.map

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=147572&r1=147571&r2=147572&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Wed Jan  4 18:04:05 2012
@@ -134,6 +134,8 @@
 /// \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,
+                                        FileManager &FileMgr,
+                                        ModuleMap &ModMap,
                                         clang::Module *Module,
                                         llvm::SmallString<256> &Includes) {
   // Don't collect any headers for unavailable modules.
@@ -161,7 +163,7 @@
       Includes += "\"\n";
     }
   } else if (const DirectoryEntry *UmbrellaDir = Module->getUmbrellaDir()) {
-    // Add all of the headers we find in this subdirectory (FIXME: recursively!).
+    // Add all of the headers we find in this subdirectory.
     llvm::error_code EC;
     llvm::SmallString<128> DirNative;
     llvm::sys::path::native(UmbrellaDir->getName(), DirNative);
@@ -175,6 +177,12 @@
           .Default(false))
         continue;
       
+      // If this header is marked 'unavailable' in this module, don't include 
+      // it.
+      if (const FileEntry *Header = FileMgr.getFile(Dir->path()))
+        if (ModMap.isHeaderInUnavailableModule(Header))
+          continue;
+      
       // Include this header umbrella header for submodules.
       if (LangOpts.ObjC1)
         Includes += "#import \"";
@@ -189,7 +197,7 @@
   for (clang::Module::submodule_iterator Sub = Module->submodule_begin(),
                                       SubEnd = Module->submodule_end();
        Sub != SubEnd; ++Sub)
-    collectModuleHeaderIncludes(LangOpts, *Sub, Includes);
+    collectModuleHeaderIncludes(LangOpts, FileMgr, ModMap, *Sub, Includes);
 }
 
 bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI, 
@@ -241,7 +249,9 @@
   
   // Collect the set of #includes we need to build the module.
   llvm::SmallString<256> HeaderContents;
-  collectModuleHeaderIncludes(CI.getLangOpts(), Module, HeaderContents);
+  collectModuleHeaderIncludes(CI.getLangOpts(), CI.getFileManager(),
+    CI.getPreprocessor().getHeaderSearchInfo().getModuleMap(),
+    Module, HeaderContents);
   if (UmbrellaHeader && HeaderContents.empty()) {
     // Simple case: we have an umbrella header and there are no additional
     // includes, we can just parse the umbrella header directly.

Added: cfe/trunk/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h?rev=147572&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h (added)
+++ cfe/trunk/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h Wed Jan  4 18:04:05 2012
@@ -0,0 +1 @@
+this is gibberish

Modified: cfe/trunk/test/Modules/Inputs/NoUmbrella.framework/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/NoUmbrella.framework/module.map?rev=147572&r1=147571&r2=147572&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/NoUmbrella.framework/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/NoUmbrella.framework/module.map Wed Jan  4 18:04:05 2012
@@ -1,4 +1,9 @@
 framework module NoUmbrella {
   umbrella "Headers"
   module * { }
-}
\ No newline at end of file
+
+  module unavailable {
+    requires unavailable
+    header "Boom.h"
+  }
+}





More information about the cfe-commits mailing list