[clang] [libclang/python] Add isFunctionInlined support (PR #162882)

Thomas Applencourt via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 14 08:31:12 PDT 2025


https://github.com/TApplencourt updated https://github.com/llvm/llvm-project/pull/162882

>From 674bdfb5d0160bf637cce069fdf03c465c81b287 Mon Sep 17 00:00:00 2001
From: tapplencourt <tapplencourt at anl.gov>
Date: Fri, 10 Oct 2025 16:39:51 +0000
Subject: [PATCH 1/5] 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 <tapplencourt at anl.gov>
Date: Fri, 10 Oct 2025 16:39:51 +0000
Subject: [PATCH 2/5] 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 <tapplencourt at anl.gov>
Date: Tue, 14 Oct 2025 15:26:11 +0000
Subject: [PATCH 3/5] 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 <tapplencourt at anl.gov>
Date: Tue, 14 Oct 2025 15:26:49 +0000
Subject: [PATCH 4/5] 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 <tapplencourt at anl.gov>
Date: Tue, 14 Oct 2025 15:30:58 +0000
Subject: [PATCH 5/5] 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``



More information about the cfe-commits mailing list