<div dir="ltr">Thank you!</div><div class="gmail_extra"><br><div class="gmail_quote">On 11 January 2017 at 10:47, Manman Ren via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mren<br>
Date: Wed Jan 11 12:47:38 2017<br>
New Revision: 291689<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=291689&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=291689&view=rev</a><br>
Log:<br>
Module: Do not add any link flags when an implementation TU of a module imports<br>
a header of that same module.<br>
<br>
This fixes a regression caused by r280409.<br>
rdar://problem/29930553<br>
<br>
This is an updated version for r291628 (which was reverted in r291688).<br>
<br>
Added:<br>
cfe/trunk/test/Modules/Inputs/<wbr>module-impl-with-link/<br>
cfe/trunk/test/Modules/Inputs/<wbr>module-impl-with-link/foo.h<br>
cfe/trunk/test/Modules/Inputs/<wbr>module-impl-with-link/module.<wbr>modulemap<br>
cfe/trunk/test/Modules/module-<wbr>impl-with-link.c<br>
Modified:<br>
cfe/trunk/lib/CodeGen/<wbr>CodeGenModule.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/<wbr>CodeGenModule.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=291689&r1=291688&r2=291689&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/CodeGen/<wbr>CodeGenModule.cpp?rev=291689&<wbr>r1=291688&r2=291689&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/CodeGen/<wbr>CodeGenModule.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/<wbr>CodeGenModule.cpp Wed Jan 11 12:47:38 2017<br>
@@ -1243,9 +1243,15 @@ void CodeGenModule::<wbr>EmitModuleLinkOption<br>
SmallVector<clang::Module *, 16> Stack;<br>
<br>
// Seed the stack with imported modules.<br>
- for (Module *M : ImportedModules)<br>
+ for (Module *M : ImportedModules) {<br>
+ // Do not add any link flags when an implementation TU of a module imports<br>
+ // a header of that same module.<br>
+ if (M->getTopLevelModuleName() == getLangOpts().CurrentModule &&<br>
+ !getLangOpts().<wbr>isCompilingModule())<br>
+ continue;<br>
if (Visited.insert(M).second)<br>
Stack.push_back(M);<br>
+ }<br>
<br>
// Find all of the modules to import, making a little effort to prune<br>
// non-leaf modules.<br>
<br>
Added: cfe/trunk/test/Modules/Inputs/<wbr>module-impl-with-link/foo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h?rev=291689&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Modules/Inputs/module-impl-<wbr>with-link/foo.h?rev=291689&<wbr>view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Modules/Inputs/<wbr>module-impl-with-link/foo.h (added)<br>
+++ cfe/trunk/test/Modules/Inputs/<wbr>module-impl-with-link/foo.h Wed Jan 11 12:47:38 2017<br>
@@ -0,0 +1 @@<br>
+//empty<br>
<br>
Added: cfe/trunk/test/Modules/Inputs/<wbr>module-impl-with-link/module.<wbr>modulemap<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap?rev=291689&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Modules/Inputs/module-impl-<wbr>with-link/module.modulemap?<wbr>rev=291689&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Modules/Inputs/<wbr>module-impl-with-link/module.<wbr>modulemap (added)<br>
+++ cfe/trunk/test/Modules/Inputs/<wbr>module-impl-with-link/module.<wbr>modulemap Wed Jan 11 12:47:38 2017<br>
@@ -0,0 +1,4 @@<br>
+module Clib {<br>
+ header "foo.h"<br>
+ link "Clib"<br>
+}<br>
<br>
Added: cfe/trunk/test/Modules/module-<wbr>impl-with-link.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-impl-with-link.c?rev=291689&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Modules/module-impl-with-link.<wbr>c?rev=291689&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Modules/module-<wbr>impl-with-link.c (added)<br>
+++ cfe/trunk/test/Modules/module-<wbr>impl-with-link.c Wed Jan 11 12:47:38 2017<br>
@@ -0,0 +1,7 @@<br>
+// RUN: rm -rf %t<br>
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fmodule-name=Clib %s -I %S/Inputs/module-impl-with-<wbr>link -emit-llvm -o -<br>
+#include "foo.h"<br>
+// CHECK: !{{[0-9]+}} = !{i32 6, !"Linker Options", ![[LINK_OPTIONS:[0-9]+]]}<br>
+// Make sure we don't generate linker option for module Clib since this TU is<br>
+// an implementation of Clib.<br>
+// CHECK: ![[LINK_OPTIONS]] = !{}<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>