<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On Oct 17, 2007, at 5:37 PM, Chris Lattner wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Bad cast...need to use dyn_cast_or_null. Also changed Sema::InitBuiltinVaListType (which had the same bug).</DIV> </BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Hi Steve,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Why are these dyn_cast_or_null?<SPAN class="Apple-converted-space">  </SPAN>It seems like none of those cases allow null pointers?</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The second case you forwarded currently needs it (you may be right about the first).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>If I don't use dyn_cast_or_null(), the following case will bus error. With dyn_cast_or_null(), we assert (<FONT class="Apple-style-span" color="#891315" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">missing '@interface NSConstantString').</SPAN></FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>[dylan:~/llvm/tools/clang] admin% cat trivial.m</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>@class NSString;</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>NSString *s = @"123";</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>This is because NSConstantString isn't really built-in - we rely on seeing NSString.h to get the @interface for NSConstantString. This dividing line between the language and library/platform is a little murky (unfortunately, given the adhoc language evolution:-). </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>So...until we have a better solution for how to integrate NSConstantString, I have the conservative dyn_cast_or_null. In practice (with MacOS X/Cocoa), this isn't a problem. It's unlikely developers will bump into this assert.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>snaroff</DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-Chris</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Modified:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>cfe/trunk/Sema/SemaDecl.cpp</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>cfe/trunk/Sema/SemaExpr.cpp</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>cfe/trunk/clang.xcodeproj/project.pbxproj</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Modified: cfe/trunk/Sema/SemaDecl.cpp</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">URL: <A href="http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=43023&r1=43022&r2=43023&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=43023&r1=43022&r2=43023&view=diff</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">==============================================================================</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--- cfe/trunk/Sema/SemaDecl.cpp (original)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+++ cfe/trunk/Sema/SemaDecl.cpp Mon Oct 15 19:00:18 2007</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">@@ -154,7 +154,7 @@</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>IdentifierInfo *VaIdent = &Context.Idents.get("__builtin_va_list");</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>ScopedDecl *VaDecl = LookupScopedDecl(VaIdent, Decl::IDNS_Ordinary,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">                                           </SPAN>SourceLocation(), TUScope);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-<SPAN class="Apple-converted-space">  </SPAN>TypedefDecl *VaTypedef = cast<TypedefDecl>(VaDecl);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>TypedefDecl *VaTypedef = dyn_cast_or_null<TypedefDecl>(VaDecl);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>Context.setBuiltinVaListType(Context.getTypedefType(VaTypedef));</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Modified: cfe/trunk/Sema/SemaExpr.cpp</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">URL: <A href="http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=43023&r1=43022&r2=43023&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=43023&r1=43022&r2=43023&view=diff</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">==============================================================================</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--- cfe/trunk/Sema/SemaExpr.cpp (original)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+++ cfe/trunk/Sema/SemaExpr.cpp Mon Oct 15 19:00:18 2007</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">@@ -1896,9 +1896,9 @@</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">     </SPAN>IdentifierInfo *NSIdent = &Context.Idents.get("NSConstantString");</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">     </SPAN>ScopedDecl *IFace = LookupScopedDecl(NSIdent, Decl::IDNS_Ordinary,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">                                          </SPAN>SourceLocation(), TUScope);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-<SPAN class="Apple-converted-space">    </SPAN>ObjcInterfaceDecl *stringInterface = cast<ObjcInterfaceDecl>(IFace);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-<SPAN class="Apple-converted-space">    </SPAN>assert(stringInterface && "missing '@interface NSConstantString'");</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-<SPAN class="Apple-converted-space">    </SPAN>Context.setObjcConstantStringInterface(stringInterface);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>ObjcInterfaceDecl *strIFace = dyn_cast_or_null<ObjcInterfaceDecl>(IFace);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>assert(strIFace && "missing '@interface NSConstantString'");</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>Context.setObjcConstantStringInterface(strIFace);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>QualType t = Context.getObjcConstantStringInterface();</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>t = Context.getPointerType(t);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Modified: cfe/trunk/clang.xcodeproj/project.pbxproj</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">URL: <A href="http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=43023&r1=43022&r2=43023&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=43023&r1=43022&r2=43023&view=diff</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">==============================================================================</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+++ cfe/trunk/clang.xcodeproj/project.pbxproj Mon Oct 15 19:00:18 2007</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">@@ -742,7 +742,6 @@</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> <SPAN class="Apple-tab-span" style="white-space:pre">     </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN></SPAN>08FB7793FE84155DC02AAC07 /* Project object */ = {</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> <SPAN class="Apple-tab-span" style="white-space:pre">     </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN></SPAN>isa = PBXProject;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> <SPAN class="Apple-tab-span" style="white-space:pre">     </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN></SPAN>buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN>compatibilityVersion = "Xcode 2.4";</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> <SPAN class="Apple-tab-span" style="white-space:pre">      </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN></SPAN>hasScannedForEncodings = 1;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> <SPAN class="Apple-tab-span" style="white-space:pre">   </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN></SPAN>mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> <SPAN class="Apple-tab-span" style="white-space:pre">     </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN></SPAN>projectDirPath = "";</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">cfe-commits mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</A></DIV> </BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> </BLOCKQUOTE></DIV><BR></BODY></HTML>