Author: Jannick Kremer Date: 2024-08-02T17:25:30+04:00 New Revision: e7ee21fbc96664cf7736194c0ed922753e338989
URL: https://github.com/llvm/llvm-project/commit/e7ee21fbc96664cf7736194c0ed922753e338989 DIFF: https://github.com/llvm/llvm-project/commit/e7ee21fbc96664cf7736194c0ed922753e338989.diff LOG: [libclang/python] Fix `get_exception_specification_kind` (#101548) Fix a bug with `get_exception_specification_kind`. The function did not work before. Also add a test that confirms that it works now. Added: Modified: clang/bindings/python/clang/cindex.py clang/bindings/python/tests/cindex/test_exception_specification_kind.py clang/docs/ReleaseNotes.rst Removed: ################################################################################ diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 2038ef6045c7d..c251c46a04adf 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2654,7 +2654,7 @@ def get_exception_specification_kind(self): the ExceptionSpecificationKind enumeration. """ return ExceptionSpecificationKind.from_id( - conf.lib.clang.getExceptionSpecificationType(self) + conf.lib.clang_getExceptionSpecificationType(self) ) @property diff --git a/clang/bindings/python/tests/cindex/test_exception_specification_kind.py b/clang/bindings/python/tests/cindex/test_exception_specification_kind.py index 8e2a6b5c50223..e4742db31adbe 100644 --- a/clang/bindings/python/tests/cindex/test_exception_specification_kind.py +++ b/clang/bindings/python/tests/cindex/test_exception_specification_kind.py @@ -13,7 +13,7 @@ def find_function_declarations(node, declarations=[]): if node.kind == clang.cindex.CursorKind.FUNCTION_DECL: - declarations.append((node.spelling, node.exception_specification_kind)) + declarations.append(node) for child in node.get_children(): declarations = find_function_declarations(child, declarations) return declarations @@ -33,4 +33,12 @@ def test_exception_specification_kind(self): ("square2", ExceptionSpecificationKind.BASIC_NOEXCEPT), ("square3", ExceptionSpecificationKind.COMPUTED_NOEXCEPT), ] - self.assertListEqual(declarations, expected) + from_cursor = [ + (node.spelling, node.exception_specification_kind) for node in declarations + ] + from_type = [ + (node.spelling, node.type.get_exception_specification_kind()) + for node in declarations + ] + self.assertListEqual(from_cursor, expected) + self.assertListEqual(from_type, expected) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index efa01bfc92cf6..25f5bd37bbe94 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -302,6 +302,7 @@ Sanitizers Python Binding Changes ---------------------- +- Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``. OpenMP Support -------------- _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits