[clang] [clang][ASTImporter] import InstantiatedFromMember of ClassTemplateSpecializationDecl (PR #76493)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 3 00:18:51 PST 2024
================
@@ -9342,6 +9342,38 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportConflictTypeAliasTemplate) {
EXPECT_FALSE(ImportedCallable);
}
+AST_MATCHER(ClassTemplateSpecializationDecl, hasInstantiatedFromMember) {
+ if (auto Instantiate = Node.getInstantiatedFrom()) {
+ if (auto *FromPartialSpecialization =
+ Instantiate.get<ClassTemplatePartialSpecializationDecl *>()) {
+ return nullptr != FromPartialSpecialization->getInstantiatedFromMember();
+ }
+ }
+ return false;
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportInstantiatedFromMember) {
+ const char *Code =
+ R"(
+ template <typename> struct B {
+ template <typename, bool = false> union D;
+ template <typename T> union D<T> {};
+ D<int> d;
+ };
+ B<int> b;
+ )";
+ Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+ auto *FromA = FirstDeclMatcher<ClassTemplateSpecializationDecl>().match(
+ FromTU, classTemplateSpecializationDecl(hasName("D"),
+ hasInstantiatedFromMember()));
+ auto *FromPartialSpecialization =
+ cast<ClassTemplatePartialSpecializationDecl *>(
+ FromA->getInstantiatedFrom());
+ auto *ImportedPartialSpecialization =
----------------
balazske wrote:
ASSERT_TRUE(FromPartialSpecialization->getInstantiatedFromMember());
https://github.com/llvm/llvm-project/pull/76493
More information about the cfe-commits
mailing list