This is an archive of the discontinued LLVM Phabricator instance.

[libclang 1/8] Add support for ObjCObjectType
ClosedPublic

Authored by michaelwu on Jul 9 2018, 12:49 AM.

Details

Summary

This patch adds support to the clang-c API for identifying ObjCObjects in CXTypes, enumerating type args and protocols on ObjCObjectTypes, and retrieving the base type of ObjCObjectTypes. Currently only ObjCInterfaceTypes are exposed, which do not have type args or protocols.

Diff Detail

Repository
rL LLVM

Event Timeline

michaelwu created this revision.Jul 9 2018, 12:49 AM
michaelwu updated this revision to Diff 154540.Jul 9 2018, 1:01 AM

Replaced tabs with spaces.

yvvan added inline comments.Jul 11 2018, 11:16 PM
include/clang-c/Index.h
35 ↗(On Diff #154540)

Please, increment the minor version (you are adding new functions)

3644 ↗(On Diff #154540)

Other similar calls usually return unsigned int because they can't be below zero.

3659 ↗(On Diff #154540)

same about return type

tools/libclang/CXType.cpp
1118 ↗(On Diff #154540)

there's no reason to return -1 since in your code you check that the result is greater than 0.
Return 0 instead (this is also related to the comment about making it unsigned)

michaelwu added inline comments.Jul 12 2018, 8:30 AM
include/clang-c/Index.h
35 ↗(On Diff #154540)

This is one in a series of patches that add features to libclang - would you be ok with incrementing at the end of the series?

3644 ↗(On Diff #154540)

I was mimicking clang_Type_getNumTemplateArguments for this, which appears to be the most similar API. It uses 0 to n for the number of template arguments and -1 to indicate that it was called on the wrong type. If you're ok with the inconsistency, I'll make this unsigned. I also prefer having this unsigned.

michaelwu retitled this revision from [libclang] Add support for ObjCObjectType to [libclang 1/8] Add support for ObjCObjectType.Jul 21 2018, 11:12 AM
michaelwu updated this revision to Diff 156692.Jul 21 2018, 3:20 PM

clang_Type_getNumObjCTypeArgs and clang_Type_getNumObjCProtocolRefs now return unsigned.

I've bumped CINDEX_VERSION_MINOR in D49635 , which is the last in this patch series.

michaelwu marked 3 inline comments as done.Jul 21 2018, 3:21 PM

I'm mostly fine with your set of patches. Let me double check and we can get it in.

yvvan accepted this revision.Jul 31 2018, 6:02 AM
This revision is now accepted and ready to land.Jul 31 2018, 6:02 AM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.