[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:14:03 PDT 2020


vabridgers updated this revision to Diff 274945.
vabridgers added a comment.

Updated commit header.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83006/new/

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/d30a774b/attachment.bin>


More information about the cfe-commits mailing list