Skip to content

Commit e7ee21f

Browse files
authored
[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.
1 parent dba3dfa commit e7ee21f

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

clang/bindings/python/clang/cindex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,7 @@ def get_exception_specification_kind(self):
26542654
the ExceptionSpecificationKind enumeration.
26552655
"""
26562656
return ExceptionSpecificationKind.from_id(
2657-
conf.lib.clang.getExceptionSpecificationType(self)
2657+
conf.lib.clang_getExceptionSpecificationType(self)
26582658
)
26592659

26602660
@property

clang/bindings/python/tests/cindex/test_exception_specification_kind.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
def find_function_declarations(node, declarations=[]):
1515
if node.kind == clang.cindex.CursorKind.FUNCTION_DECL:
16-
declarations.append((node.spelling, node.exception_specification_kind))
16+
declarations.append(node)
1717
for child in node.get_children():
1818
declarations = find_function_declarations(child, declarations)
1919
return declarations
@@ -33,4 +33,12 @@ def test_exception_specification_kind(self):
3333
("square2", ExceptionSpecificationKind.BASIC_NOEXCEPT),
3434
("square3", ExceptionSpecificationKind.COMPUTED_NOEXCEPT),
3535
]
36-
self.assertListEqual(declarations, expected)
36+
from_cursor = [
37+
(node.spelling, node.exception_specification_kind) for node in declarations
38+
]
39+
from_type = [
40+
(node.spelling, node.type.get_exception_specification_kind())
41+
for node in declarations
42+
]
43+
self.assertListEqual(from_cursor, expected)
44+
self.assertListEqual(from_type, expected)

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ Sanitizers
302302

303303
Python Binding Changes
304304
----------------------
305+
- Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``.
305306

306307
OpenMP Support
307308
--------------

0 commit comments

Comments
 (0)