From 3baad29d4413e1409fc69a472d374cf5de1d78ec Mon Sep 17 00:00:00 2001 From: Douglas Gregor <dgregor@apple.com> Date: Mon, 14 Jan 2013 19:00:05 +0000 Subject: [PATCH] When forming the link options for an imported module, also include the 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 | 9 +++++++-- .../Inputs/DependsOnModule.framework/DependsOnModule | 0 test/Modules/autolink.m | 9 +++++---- 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 test/Modules/Inputs/DependsOnModule.framework/DependsOnModule diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index c43528866b0..4b662e0b899 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -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 index 00000000000..e69de29bb2d diff --git a/test/Modules/autolink.m b/test/Modules/autolink.m index 836d910914a..9da6d32ec18 100644 --- a/test/Modules/autolink.m +++ b/test/Modules/autolink.m @@ -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"} -- GitLab