Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions clang/bindings/python/clang/cindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2362,6 +2362,13 @@ 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.
"""
return conf.lib.clang_Cursor_isFunctionInlined(self) # type: ignore [no-any-return]

@cursor_null_guard
def has_attrs(self) -> bool:
"""
Expand Down Expand Up @@ -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], bool),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
("clang_Cursor_isFunctionInlined", [Cursor], bool),
("clang_Cursor_isFunctionInlined", [Cursor], c_uint),

Answering the question from the PR description, c_uint reflects C function signature. I took a look at ctypes implementation, but I'm still not sure how bool is handled. If it's https://github.com/python/cpython/blob/b3a38438d83245e52dff80f348c7fde539333cea/Modules/_ctypes/cfield.c#L713, then I'm not particularly happy about unsigned read as wider long long.

("clang_Location_isInSystemHeader", [SourceLocation], bool),
("clang_PrintingPolicy_dispose", [PrintingPolicy]),
("clang_PrintingPolicy_getProperty", [PrintingPolicy, c_int], c_uint),
Expand Down
15 changes: 15 additions & 0 deletions clang/bindings/python/tests/cindex/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,21 @@ 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 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")

Expand Down
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ Sanitizers

Python Binding Changes
----------------------
- Exposed ``clang_Cursor_is_function_inlined``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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``
Expand Down