[cfe-commits] r120722 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp test/CodeGenCXX/value-init.cpp

Chris Lattner clattner at apple.com
Thu Dec 2 14:54:50 PST 2010


On Dec 2, 2010, at 10:44 AM, Douglas Gregor wrote:

>> 
>> +  // InitListExprs for structs have to be handled carefully.  If there are
>> +  // reference members, we need to consider the size of the reference, not the
>> +  // referencee.  InitListExprs for unions and arrays can't have references.
>> +  if (!E->getType()->isUnionType() && !E->getType()->isArrayType()) {
>> +    RecordDecl *SD = E->getType()->getAs<RecordType>()->getDecl();
>> +    uint64_t NumNonZeroBytes = 0;
> 
> While I know that "if it's not a union or an array, it's a struct" holds for aggregates, it feels needlessly indirect. How about:
> 
> 	if (const RecordType *Record = E->getType()->getAs<RecordType>()) {
> 		if (!Record->getDecl()->isUnion()) {
> 		}
> 	}
> 
> ?
> 
> It's also more efficient ;)

Works for me, one in r120746.  I did it that way to reduce indentation, but it doesn't matter much and I agree with you that your formulation is clearer.  Thanks for the review!

-Chris



More information about the cfe-commits mailing list