What does clang::ObjCPropertyDecl::getPropertyAttributes() really gets?

Hi all,

I’m trying to extract all attributes from an ObjCPropertyDecl such as:

@property (strong, nonatomic) NSMutableDictionary* fieldsToBePosted;

So I refered to the clang docs and found the function clang::ObjCPropertyDecl::getPropertyAttributes(), which looks like what I need. Then I wrote a piece of code like this:

clang::ObjCPropertyDecl::PropertyAttributeKind kind = decl->getPropertyAttributes();

cout << kind << endl;

What surprised me is that I got 64 (0x40), which is OBJC_PR_nonatomic. What I expected is OBJC_PR_nonatomic | OBJC_PR_strong a.k.a. 1088(0x440).

Also, as I tried to dump the decl, it looks like this:


ObjCPropertyDecl 0x7fc9ac66c640 </Users/wzpan/Documents/workspace/HelloWorld/HelloWorldViewController.m:14:1, col:52> col:52 fieldsToBePosted 'NSMutableDictionary *' nonatomic

Where has the strong attributes gone? Can anyone please tell me how to get all the attributes? Thanks.

Hi all,

I’m trying to extract all attributes from an ObjCPropertyDecl such as:

@property (strong, nonatomic) NSMutableDictionary* fieldsToBePosted;

So I refered to the clang docs and found the function clang::ObjCPropertyDecl::getPropertyAttributes(), which looks like what I need. Then I wrote a piece of code like this:

clang::ObjCPropertyDecl::PropertyAttributeKind kind = decl->getPropertyAttributes();

cout << kind << endl;

What surprised me is that I got 64 (0x40), which is OBJC_PR_nonatomic. What I expected is OBJC_PR_nonatomic | OBJC_PR_strong a.k.a. 1088(0x440).

Also, as I tried to dump the decl, it looks like this:


ObjCPropertyDecl 0x7fc9ac66c640 </Users/wzpan/Documents/workspace/HelloWorld/HelloWorldViewController.m:14:1, col:52> col:52 fieldsToBePosted 'NSMutableDictionary *' nonatomic

Where has the strong attributes gone? Can anyone please tell me how to get all the attributes? Thanks.

Try: getPropertyAttributesAsWritten

  • Fariborz