[PATCH] D57905: [ASTImporter][ASTImporterSpecificLookup] Add test for different operators
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 8 01:20:10 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rC353505: [ASTImporter][ASTImporterSpecificLookup] Add test for different operators (authored by martong, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D57905?vs=185924&id=185925#toc
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57905/new/
https://reviews.llvm.org/D57905
Files:
unittests/AST/ASTImporterTest.cpp
Index: unittests/AST/ASTImporterTest.cpp
===================================================================
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -4812,6 +4812,66 @@
EXPECT_EQ(Res.count(F2), 1u);
}
+TEST_P(ASTImporterLookupTableTest,
+ DifferentOperatorsShouldHaveDifferentResultSet) {
+ TranslationUnitDecl *ToTU = getToTuDecl(
+ R"(
+ struct X{};
+ void operator+(X, X);
+ void operator-(X, X);
+ )",
+ Lang_CXX);
+
+ ASTImporterLookupTable LT(*ToTU);
+ auto *FPlus = FirstDeclMatcher<FunctionDecl>().match(
+ ToTU, functionDecl(hasOverloadedOperatorName("+")));
+ auto *FMinus = FirstDeclMatcher<FunctionDecl>().match(
+ ToTU, functionDecl(hasOverloadedOperatorName("-")));
+ DeclarationName NamePlus = FPlus->getDeclName();
+ auto ResPlus = LT.lookup(ToTU, NamePlus);
+ EXPECT_EQ(ResPlus.size(), 1u);
+ EXPECT_EQ(ResPlus.count(FPlus), 1u);
+ EXPECT_EQ(ResPlus.count(FMinus), 0u);
+ DeclarationName NameMinus = FMinus->getDeclName();
+ auto ResMinus = LT.lookup(ToTU, NameMinus);
+ EXPECT_EQ(ResMinus.size(), 1u);
+ EXPECT_EQ(ResMinus.count(FMinus), 1u);
+ EXPECT_EQ(ResMinus.count(FPlus), 0u);
+ EXPECT_NE(*ResMinus.begin(), *ResPlus.begin());
+}
+
+TEST_P(ASTImporterLookupTableTest, LookupDeclNamesFromDifferentTUs) {
+ TranslationUnitDecl *ToTU = getToTuDecl(
+ R"(
+ struct X {};
+ void operator+(X, X);
+ )",
+ Lang_CXX);
+ auto *ToPlus = FirstDeclMatcher<FunctionDecl>().match(
+ ToTU, functionDecl(hasOverloadedOperatorName("+")));
+
+ Decl *FromTU = getTuDecl(
+ R"(
+ struct X {};
+ void operator+(X, X);
+ )",
+ Lang_CXX);
+ auto *FromPlus = FirstDeclMatcher<FunctionDecl>().match(
+ FromTU, functionDecl(hasOverloadedOperatorName("+")));
+
+ // FromPlus have a different TU, thus its DeclarationName is different too.
+ ASSERT_NE(ToPlus->getDeclName(), FromPlus->getDeclName());
+
+ ASTImporterLookupTable LT(*ToTU);
+ auto Res = LT.lookup(ToTU, ToPlus->getDeclName());
+ ASSERT_EQ(Res.size(), 1u);
+ EXPECT_EQ(*Res.begin(), ToPlus);
+
+ // FromPlus have a different TU, thus its DeclarationName is different too.
+ Res = LT.lookup(ToTU, FromPlus->getDeclName());
+ ASSERT_EQ(Res.size(), 0u);
+}
+
static const RecordDecl * getRecordDeclOfFriend(FriendDecl *FD) {
QualType Ty = FD->getFriendType()->getType();
QualType NamedTy = cast<ElaboratedType>(Ty)->getNamedType();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57905.185925.patch
Type: text/x-patch
Size: 2475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190208/766db1b1/attachment.bin>
More information about the cfe-commits
mailing list