[cfe-commits] r43023 - in /cfe/trunk: Sema/SemaDecl.cpp Sema/SemaExpr.cpp clang.xcodeproj/project.pbxproj

Steve Naroff snaroff at apple.com
Thu Oct 18 11:17:30 PDT 2007


On Oct 18, 2007, at 10:04 AM, Chris Lattner wrote:
>
>> If I don't use dyn_cast_or_null(), the following case will bus  
>> error. With dyn_cast_or_null(), we assert (missing '@interface  
>> NSConstantString').
>
> I don't see how this is any better: you're trading one crash for  
> another.

If that's true, then why use asserts at all? From my perspective, we  
use them because they are helpful during development. Since clang is  
under active development, I think there is a big difference between  
an assert crash and a bus error. For me, an assert often has an  
implied "FIXME"...

> If you did a check and gracefully handled the problem that would be  
> different.
>
> Remember that it should be impossible to trigger asserts.  It seems  
> like this should turn into a real check with error recovery.
>

Understood. As I said in my previous email, the assert is in place  
"until we have a better solution to how to integrate  
NSConstantString". If you'd like me to make this a priority, then I  
can do so. For now, I'd much prefer to simply add an explicit FIXME  
to the code. It's your call...

> The third:
>
>>>> +    ObjcInterfaceDecl *strIFace =  
>>>> dyn_cast_or_null<ObjcInterfaceDecl>(IFace);
>>>> +    assert(strIFace && "missing '@interface NSConstantString'");
>>>> +    Context.setObjcConstantStringInterface(strIFace);
>>>>    }
>
> Likewise, using cast<> is more efficient in a non-assert build and  
> is less code.
>

I'll try and improve my casting etiquette:-) I have to admit, there  
are so many different types of casts (between C++ and llvm) that I  
don't always take the time to evaluate the best fit. My bad.

snaroff

> -Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20071018/15873c36/attachment.html>


More information about the cfe-commits mailing list