Expose atomic type through the C API.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hi,
We use libclang in OpenJDK project Panama for a tool, jextract, to read C header files and generate Java bindings. It's critical for us to be able get the "real" underlying type.
Currently type like _Atomic(int) are not exposed, and libclang will give us a type kind of CXType_Unexposed, and we need a way to get the value type of CXType_Int .
Is there an existing way to do that? I have tried to call clang_getCanonicalType on the unexposed type, but that return the same unexposed type.
Please let me know if the proposed patch is on the right track or not, I would appreciate guidance to get this issue solved.
Would like to try to draw attention to this patch again, since it seems to have gone under the radar. Can someone review this/help get it integrated? We are still having to work around _Atomic types because we can't get to the underlying value type. Thanks
I'm sorry about the delay in review, this did fall off my radar. Thank you for bringing it to my attention!
Looks mostly good to me, just a few small nits.
clang/include/clang-c/Index.h | ||
---|---|---|
3953 | Missing a full stop at the end of the comment. | |
clang/tools/c-index-test/c-index-test.c | ||
1585 | Should elide braces here. | |
clang/tools/libclang/CXType.cpp | ||
1326–1329 | I would probably rewrite this function to: QualType T = GetQualType(CT); if (T.isNull() || !T->isAtomicType()) return MakeCXType(QualType(), GetTU(CT)); const auto *AT = T->castAs<AtomicType>(); return MakeCXType(AT->getValueType(), GetTU(CT)); |
I've commit on your behalf in 38ca7b11db2d22e0fdfbff3f19276f9796f747d3, thank you for the patch!
Missing a full stop at the end of the comment.