From 9803ee8e9a3af45cdb62e5359929ff608d6dae7d Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Wed, 11 Jan 2017 18:47:38 +0000 Subject: Module: Do not add any link flags when an implementation TU of a module imports a header of that same module. This fixes a regression caused by r280409. rdar://problem/29930553 This is an updated version for r291628 (which was reverted in r291688). llvm-svn: 291689 --- clang/lib/CodeGen/CodeGenModule.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index ab29d2dbb56..36005430ae4 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1243,9 +1243,15 @@ void CodeGenModule::EmitModuleLinkOptions() { SmallVector Stack; // Seed the stack with imported modules. - for (Module *M : ImportedModules) + for (Module *M : ImportedModules) { + // Do not add any link flags when an implementation TU of a module imports + // a header of that same module. + if (M->getTopLevelModuleName() == getLangOpts().CurrentModule && + !getLangOpts().isCompilingModule()) + continue; if (Visited.insert(M).second) Stack.push_back(M); + } // Find all of the modules to import, making a little effort to prune // non-leaf modules. -- cgit v1.2.3