[clang] [clang][ASTImporter] Fix crash when import `VarTemplateDecl` in record (PR #67522)

Qizhi Hu via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 3 03:08:05 PDT 2023


================
@@ -4988,6 +4988,39 @@ TEST_P(ASTImporterOptionSpecificTestBase,
   }
 }
 
+TEST_P(ImportFriendClasses, RecordVarTemplateDecl) {
+  Decl *ToTU = getToTuDecl(
+      R"(
+      template <class T>
+      class A {
+      public:
+        template <class U>
+        static constexpr bool X = true;
+      };
+      )",
+      Lang_CXX14);
+
+  auto *Fwd = FirstDeclMatcher<VarTemplateDecl>().match(
+      ToTU, varTemplateDecl(hasName("X")));
+  Decl *FromTU = getTuDecl(
+      R"(
+      template <class T>
+      class A {
+      public:
+        template <class U>
+        static constexpr bool X = true;
+      };
+      )",
+      Lang_CXX14, "input1.cc");
+  auto *FromA = FirstDeclMatcher<VarTemplateDecl>().match(
+      FromTU, varTemplateDecl(hasName("X")));
+  auto *ToA = Import(FromA, Lang_CXX11);
+  EXPECT_TRUE(ToA);
+  EXPECT_EQ(Fwd->getTemplatedDecl(), ToA->getTemplatedDecl());
----------------
jcsxky wrote:

Yes, thanks for your suggestion. And other variable naming also has been updated.

https://github.com/llvm/llvm-project/pull/67522


More information about the cfe-commits mailing list