================ @@ -44,8 +46,53 @@ def test_from_id(self): def test_duplicate_ids(self): """Check that no two kinds have the same id""" - # for enum in self.enums: for enum in self.enums: num_declared_variants = len(enum._member_map_.keys()) num_unique_variants = len(list(enum)) self.assertEqual(num_declared_variants, num_unique_variants) + + def test_all_variants(self): + """Check that all libclang enum values are also defined in cindex""" + cenum_to_pythonenum = { + "CX_CXXAccessSpecifier": AccessSpecifier, + "CXAvailabilityKind": AvailabilityKind, + "CXBinaryOperatorKind": BinaryOperator, + "CXCursorKind": CursorKind, + "CXCursor_ExceptionSpecificationKind": ExceptionSpecificationKind, + "CXLinkageKind": LinkageKind, + "CXRefQualifierKind": RefQualifierKind, + "CX_StorageClass": StorageClass, + "CXTemplateArgumentKind": TemplateArgumentKind, + "CXTLSKind": TLSKind, + "CXTokenKind": TokenKind, + "CXTypeKind": TypeKind, + } + + indexheader = ( + Path(__file__).parent.parent.parent.parent.parent + / "include/clang-c/Index.h" + ) + tu = TranslationUnit.from_source(indexheader, ["-x", "c++"]) ---------------- DeinAlptraum wrote:
This doesn't seem to be (currently) possible. I'm relying on the `enum_value` interface of `Cursor` to get the value, and that interface asserts `cursor.kind == CursorKind.ENUM_CONSTANT_DECL` which fails when I read this as C code (all variants have only a `CursorKind.PARM_DECL` and a `CursorKind.TYPE_REF` node in C mode) https://github.com/llvm/llvm-project/pull/143264 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits