From 674bdfb5d0160bf637cce069fdf03c465c81b287 Mon Sep 17 00:00:00 2001 From: tapplencourt Date: Fri, 10 Oct 2025 16:39:51 +0000 Subject: [PATCH 01/11] Add isFunctionInlined support in Python Binding --- clang/bindings/python/clang/cindex.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 80140d2787608..015667b4decd9 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2362,6 +2362,13 @@ def get_bitfield_width(self) -> int: """ return conf.lib.clang_getFieldDeclBitWidth(self) # type: ignore [no-any-return] + def is_function_inlined(self) -> bool: + """ + Check if the function is inlined + """ + assert self.kind == TypeKind.FUNCTIONPROTO + return bool(conf.lib.clang_Cursor_isFunctionInlined(self)) # type: ignore [no-any-return] + @cursor_null_guard def has_attrs(self) -> bool: """ @@ -4308,6 +4315,7 @@ def set_property(self, property, value): ("clang_Cursor_isAnonymous", [Cursor], bool), ("clang_Cursor_isAnonymousRecordDecl", [Cursor], bool), ("clang_Cursor_isBitField", [Cursor], bool), + ("clang_Cursor_isFunctionInlined", [Cursor], c_uint), ("clang_Location_isInSystemHeader", [SourceLocation], bool), ("clang_PrintingPolicy_dispose", [PrintingPolicy]), ("clang_PrintingPolicy_getProperty", [PrintingPolicy, c_int], c_uint), From 7a69e7d38c450c6cb8049f9aeb9e9c52be8e1e1e Mon Sep 17 00:00:00 2001 From: tapplencourt Date: Fri, 10 Oct 2025 16:39:51 +0000 Subject: [PATCH 02/11] Add isFunctionInlined support in Python Binding --- clang/bindings/python/clang/cindex.py | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 015667b4decd9..0c08e3faeec2c 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2362,6 +2362,7 @@ def get_bitfield_width(self) -> int: """ return conf.lib.clang_getFieldDeclBitWidth(self) # type: ignore [no-any-return] + @cursor_null_guard def is_function_inlined(self) -> bool: """ Check if the function is inlined From 9efe91b5421c809a5f877491ff5eb5a2ee95daf9 Mon Sep 17 00:00:00 2001 From: tapplencourt Date: Tue, 14 Oct 2025 15:26:11 +0000 Subject: [PATCH 03/11] Use bool implace of c_int --- clang/bindings/python/clang/cindex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 0c08e3faeec2c..f1295f606b030 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2368,7 +2368,7 @@ def is_function_inlined(self) -> bool: Check if the function is inlined """ assert self.kind == TypeKind.FUNCTIONPROTO - return bool(conf.lib.clang_Cursor_isFunctionInlined(self)) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_isFunctionInlined(self) # type: ignore [no-any-return] @cursor_null_guard def has_attrs(self) -> bool: @@ -4316,7 +4316,7 @@ def set_property(self, property, value): ("clang_Cursor_isAnonymous", [Cursor], bool), ("clang_Cursor_isAnonymousRecordDecl", [Cursor], bool), ("clang_Cursor_isBitField", [Cursor], bool), - ("clang_Cursor_isFunctionInlined", [Cursor], c_uint), + ("clang_Cursor_isFunctionInlined", [Cursor], bool), ("clang_Location_isInSystemHeader", [SourceLocation], bool), ("clang_PrintingPolicy_dispose", [PrintingPolicy]), ("clang_PrintingPolicy_getProperty", [PrintingPolicy, c_int], c_uint), From 8c14af8d1027a43d0e36ff6fbde5322da036c214 Mon Sep 17 00:00:00 2001 From: tapplencourt Date: Tue, 14 Oct 2025 15:26:49 +0000 Subject: [PATCH 04/11] Docstrings should end with a period --- clang/bindings/python/clang/cindex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index f1295f606b030..4cf14fd8899f8 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2365,7 +2365,7 @@ def get_bitfield_width(self) -> int: @cursor_null_guard def is_function_inlined(self) -> bool: """ - Check if the function is inlined + Check if the function is inlined. """ assert self.kind == TypeKind.FUNCTIONPROTO return conf.lib.clang_Cursor_isFunctionInlined(self) # type: ignore [no-any-return] From 6edd33cab590e4f712c0d43f5363670b276244f8 Mon Sep 17 00:00:00 2001 From: tapplencourt Date: Tue, 14 Oct 2025 15:30:58 +0000 Subject: [PATCH 05/11] add ReleaseNotes --- clang/docs/ReleaseNotes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 99aa545831240..037c9549d1aab 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -615,6 +615,7 @@ Sanitizers Python Binding Changes ---------------------- +- Exposed ``clang_Cursor_is_function_inlined``. - Exposed ``clang_getCursorLanguage`` via ``Cursor.language``. - Add all missing ``CursorKind``s, ``TypeKind``s and ``ExceptionSpecificationKind``s from ``Index.h`` From 484b385834187c482d880724e077c1a9ccbc0c7b Mon Sep 17 00:00:00 2001 From: tapplencourt Date: Tue, 14 Oct 2025 15:38:20 +0000 Subject: [PATCH 06/11] Add test for is_function_inlined --- clang/bindings/python/tests/cindex/test_cursor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py index eb0d1d50601a6..7f6230c9d1a36 100644 --- a/clang/bindings/python/tests/cindex/test_cursor.py +++ b/clang/bindings/python/tests/cindex/test_cursor.py @@ -784,6 +784,11 @@ def test_storage_class(self): cursor = get_cursor(tu, "reg") self.assertEqual(cursor.storage_class, StorageClass.REGISTER) + def test_function_inlined(self): + tu = get_tu("inline void foo(void);") + cursor = get_cursor(tu, "foo") + self.assertEqual(cursor.is_function_inlined(), True) + def test_availability(self): tu = get_tu("class A { A(A const&) = delete; };", lang="cpp") From a5d081ce33e6c0929ddd7fe710512871b6c5ce72 Mon Sep 17 00:00:00 2001 From: tapplencourt Date: Tue, 21 Oct 2025 20:26:27 +0000 Subject: [PATCH 07/11] Remove assert --- clang/bindings/python/clang/cindex.py | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 4cf14fd8899f8..7c0b26e311f94 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2367,7 +2367,6 @@ def is_function_inlined(self) -> bool: """ Check if the function is inlined. """ - assert self.kind == TypeKind.FUNCTIONPROTO return conf.lib.clang_Cursor_isFunctionInlined(self) # type: ignore [no-any-return] @cursor_null_guard From 0d1268ce0525db85dab7267b5921857413ce7d68 Mon Sep 17 00:00:00 2001 From: tapplencourt Date: Tue, 21 Oct 2025 20:33:33 +0000 Subject: [PATCH 08/11] Add more tests --- clang/bindings/python/tests/cindex/test_cursor.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py index 7f6230c9d1a36..7cb616a7ef148 100644 --- a/clang/bindings/python/tests/cindex/test_cursor.py +++ b/clang/bindings/python/tests/cindex/test_cursor.py @@ -785,9 +785,19 @@ def test_storage_class(self): self.assertEqual(cursor.storage_class, StorageClass.REGISTER) def test_function_inlined(self): - tu = get_tu("inline void foo(void);") - cursor = get_cursor(tu, "foo") + tu = get_tu( + """ +inline void f_inline(void); +void f_noninline(void); +int d_noninline; +""" + ) + cursor = get_cursor(tu, "f_inline") self.assertEqual(cursor.is_function_inlined(), True) + cursor = get_cursor(tu, "f_noninline") + self.assertEqual(cursor.is_function_inlined(), False) + cursor = get_cursor(tu, "d_noninline") + self.assertEqual(cursor.is_function_inlined(), False) def test_availability(self): tu = get_tu("class A { A(A const&) = delete; };", lang="cpp") From 433df89e286c8c05b4c5efe440a60d25b9fce845 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 22 Oct 2025 17:27:52 -0500 Subject: [PATCH 09/11] Update clang/docs/ReleaseNotes.rst Co-authored-by: Vlad Serebrennikov --- clang/docs/ReleaseNotes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 037c9549d1aab..4479077148226 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -615,7 +615,7 @@ Sanitizers Python Binding Changes ---------------------- -- Exposed ``clang_Cursor_is_function_inlined``. +- Exposed ``clang_Cursor_isFunctionInlined``. - Exposed ``clang_getCursorLanguage`` via ``Cursor.language``. - Add all missing ``CursorKind``s, ``TypeKind``s and ``ExceptionSpecificationKind``s from ``Index.h`` From cfa988ee0f4cd1a037aaf59a8562d52a8c837f8d Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 30 Oct 2025 13:42:21 -0500 Subject: [PATCH 10/11] Update clang/bindings/python/clang/cindex.py Co-authored-by: Vlad Serebrennikov --- clang/bindings/python/clang/cindex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 7c0b26e311f94..ba2a0dbfcab7b 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -4315,7 +4315,7 @@ def set_property(self, property, value): ("clang_Cursor_isAnonymous", [Cursor], bool), ("clang_Cursor_isAnonymousRecordDecl", [Cursor], bool), ("clang_Cursor_isBitField", [Cursor], bool), - ("clang_Cursor_isFunctionInlined", [Cursor], bool), + ("clang_Cursor_isFunctionInlined", [Cursor], c_uint), ("clang_Location_isInSystemHeader", [SourceLocation], bool), ("clang_PrintingPolicy_dispose", [PrintingPolicy]), ("clang_PrintingPolicy_getProperty", [PrintingPolicy, c_int], c_uint), From 77999cecff9fd2f63b2d518922ef8cf971741b81 Mon Sep 17 00:00:00 2001 From: tapplencourt Date: Thu, 30 Oct 2025 18:44:34 +0000 Subject: [PATCH 11/11] put back bool cast --- clang/bindings/python/clang/cindex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index ba2a0dbfcab7b..6226adbc93f76 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -2367,7 +2367,7 @@ def is_function_inlined(self) -> bool: """ Check if the function is inlined. """ - return conf.lib.clang_Cursor_isFunctionInlined(self) # type: ignore [no-any-return] + return bool(conf.lib.clang_Cursor_isFunctionInlined(self)) @cursor_null_guard def has_attrs(self) -> bool: