[clang] [clang][ASTImport] fix issue on anonymous enum import (PR #93923)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Fri May 31 08:38:29 PDT 2024
================
@@ -9674,6 +9674,27 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportInstantiatedFromMember) {
EXPECT_TRUE(ImportedPartialSpecialization->getInstantiatedFromMember());
}
+TEST_P(ASTImporterOptionSpecificTestBase, ImportAnonymousEnum) {
+ const char *ToCode =
+ R"(
+ struct A {
+ enum { E1,E2} x;
+ };
+ )";
+ (void)getToTuDecl(ToCode, Lang_CXX11);
+ const char *Code =
+ R"(
+ struct A {
+ enum { E1,E2} x;
+ };
+ )";
+ Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+ auto *FromE = FirstDeclMatcher<EnumDecl>().match(FromTU, enumDecl());
+ auto *ToE = Import(FromE, Lang_CXX11);
+ ASSERT_TRUE(ToE);
+ EXPECT_FALSE(ToE->enumerators().empty());
----------------
balazske wrote:
It is more safe to get the `EnumDecl` in the `ToTU` before the import (`ToExistingE`) and after import check if it is equal to `ToE`.
https://github.com/llvm/llvm-project/pull/93923
More information about the cfe-commits
mailing list