<div>The items-property gets synthesized within the implementation. But i just realized<br></div><div>that i missed two details within my example, those are</div><div>1. Foo implements a protocol with a method, call it bar</div>
<div>2. the access to the items happen inside the implementation of bar</div><div>Is it possible that clang doesn't resolve the ObjCIvar as it isn't a method that got</div><div>declared within the interface or something like that?</div>
<div><br></div><div>I'll take a look into Sema::ActOnPropertyImplDecl - thank you so far.</div><br><div class="gmail_quote">2011/3/16 Fariborz Jahanian <span dir="ltr"><<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">It only sets it for synthesized ivars. Look at Sema::ActOnPropertyImplDecl for details. You can follow<br>
the same logic for looking up the ivar;  starting at if (Synthesize) {...}<br>
<br>
- Fariborz<br>
<div><div class="h5"><br>
On Mar 16, 2011, at 8:49 AM, Hendrik vP wrote:<br>
<br>
> I'm experimenting with clang to do some analyzes and inspections on<br>
> Objective-C-code, or, to be more precise, iPhone-Code.<br>
> Currently, I'm trying to 'guess' the inner-types of enumeratable types, especially for<br>
> NSArrays. For this, I set up a RecursiveASTVisitor and collect all of the variables<br>
> that I am interested in (ObjCIVar, VarDecl, ParmVarDecl). Also, I'm looking into<br>
> statements and declarations where those variables get used. I already got it to<br>
> guess some inner-types by inspecting ObjCForCollection-statments, which is<br>
> fine.<br>
> Now, I'm doing some specializations for NSMutableArray inside my visitor to get<br>
> some hints from statements like<br>
> [<NSMutableArray> addObject:<variable X>]<br>
> so i can build a relationship between the type of variable X and the inner-type of<br>
> the array. This already works for local declared arrays, but not for ObjCIvars.<br>
> For the moment, I'm stuck with an expression that looks like<br>
> [self.items addObject:item]<br>
> where items is declared as<br>
><br>
><br>
> @interface Foo : NSObject {<br>
> @private<br>
>   NSMutableArray *items;<br>
> }<br>
> @property(retain) NSMutableArray *items;<br>
> @end<br>
><br>
> @implementation Foo<br>
> @synthesize items;<br>
> @end<br>
><br>
><br>
> So, I'm diving into the ObjCMessageExpression and try to get the ObjCIvarDecl.<br>
> For this, I'm catching the instance-receiver, which is a ImplicitCastExpr, get it's<br>
> subExpr and cast it to the ObjCPropertyRefExpr that it is. On this, I'm calling<br>
> getExplicitProperty() and receiving the ObjCPropertyDecl.<br>
><br>
> And here's the point that confuses me: when I try to get the ObjCIvarDecl by<br>
> calling getPropertyIvarDecl on the ObjCPropertyDecl, I'm receiving a nullpointer.<br>
><br>
> The header of Foo is included and also my compilerinstance reports no errors,<br>
> so i think the configuration of the project itself should be correct. Am I<br>
> misunderstanding the concept/functionality of the methods I'm using - or is it<br>
> maybe a bug inside clang, that it doesn't set the ObjCIvarDecl properly for<br>
> every ObjCProperetyDecl?<br>
> svn log says that I am using r127573.<br>
><br>
> Thanks,<br>
> Hendrik<br>
</div></div>> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote></div><br>