[clang] [clang][ASTImport] fix issue on anonymous enum import (PR #93923)
Qizhi Hu via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 3 07:01:06 PDT 2024
================
@@ -9674,6 +9674,40 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportInstantiatedFromMember) {
EXPECT_TRUE(ImportedPartialSpecialization->getInstantiatedFromMember());
}
+AST_MATCHER_P(EnumDecl, hasEnumConstName, StringRef, ConstName) {
+ for (EnumConstantDecl *D : Node.enumerators())
+ if (D->getName() == ConstName)
+ return true;
+ return false;
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportAnonymousEnum) {
+ const char *ToCode =
+ R"(
+ struct A {
+ enum { E1, E2} x;
+ enum { E3, E4} y;
+ };
+ )";
+ Decl *ToTu = getToTuDecl(ToCode, Lang_CXX11);
+ auto *ToE = FirstDeclMatcher<EnumDecl>().match(
+ ToTu, enumDecl(hasEnumConstName("E1")));
----------------
jcsxky wrote:
Import test on the other enum has been added to make this test completely.
https://github.com/llvm/llvm-project/pull/93923
More information about the cfe-commits
mailing list