On Mon, Oct 20, 2008 at 7:15 AM, Zhongxing Xu <[EMAIL PROTECTED]> wrote: > On Mon, Oct 20, 2008 at 2:06 PM, Ted Kremenek <[EMAIL PROTECTED]> wrote: >> Do you think it seems more reasonable for VisitCast to specially handle >> the case of casting an array type to a pointer? One possible solution in >> this case would be to have VisitCast invoke VisitLValue on its subexpression >> when performing such a cast. I'm not certain if this is the right thing to >> do. >> > > After examining the code in CodeGen part of clang, now I think this approach
I don't know much about the analysis code, but you definitely need special handling for casts from an array type to a pointer type; it's not a normal cast. In the following example: int a[10]; int (*p)[10]; a and *p are lvalues. However, they get promoted to pointers in almost all contexts (the exceptions being the operands of sizeof and & operators). That promotion is done by an ImplicitCastExpr. The semantics of the promotion is that it returns the address of the first element of the array. So this kind of cast probably needs to be handled more like an addressof operator rather than a regular cast. You do need to watch out for cases where the ImplicitCastExpr does both a cast and a promotion, though. -Eli _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
