[PATCH] D83006: [ASTImporter] Add unittest case for friend decl import

Vince Bridgers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 1 16:13:54 PDT 2020


vabridgers created this revision.
vabridgers added a reviewer: martong.
Herald added subscribers: cfe-commits, teemperor, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.
vabridgers updated this revision to Diff 274945.
vabridgers added a comment.

Updated commit header.


This change adds a matching test case for the recent bug fix to
VisitFriendDecl in ASTImporterLookup.cpp.

See https://reviews.llvm.org/D82882 for details.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83006

Files:
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===================================================================
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3417,6 +3417,29 @@
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
+       ClassTemplateFriendDecl) {
+  auto Code =
+      R"(
+      template <class T> class X {  friend T; };
+      struct Y {};
+      template class X<Y>;
+    )";
+  Decl *ToTU = getToTuDecl(Code, Lang_CXX11);
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromSpec =
+      FirstDeclMatcher<ClassTemplateSpecializationDecl>().match(
+          FromTU, classTemplateSpecializationDecl());
+  auto *ToSpec =
+      FirstDeclMatcher<ClassTemplateSpecializationDecl>().match(
+          ToTU, classTemplateSpecializationDecl());
+
+  auto *ImportedSpec = Import(FromSpec, Lang_CXX11);
+  EXPECT_EQ(ImportedSpec, ToSpec);
+  EXPECT_EQ(1u, DeclCounter<ClassTemplateSpecializationDecl>().match(
+                    ToTU, classTemplateSpecializationDecl()));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
        ClassTemplatePartialSpecializationsShouldNotBeDuplicated) {
   auto Code =
       R"(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83006.274945.patch
Type: text/x-patch
Size: 1183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200701/703fbf23/attachment.bin>


More information about the cfe-commits mailing list