diff options
author | Nico Weber <thakis@chromium.org> | 2019-12-17 13:43:50 -0500 |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2019-12-17 13:43:50 -0500 |
commit | 55c55f8eb86ba3e77fe73ccdf7c861e2c2c7ae92 (patch) | |
tree | 85fc758eff962386d850024cbce041c63441cb59 /clang/unittests/AST | |
parent | 25ce33a6e4f3b13732c0f851e68390dc2acb9123 (diff) | |
download | bcm5719-llvm-55c55f8eb86ba3e77fe73ccdf7c861e2c2c7ae92.tar.gz bcm5719-llvm-55c55f8eb86ba3e77fe73ccdf7c861e2c2c7ae92.zip |
Revert "[ASTImporter] Friend class decl should not be visible in its context"
This reverts commit 4becf68c6f17fe143539ceac954b21175914e1c1.
Breaks building on Windows, see comments on D71020
Diffstat (limited to 'clang/unittests/AST')
-rw-r--r-- | clang/unittests/AST/ASTImporterTest.cpp | 50 |
1 files changed, 6 insertions, 44 deletions
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 3e8f804374f..6652111fd48 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -247,11 +247,6 @@ template <typename T> RecordDecl *getRecordDecl(T *D) { return cast<RecordType>(ET->getNamedType().getTypePtr())->getDecl(); } -static const RecordDecl *getRecordDeclOfFriend(FriendDecl *FD) { - QualType Ty = FD->getFriendType()->getType().getCanonicalType(); - return cast<RecordType>(Ty)->getDecl(); -} - struct ImportExpr : TestImportBase {}; struct ImportType : TestImportBase {}; struct ImportDecl : TestImportBase {}; @@ -2712,7 +2707,7 @@ TEST_P(ImportFriendFunctions, Lookup) { EXPECT_FALSE(To0->isInIdentifierNamespace(Decl::IDNS_Ordinary)); } -TEST_P(ImportFriendFunctions, LookupWithProtoAfter) { +TEST_P(ImportFriendFunctions, DISABLED_LookupWithProtoAfter) { auto FunctionPattern = functionDecl(hasName("f")); auto ClassPattern = cxxRecordDecl(hasName("X")); @@ -3783,44 +3778,6 @@ TEST_P(ImportFriendClasses, ImportOfRecursiveFriendClass) { EXPECT_TRUE(MatchVerifier<Decl>{}.match(ToD, Pattern)); } -TEST_P(ImportFriendClasses, UndeclaredFriendClassShouldNotBeVisible) { - Decl *FromTu = getTuDecl("class X { friend class Y; };", Lang_CXX, "from.cc"); - auto *FromX = FirstDeclMatcher<CXXRecordDecl>().match( - FromTu, cxxRecordDecl(hasName("X"))); - auto *FromFriend = FirstDeclMatcher<FriendDecl>().match(FromTu, friendDecl()); - RecordDecl *FromRecordOfFriend = - const_cast<RecordDecl *>(getRecordDeclOfFriend(FromFriend)); - - ASSERT_EQ(FromRecordOfFriend->getDeclContext(), cast<DeclContext>(FromTu)); - ASSERT_EQ(FromRecordOfFriend->getLexicalDeclContext(), - cast<DeclContext>(FromX)); - ASSERT_FALSE( - FromRecordOfFriend->getDeclContext()->containsDecl(FromRecordOfFriend)); - ASSERT_FALSE(FromRecordOfFriend->getLexicalDeclContext()->containsDecl( - FromRecordOfFriend)); - ASSERT_FALSE(FromRecordOfFriend->getLookupParent() - ->lookup(FromRecordOfFriend->getDeclName()) - .empty()); - - auto *ToX = Import(FromX, Lang_CXX); - ASSERT_TRUE(ToX); - - Decl *ToTu = ToX->getTranslationUnitDecl(); - auto *ToFriend = FirstDeclMatcher<FriendDecl>().match(ToTu, friendDecl()); - RecordDecl *ToRecordOfFriend = - const_cast<RecordDecl *>(getRecordDeclOfFriend(ToFriend)); - - ASSERT_EQ(ToRecordOfFriend->getDeclContext(), cast<DeclContext>(ToTu)); - ASSERT_EQ(ToRecordOfFriend->getLexicalDeclContext(), cast<DeclContext>(ToX)); - EXPECT_FALSE( - ToRecordOfFriend->getDeclContext()->containsDecl(ToRecordOfFriend)); - EXPECT_FALSE(ToRecordOfFriend->getLexicalDeclContext()->containsDecl( - ToRecordOfFriend)); - EXPECT_FALSE(ToRecordOfFriend->getLookupParent() - ->lookup(ToRecordOfFriend->getDeclName()) - .empty()); -} - TEST_P(ImportFriendClasses, ImportOfRecursiveFriendClassTemplate) { Decl *FromTu = getTuDecl( R"( @@ -4520,6 +4477,11 @@ TEST_P(ASTImporterLookupTableTest, LookupDeclNamesFromDifferentTUs) { ASSERT_EQ(Res.size(), 0u); } +static const RecordDecl *getRecordDeclOfFriend(FriendDecl *FD) { + QualType Ty = FD->getFriendType()->getType().getCanonicalType(); + return cast<RecordType>(Ty)->getDecl(); +} + TEST_P(ASTImporterLookupTableTest, LookupFindsFwdFriendClassDeclWithElaboratedType) { TranslationUnitDecl *ToTU = getToTuDecl( |