libclang python underlying_typedef_type does not match docstring
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
https://github.com/llvm/llvm-project/blob/e3d3b3b0cf3672480d6f781a9726cec1e7983d14/clang/bindings/python/clang/cindex.py#L2111
`clang.cindex.Cursor.underlying_typedef_type` is documented to raise an exception if the cursor is not actually a typedef. But the assertion in the code is only that the cursor is a declaration. This method could be called for a Cursor of `STRUCT_DECL` type, and the returned type would be `TypeKind.INVALID` and have an empty string for the spelling.
I think the fix should be as simple as changing the assert to `assert self.kind == CursorKind.TYPEDEF_DECL`, but there may be something I am missing.
Contributor guide
Research direction
Start at clang/bindings/python/clang/cindex.py around line 2111 and read Cursor.underlying_typedef_type alongside its docstring. Reproduce the behavior with a STRUCT_DECL cursor, then verify that non-typedef cursors raise the documented exception while typedef cursors still return their underlying type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100