[llvm-commits] [llvm] r155761 - /llvm/trunk/include/llvm/Support/type_traits.h

Benjamin Kramer benny.kra at googlemail.com
Sun Apr 29 03:54:51 PDT 2012


On 29.04.2012, at 12:27, John McCall wrote:

> On Apr 28, 2012, at 9:22 AM, Benjamin Kramer wrote:
>> URL: http://llvm.org/viewvc/llvm-project?rev=155761&view=rev
>> Log:
>> If the __is_trivially_copyable type trait is available use it as the baseline for isPodLike.
>> 
>> This way we can enable the POD-like class optimization for a lot more classes,
>> saving ~120k of code in clang/i386/Release+Asserts when selfhosting.
> 
> SmallVector assumes that isPodLike also implies a trivial destructor
> and a valid and trivial copy-assignment operator.  You need to at least
> be checking __has_trivial_destructor;  whether you want to also check
> __is_trivially_assignable or audit and fix all the places that assume
> something about copy assignment is up to you.

>From C++11 [class]p6:
> A trivially copyable class is a class that: […] has a trivial destructor

So __is_trivially_copyable should imply __has_trivial_destructor.

> For example, SmallVector::push_back is now incorrect (and will fail
> to compile) for a class with a reference member.

Hmm, this is an unfortunate requirement of the specialized push_back
for POD-likes. I audited SmallVector and fixed the issue in r155791.

- Ben

> 
> John.





More information about the llvm-commits mailing list