[cfe-dev] On the preferred use of C++ in the clang source code

Chris Lattner clattner at apple.com
Fri Jan 4 17:34:13 PST 2008


>> It is pretty subjective.  We do use almost all C++ features somewhere
>> in the (greater llvm) code base.  It's really more about making clear
>> and simple code than it is about banning specific language features.
>> Some coding guidelines are available here:
>> http://llvm.org/docs/CodingStandards.html
>>
>> That said, there are two features we don't like:  RTTI and EH.  This
>> is because they violate the "don't pay for it if you don't use it"
>> principle.
>
> Is this violation intrinsic to the concepts and requirements of RTTI
> and/or EH or is this an implementation issue?
>
> I have no personal attachment to RTTI but EH and its associated safety
> guarantees allow me to read, write and reason about code much better.
>
> If these /are/ implementation issues does CLang plan to do better in  
> its
> C++ implementation?

I don't see an obvious way an implementation could fix this.  The  
issue is that vtable-based implementations is that you need to know at  
the point of the vtable emission (often a single .cpp file) whether  
you will be throwing the class or calling typeof on it.  If it is  
possible, you have to emit a bunch of metadata.

In implementations that don't hang the RTTI info off the vtable, you  
could certainly do it, but I'm not aware of any that do this, and we  
have to be compatible with platform ABIs.

-Chris 



More information about the cfe-dev mailing list