[clang] [libclang/python] Fix get_exception_specification_kind (PR #101548)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 1 12:06:31 PDT 2024
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/101548
This fixes a bug with `get_exception_ specification_kind`. The function did not work before. Also add a test that confirms that it works now.
>From 7e5ff53e8dc56e15f84c3868a25a779be54a22f0 Mon Sep 17 00:00:00 2001
From: Jannick Kremer <jannick.kremer at mailbox.org>
Date: Thu, 1 Aug 2024 20:01:34 +0100
Subject: [PATCH] [libclang/python] Fix get_exception_specification_kind
---
clang/bindings/python/clang/cindex.py | 2 +-
.../tests/cindex/test_exception_specification_kind.py | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
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..6653c22eaf9cd 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,7 @@ 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)
More information about the cfe-commits
mailing list