<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Apr 5, 2010, at 3:32 PM, Ted Kremenek wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 30, 2010, at 3:40 PM, Fariborz Jahanian wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">Author: fjahanian<br>Date: Tue Mar 30 17:40:11 2010<br>New Revision: 99951<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=99951&view=rev">http://llvm.org/viewvc/llvm-project?rev=99951&view=rev</a><br>Log:<br>Recognize __attribute__((NSObject)) directly applied<br>on retain properties. (radar 7809468).<br><br>Modified:<br>   cfe/trunk/lib/Sema/Sema.h<br>   cfe/trunk/lib/Sema/SemaObjCProperty.cpp<br>   cfe/trunk/test/SemaObjC/nsobject-attribute.m<br><br></span></blockquote><div><br></div><div><SNIP></div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><br>-void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,<br>+void Sema::CheckObjCPropertyAttributes(DeclPtrTy PropertyPtrTy,<br>                                       SourceLocation Loc,<br>                                       unsigned &Attributes) {<br>  // FIXME: Improve the reported location.<br>+  Decl *PDecl = PropertyPtrTy.getAs<Decl>();<br>+  ObjCPropertyDecl *PropertyDecl = dyn_cast_or_null<ObjCPropertyDecl>(PDecl);<br>+  QualType PropertyTy = PropertyDecl->getType();<span class="Apple-converted-space"> </span></span></blockquote></div><br><div>Hi Fariborz,</div><div><br></div><div>This doesn't quite look right.  On the second line there is 'dyn_cast_or_null' and on the third line PropetyDecl gets dereferenced without checking if it is null.  Is it always the case that 'PDecl' will be both non-null and a ObjCProperyDecl?  If that is the case, we should be using 'cast', not 'dyn_cast'.  If 'PDecl' could be null we should probably check for that up front and then bail out of the method before even doing the cast to ObjCPropetyDecl*.  Otherwise, this looks like a potential crash.</div></div></blockquote><div><br class="webkit-block-placeholder"></div>No it is not right. We should bail out if is it null, or if we do not see an ObjCPropertyDecl   passed down.</div><div>(which is caused by detection of error in property declaration earlier).</div><div><br class="webkit-block-placeholder"></div><div>- fariborz</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Ted</div></div></blockquote></div><br></body></html>