<div dir="ltr">Seems causes failure in selfhosting.<div><a href="http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/10188">http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/10188</a><br></div><div><br></div><div>FYI, I saw the log below (on my local branch);</div><div><br></div><div><div>While building module 'LLVM_Utils' imported from ~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:</div><div>While building module 'std' imported from ~/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h:14:</div><div>In file included from <module-includes>:4:</div><div>In file included from ~/llvm/install/bin/../include/c++/v1/bitset:124:</div><div>In file included from ~/llvm/install/bin/../include/c++/v1/string:438:</div><div>~/llvm/install/bin/../include/c++/v1/cwchar:118:9: error: no member named 'tm' in the global namespace; did you mean 'tm'?</div><div>using ::tm;</div><div>      ~~^</div><div>/usr/include/time.h:133:8: note: 'tm' declared here</div><div>struct tm</div><div>       ^</div><div>While building module 'LLVM_Utils' imported from ~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:</div><div>In file included from <module-includes>:1:</div><div>In file included from ~/llvm/llvm-project/llvm/include/llvm/ADT/StringMap.h:17:</div><div>~/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h:14:10: fatal error: could not build module 'std'</div><div>#include <algorithm></div><div> ~~~~~~~~^</div><div>While building module 'LLVM_Utils' imported from ~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:</div><div>While building module 'LLVM_Support_DataTypes' imported from ~/llvm/llvm-project/llvm/include/llvm/Support/SwapByteOrder.h:19:</div><div>In file included from <module-includes>:1:</div><div>include/llvm/Support/DataTypes.h:35:10: fatal error: could not build module 'std'</div><div>#include <cmath></div><div> ~~~~~~~~^</div><div>While building module 'LLVM_Utils' imported from ~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:</div><div>While building module 'LLVM_C' imported from ~/llvm/llvm-project/llvm/include/llvm/Support/CBindingWrapping.h:18:</div><div>In file included from <module-includes>:1:</div><div>~/llvm/llvm-project/llvm/include/llvm-c/./Support.h:17:10: fatal error: could not build module 'LLVM_Support_DataTypes'</div><div>#include "llvm/Support/DataTypes.h"</div><div> ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~</div><div>~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:10: fatal error: could not build module 'LLVM_Utils'</div><div>#include "llvm/Support/ARMBuildAttributes.h"</div><div> ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</div><div>5 errors generated.</div></div><div><br></div><div>Reverting r256907 just works for me. Lemme know if you would like more information.</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jan 6, 2016 at 12:55 PM Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Tue Jan  5 21:52:10 2016<br>
New Revision: 256907<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=256907&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=256907&view=rev</a><br>
Log:<br>
[modules] When a tag type that was imported from a module is referenced via an<br>
elaborated-type-specifier, create a declaration of it to track that the current<br>
module makes it visible too.<br>
<br>
Added:<br>
    cfe/trunk/test/Modules/tag-injection.cpp<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaDecl.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=256907&r1=256906&r2=256907&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=256907&r1=256906&r2=256907&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan  5 21:52:10 2016<br>
@@ -12277,16 +12277,35 @@ Decl *Sema::ActOnTag(Scope *S, unsigned<br>
         if (!Invalid) {<br>
           // If this is a use, just return the declaration we found, unless<br>
           // we have attributes.<br>
-<br>
-          // FIXME: In the future, return a variant or some other clue<br>
-          // for the consumer of this Decl to know it doesn't own it.<br>
-          // For our current ASTs this shouldn't be a problem, but will<br>
-          // need to be changed with DeclGroups.<br>
-          if (!Attr &&<br>
-              ((TUK == TUK_Reference &&<br>
-                (!PrevTagDecl->getFriendObjectKind() || getLangOpts().MicrosoftExt))<br>
-               || TUK == TUK_Friend))<br>
-            return PrevTagDecl;<br>
+          if (TUK == TUK_Reference || TUK == TUK_Friend) {<br>
+            if (Attr) {<br>
+              // FIXME: Diagnose these attributes. For now, we create a new<br>
+              // declaration to hold them.<br>
+            } else if (TUK == TUK_Reference &&<br>
+                       (PrevTagDecl->getFriendObjectKind() ==<br>
+                            Decl::FOK_Undeclared ||<br>
+                        getOwningModule(PrevDecl) !=<br>
+                            PP.getModuleContainingLocation(KWLoc)) &&<br>
+                       SS.isEmpty()) {<br>
+              // This declaration is a reference to an existing entity, but<br>
+              // has different visibility from that entity: it either makes<br>
+              // a friend visible or it makes a type visible in a new module.<br>
+              // In either case, create a new declaration. We only do this if<br>
+              // the declaration would have meant the same thing if no prior<br>
+              // declaration were found, that is, if it was found in the same<br>
+              // scope where we would have injected a declaration.<br>
+              DeclContext *InjectedDC = CurContext;<br>
+              while (!InjectedDC->isFileContext() &&<br>
+                     !InjectedDC->isFunctionOrMethod())<br>
+                InjectedDC = InjectedDC->getParent();<br>
+              if (!InjectedDC->getRedeclContext()->Equals(<br>
+                  PrevDecl->getDeclContext()->getRedeclContext()))<br>
+                return PrevTagDecl;<br>
+              // This is in the injected scope, create a new declaration.<br>
+            } else {<br>
+              return PrevTagDecl;<br>
+            }<br>
+          }<br>
<br>
           // Diagnose attempts to redefine a tag.<br>
           if (TUK == TUK_Definition) {<br>
<br>
Added: cfe/trunk/test/Modules/tag-injection.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/tag-injection.cpp?rev=256907&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/tag-injection.cpp?rev=256907&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/tag-injection.cpp (added)<br>
+++ cfe/trunk/test/Modules/tag-injection.cpp Tue Jan  5 21:52:10 2016<br>
@@ -0,0 +1,22 @@<br>
+// RUN: rm -rf %t<br>
+// RUN: mkdir %t<br>
+// RUN: touch %t/a.h<br>
+// RUN: echo 'struct X {};' > %t/b.h<br>
+// RUN: echo 'module X { module a { header "a.h" } module b { header "b.h" } }' > %t/x.modulemap<br>
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -fmodule-map-file=%t/x.modulemap %s -I%t -verify -fmodules-local-submodule-visibility -std=c++11<br>
+<br>
+#include "a.h"<br>
+<br>
+struct A {<br>
+  // This use of 'struct X' makes the declaration (but not definition) of X visible.<br>
+  virtual void f(struct X *p);<br>
+};<br>
+<br>
+namespace N {<br>
+  struct B : A {<br>
+    void f(struct X *q) override;<br>
+  };<br>
+}<br>
+<br>
+X x; // expected-error {{definition of 'X' must be imported from module 'X.b' before it is required}}<br>
+// expected-note@b.h:1 {{here}}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">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/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>