<div dir="ltr"><div><span style="font-size:12.8px">The following test fails on my machine:</span></div><div><span style="font-size:12.8px"><br></span></div><div><div>> // svn: E155007</div><div>> // unittests/AST/ASTImporterTest.<wbr>cpp</div><div><div style="font-size:12.8px">> TEST(ImportExpr, ImportIOstream) {</div><div style="font-size:12.8px">> MatchVerifier<Decl> Verifier;</div><div style="font-size:12.8px">> EXPECT_TRUE(testImport(</div><div style="font-size:12.8px">> "#include<iostream> \n"</div><div style="font-size:12.8px">> "inline namespace D {\n"</div><div style="font-size:12.8px">> " template<class>\n"</div><div style="font-size:12.8px">> " struct declToImport {<span style="font-size:12.8px">};\n"</span></div><div style="font-size:12.8px">> "}\n", Lang_CXX, "", Lang_CXX, Verifier, decl()));</div><div style="font-size:12.8px">> }</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">It seems that the astImporter is not completely deterministic.</div><div style="font-size:12.8px">In anycase, I encounter one of two errors:</div><div><span style="font-size:12.8px">1) If it calls `</span>TagDecl::setTypedefDeclForAnonDecl`<span style="font-size:12.8px"> it fails as `</span>assert(T->isLinkageValid());` is false</div><div>2) If it parses a FriendDecl it gets stuck in an infinite loop :</div><div><br></div><div>Decl *ASTNodeImporter::VisitFriendDecl(FriendDecl *D) {</div><div>/*......*/</div><div><div> │3437 while (ImportedFriend) {</div><div> │3438 if (D->getFriendDecl() && ImportedFriend->getFriendDecl()) { </div><div> // ^^^ evaluates to false</div><div> │3439 if (Context.IsStructurallyEquivalent(D->getFriendDecl(), </div><div> │3440 ImportedFriend->getFriendDecl()))</div><div> │3441 return Importer.Imported(D, ImportedFriend);</div><div> │3442</div><div> │3443 } else if (D->getFriendType() && ImportedFriend->getFriendType()) {</div><div> │3444 if (Importer.IsStructurallyEquivalent( </div><div> // ^^^ always false</div><div> │3445 D->getFriendType()->getType(), </div><div> │3446 ImportedFriend->getFriendType()->getType(), true)) </div><div> │3447 return Importer.Imported(D, ImportedFriend); </div><div> │3448 } </div><div> │3449 ImportedFriend = ImportedFriend->getNextFriend(); </div><div> // ^^^ returns always the same frienddecl; </div><div> // why does a Frienddecl has itself as a friend ?</div><div> │3450 } </div><div><br></div><div>Does anybody have an idea what's going on? </div></div><div><br></div><br><br></div><img width="0" height="0" class="mailtrack-img" src="https://mailtrack.io/trace/mail/f602f5bb94661ea85bc50755d735c1086b00182c.png?u=931501"></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-09 13:49 GMT+00:00 Gaetano Checinski <span dir="ltr"><<a href="mailto:gaetano.checinski@gmail.com" target="_blank">gaetano.checinski@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Guys,</div><div>I've noticed that the ASTImporter fails to import some named decls from <iostream> due to an invalid linkagecache (in TagDecl::<wbr>setTypedefNameForAnonDecl()).</div><div>Running with assertions disabled never terminates.</div><div>However, while trying to build an minimal reproducible example, i stumbled on a different error regarding templated structs with frienddecls.</div><div>I think they may be related because i found this commit: </div><div><a href="https://mailtrack.io/trace/link/3bfa5f729eac3d7d441cda522b04d9aa06778eec?url=https%3A%2F%2Fpublic.cdl.uni-saarland.de%2Fnoise%2Fclang%2Fcommit%2Fad0e27b18b0cefab049121d4bfd7b12216e7de6e&signature=1e3968956e628307" target="_blank">https://public.cdl.uni-<wbr>saarland.de/noise/clang/<wbr>commit/<wbr>ad0e27b18b0cefab049121d4bfd7b1<wbr>2216e7de6e</a></div><div><br></div><div><br></div><div>The following test fails:</div><div> </div><div>> // svn: E155007</div><div>> // unittests/AST/ASTImporterTest.<wbr>cpp</div><div><div>> TEST(ImportExpr, TemplatedStructFriend) {</div><div>> MatchVerifier<Decl> Verifier;</div><div>> EXPECT_TRUE(testImport(</div><div>> "void foo() {}; \n"</div><div>> "inline namespace D {\n"</div><div>> " template<class>\n"</div><div>> " struct declToImport {\n"</div><div>> " friend bool f(const declToImport &);\n"</div><div>> " };\n"</div><div>> " template class declToImport<int>;\n"</div><div>> "}\n", Lang_CXX, "", Lang_CXX, Verifier, decl()));</div><div>> }</div><div><br></div><div>stacktrace: </div>> clang/llvm/tools/clang/lib/<wbr>AST/DeclFriend.cpp, line 43.<div>> 0 ASTTests 0x0000000104f8e135 l </div><div>> lvm::sys::PrintStackTrace(<wbr>llvm::raw_ostream&) + 101</div><div>> 1 ASTTests 0x0000000104f8e779 PrintStackTraceSignalHandler(<wbr>void*) + 25</div><div>> 2 ASTTests 0x0000000104f8a6d9 llvm::sys::RunSignalHandlers() + 425</div><div>> 3 ASTTests 0x0000000104f8ec92 SignalHandler(int) + 354</div><div>> 4 libsystem_platform.dylib 0x00007fff9e3eebba _sigtramp + 26</div><div><br></div><div>Thanks in advance,</div><div>Gaetano Checinski</div><div><br></div><div><br></div></div><img width="0" height="0" class="m_-792721907466976921mailtrack-img" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"></div>
</blockquote></div><br></div>