]> granicus.if.org Git - clang/commitdiff
When generating includes for all of the headers we found in an
authorDouglas Gregor <dgregor@apple.com>
Thu, 5 Jan 2012 00:04:05 +0000 (00:04 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 5 Jan 2012 00:04:05 +0000 (00:04 +0000)
umbrella directory, skip includes for any headers that are part of an
unavailable module.

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

lib/Frontend/FrontendActions.cpp
test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h [new file with mode: 0644]
test/Modules/Inputs/NoUmbrella.framework/module.map

index d9a385d232e3d47f7c3347cf2ad651a569dcca6c..2261b30712814d13617a2ea31593b782b5bf5d41 100644 (file)
@@ -134,6 +134,8 @@ ASTConsumer *GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
 /// \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 @@ static void collectModuleHeaderIncludes(const LangOptions &LangOpts,
       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 @@ static void collectModuleHeaderIncludes(const LangOptions &LangOpts,
           .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 @@ static void collectModuleHeaderIncludes(const LangOptions &LangOpts,
   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 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI,
   
   // 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.
diff --git a/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h b/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h
new file mode 100644 (file)
index 0000000..ac4a14a
--- /dev/null
@@ -0,0 +1 @@
+this is gibberish
index 944150146fad1d958944cdcb4983f9d63c873c11..986cca995c10d0db57d4e5b61e0b5c0bf82f63b3 100644 (file)
@@ -1,4 +1,9 @@
 framework module NoUmbrella {
   umbrella "Headers"
   module * { }
-}
\ No newline at end of file
+
+  module unavailable {
+    requires unavailable
+    header "Boom.h"
+  }
+}