Lack of API 2

There is no API for accessing optional/required properties. The only thing it offers is CXCursor_ObjCPropertyDecl. But in Protocol we can have both optional/required properties. So there is still lack of API.

@protocol protocol1
@optional
@property (readonly) NSString *string1;

@required
@property (readonly) NSString *string2;
@end

We do not have separate ASTs for such things as @optional/@required. Such info is kept in AST for the properties and methods.
Lack of CXCursor for them could be fall out from that.

  • Fariborz

A function could be added to query the optional/required state of the property.

Please either file an enhancement request in bugzilla, or even better, see if you can provide a patch for reviewing.

Implemented in r185724:

/**

  • \brief Given a cursor that represents an ObjC method or property declaration,
  • return non-zero if the declaration was affected by “@optional”.
  • Returns zero if the cursor is not such a declaration or it is “@required”.
    */
    CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);