Skip to content

Commit 855a3e9

Browse files
[libclang/python] Add isFunctionInlined support (#162882)
`cindex.py` was missing support for [isFunctionInlined](https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga963097b9aecabf5dce7554dff18b061d), this PR add it. --------- Co-authored-by: Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>
1 parent 8761693 commit 855a3e9

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

clang/bindings/python/clang/cindex.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,6 +2362,13 @@ def get_bitfield_width(self) -> int:
23622362
"""
23632363
return conf.lib.clang_getFieldDeclBitWidth(self) # type: ignore [no-any-return]
23642364

2365+
@cursor_null_guard
2366+
def is_function_inlined(self) -> bool:
2367+
"""
2368+
Check if the function is inlined.
2369+
"""
2370+
return bool(conf.lib.clang_Cursor_isFunctionInlined(self))
2371+
23652372
@cursor_null_guard
23662373
def has_attrs(self) -> bool:
23672374
"""
@@ -4310,6 +4317,7 @@ def set_property(self, property, value):
43104317
("clang_Cursor_isAnonymous", [Cursor], bool),
43114318
("clang_Cursor_isAnonymousRecordDecl", [Cursor], bool),
43124319
("clang_Cursor_isBitField", [Cursor], bool),
4320+
("clang_Cursor_isFunctionInlined", [Cursor], c_uint),
43134321
("clang_Location_isInSystemHeader", [SourceLocation], bool),
43144322
("clang_PrintingPolicy_dispose", [PrintingPolicy]),
43154323
("clang_PrintingPolicy_getProperty", [PrintingPolicy, c_int], c_uint),

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,21 @@ def test_storage_class(self):
784784
cursor = get_cursor(tu, "reg")
785785
self.assertEqual(cursor.storage_class, StorageClass.REGISTER)
786786

787+
def test_function_inlined(self):
788+
tu = get_tu(
789+
"""
790+
inline void f_inline(void);
791+
void f_noninline(void);
792+
int d_noninline;
793+
"""
794+
)
795+
cursor = get_cursor(tu, "f_inline")
796+
self.assertEqual(cursor.is_function_inlined(), True)
797+
cursor = get_cursor(tu, "f_noninline")
798+
self.assertEqual(cursor.is_function_inlined(), False)
799+
cursor = get_cursor(tu, "d_noninline")
800+
self.assertEqual(cursor.is_function_inlined(), False)
801+
787802
def test_availability(self):
788803
tu = get_tu("class A { A(A const&) = delete; };", lang="cpp")
789804

clang/docs/ReleaseNotes.rst

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

660660
Python Binding Changes
661661
----------------------
662+
- Exposed ``clang_Cursor_isFunctionInlined``.
662663
- Exposed ``clang_getCursorLanguage`` via ``Cursor.language``.
663664
- Add all missing ``CursorKind``s, ``TypeKind``s and
664665
``ExceptionSpecificationKind``s from ``Index.h``

0 commit comments

Comments
 (0)