[cfe-dev] __is_empty type trait patch

Eli Friedman eli.friedman at gmail.com
Mon Aug 3 11:32:27 PDT 2009


On Mon, Aug 3, 2009 at 8:21 AM, Anders Carlsson<andersca at mac.com> wrote:
>
> 2 aug 2009 kl. 19.45 skrev Sean Hunt:
>
>> Hello,
>>
>> I'm a new coder hoping to help out with the C++ implementation on
>> clang.
>> After fiddling around with several things I discovered were all being
>> worked on already, someone recommended I implement the __is_empty type
>> trait, so that is what I did. I was told to send a message here now;
>> I've attached a patch.
>
> Nice, welcome! :)
>
>>
>>
>>
>> +  /// Empty - true when this class is empty for traits purposes,
>> i.e. has no
>> +  /// data members other than 0-width bit-fields, has no virtual
>> function/base,
>> +  /// and doesn't inherit from a non-empty class. Doesn't take
>> union-ness into
>> +  /// account.
>> +  bool Empty : 1;
>> +
>
> You don't have to store this - the ASTRecordLayout already stores the
> dataSize so you can just check to see if it's 0.

That doesn't actually work; see http://llvm.org/bugs/show_bug.cgi?id=4673 .

-Eli




More information about the cfe-dev mailing list