]> granicus.if.org Git - clang/commitdiff
When forming the link options for an imported module, also include the
authorDouglas Gregor <dgregor@apple.com>
Mon, 14 Jan 2013 19:00:05 +0000 (19:00 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 14 Jan 2013 19:00:05 +0000 (19:00 +0000)
link options for the modules it imports.

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

lib/CodeGen/CodeGenModule.cpp
test/Modules/Inputs/DependsOnModule.framework/DependsOnModule [new file with mode: 0644]
test/Modules/autolink.m

index c43528866b024b78382177b74c0178e61318f970..4b662e0b8997cc4f8be121359752a92faad80680 100644 (file)
@@ -2822,8 +2822,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
         Metadata->addOperand(llvm::MDNode::get(getLLVMContext(), OptString));
       }
 
-      // We've imported this module; now import any of its children that haven't
-      // already been imported.
+      // Import this module's (non-explicit) submodules.
       for (clang::Module::submodule_iterator Sub = Mod->submodule_begin(),
                                           SubEnd = Mod->submodule_end();
            Sub != SubEnd; ++Sub) {
@@ -2833,6 +2832,12 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
         if (ImportedModules.insert(*Sub))
           Stack.push_back(*Sub);
       }
+
+      // Import this module's dependencies.
+      for (unsigned I = 0, N = Mod->Imports.size(); I != N; ++I) {
+        if (ImportedModules.insert(Mod->Imports[I]))
+          Stack.push_back(Mod->Imports[I]);
+      }
     }
     break;
  }
diff --git a/test/Modules/Inputs/DependsOnModule.framework/DependsOnModule b/test/Modules/Inputs/DependsOnModule.framework/DependsOnModule
new file mode 100644 (file)
index 0000000..e69de29
index 836d910914a2c572b93183006d5975e90415b721..9da6d32ec18a3b03cdae31bc51ece42d33c513b5 100644 (file)
@@ -13,9 +13,9 @@ int g() {
   return autolink;
 }
 
-@import Module.SubFramework;
-const char *get_module_subframework() {
-  return module_subframework;
+@import DependsOnModule.SubFramework;
+float *get_module_subframework() {
+  return sub_framework;
 }
 
 @import NoUmbrella;
@@ -23,8 +23,9 @@ int use_no_umbrella() {
   return no_umbrella_A;
 }
 
-// CHECK: !llvm.module.linkoptions = !{![[AUTOLINK:[0-9]+]], ![[AUTOLINK_FRAMEWORK:[0-9]+]], ![[MODULE:[0-9]+]], ![[NOUMBRELLA:[0-9]+]]}
+// CHECK: !llvm.module.linkoptions = !{![[AUTOLINK:[0-9]+]], ![[AUTOLINK_FRAMEWORK:[0-9]+]], ![[DEPENDSONMODULE:[0-9]+]], ![[MODULE:[0-9]+]], ![[NOUMBRELLA:[0-9]+]]}
 // CHECK: ![[AUTOLINK]] = metadata !{metadata !"-lautolink"}
 // CHECK: ![[AUTOLINK_FRAMEWORK]] = metadata !{metadata !"-framework", metadata !"autolink_framework"}
+// CHECK: ![[DEPENDSONMODULE]] = metadata !{metadata !"-framework", metadata !"DependsOnModule"}
 // CHECK: ![[MODULE]] = metadata !{metadata !"-framework", metadata !"Module"}
 // CHECK: ![[NOUMBRELLA]] = metadata !{metadata !"-framework", metadata !"NoUmbrella"}