<div>I'm experimenting with clang to do some analyzes and inspections on </div><div>Objective-C-code, or, to be more precise, iPhone-Code.</div><div>Currently, I'm trying to 'guess' the inner-types of enumeratable types, especially for<br>
</div><div>NSArrays. For this, I set up a RecursiveASTVisitor and collect all of the variables</div><div>that I am interested in (ObjCIVar, VarDecl, ParmVarDecl). Also, I'm looking into</div><div>statements and declarations where those variables get used. I already got it to</div>
<div>guess some inner-types by inspecting ObjCForCollection-statments, which is </div><div>fine.</div><div>Now, I'm doing some specializations for NSMutableArray inside my visitor to get </div><div>some hints from statements like</div>
<div>[<NSMutableArray> addObject:<variable X>]</div><div>so i can build a relationship between the type of variable X and the inner-type of</div><div>the array. This already works for local declared arrays, but not for ObjCIvars.</div>
<div>For the moment, I'm stuck with an expression that looks like</div><div>[self.items addObject:item]</div><div>where items is declared as</div><div><br></div><div><br></div><div>@interface Foo : NSObject {</div><div>
@private</div><div>  NSMutableArray *items;</div><div>}</div><div>@property(retain) NSMutableArray *items;
</div><div>@end </div><div><br></div><div>@implementation Foo  </div><div>@synthesize items;</div><div>@end</div><div><br></div><div><br></div><div>So, I'm diving into the ObjCMessageExpression and try to get the ObjCIvarDecl.</div>
<div>For this, I'm catching the instance-receiver, which is a ImplicitCastExpr, get it's</div><div>subExpr and cast it to the ObjCPropertyRefExpr that it is. On this, I'm calling</div><div>getExplicitProperty() and receiving the ObjCPropertyDecl.</div>
<div><br></div><div>And here's the point that confuses me: when I try to get the ObjCIvarDecl by</div><div>calling getPropertyIvarDecl on the ObjCPropertyDecl, I'm receiving a nullpointer.</div><div><br></div><div>
The header of Foo is included and also my compilerinstance reports no errors,</div><div>so i think the configuration of the project itself should be correct. Am I </div><div>misunderstanding the concept/functionality of the methods I'm using - or is it</div>
<div>maybe a bug inside clang, that it doesn't set the ObjCIvarDecl properly for</div><div>every ObjCProperetyDecl?</div><div>svn log says that I am using r127573.</div><div><br></div><div>Thanks,</div><div>Hendrik</div>