@@ -5634,6 +5634,43 @@ TEST_P(ImportFriendFunctionTemplates, LookupShouldFindPreviousFriend) {
5634
5634
EXPECT_EQ (Imported->getPreviousDecl (), Friend);
5635
5635
}
5636
5636
5637
+ TEST_P (ImportFriendFunctionTemplates, ImportFriendFunctionInsideClassTemplate) {
5638
+ Decl *From, *To;
5639
+ std::tie (From, To) = getImportedDecl (
5640
+ R"(
5641
+ template <typename T> struct X {
5642
+ template <typename U> friend void f();
5643
+ };
5644
+ )" ,
5645
+ Lang_CXX03, " " , Lang_CXX03, " X" );
5646
+
5647
+ auto *FromFriend = FirstDeclMatcher<FriendDecl>().match (From, friendDecl ());
5648
+ auto *ToFriend = FirstDeclMatcher<FriendDecl>().match (To, friendDecl ());
5649
+
5650
+ EXPECT_TRUE (FromFriend ==
5651
+ LastDeclMatcher<FriendDecl>().match (From, friendDecl ()));
5652
+ EXPECT_TRUE (ToFriend ==
5653
+ LastDeclMatcher<FriendDecl>().match (To, friendDecl ()));
5654
+
5655
+ auto *FromDecl = FromFriend->getFriendDecl ();
5656
+ auto *FromDC = FromFriend->getDeclContext ();
5657
+ auto *FromLexicalDC = FromFriend->getLexicalDeclContext ();
5658
+
5659
+ EXPECT_TRUE (FromDC->containsDecl (FromFriend));
5660
+ EXPECT_FALSE (FromDC->containsDecl (FromDecl));
5661
+ EXPECT_TRUE (FromLexicalDC->containsDecl (FromFriend));
5662
+ EXPECT_FALSE (FromLexicalDC->containsDecl (FromDecl));
5663
+
5664
+ auto *ToDecl = ToFriend->getFriendDecl ();
5665
+ auto *ToDC = ToFriend->getDeclContext ();
5666
+ auto *ToLexicalDC = ToFriend->getLexicalDeclContext ();
5667
+
5668
+ EXPECT_TRUE (ToDC->containsDecl (ToFriend));
5669
+ EXPECT_FALSE (ToDC->containsDecl (ToDecl));
5670
+ EXPECT_TRUE (ToLexicalDC->containsDecl (ToFriend));
5671
+ EXPECT_FALSE (ToLexicalDC->containsDecl (ToDecl));
5672
+ }
5673
+
5637
5674
struct ASTImporterWithFakeErrors : ASTImporter {
5638
5675
using ASTImporter::ASTImporter;
5639
5676
bool returnWithErrorInTest () override { return true ; }
0 commit comments