[cfe-commits] r61746 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Parse/ lib/AST/ lib/Parse/ lib/Sema/ test/SemaCXX/
Chris Lattner
clattner at apple.com
Mon Jan 5 20:49:02 PST 2009
On Jan 5, 2009, at 8:10 PM, Douglas Gregor wrote:
>> Doing this comparison with types seems awkward, can you just do
>> something like:
>>
>> if (const RecordType *RT = ArgType->getAsRecordType())
>> if (RT->getDecl() == this) ...
>>
>> instead? likewise in hasConstCopyAssignment.
>
> That won't work, since there can be multiple RecordDecls for a given
> record type.
Is there a similar mechanism that will work?
>>> + if (getLangOptions().CPlusPlus) {
>>> CheckExtraCXXDefaultArguments(D);
>>> + if (!T->isPODType())
>>> + cast<CXXRecordDecl>(Record)->setPOD(false);
>>
>> I see that you basically clear the 'ispod' bit whenever something is
>> parsed that prevents a class from being a POD. Would it be better to
>> make it a predicate that walks the member list to determine podness?
>> The advantage of doing this is that it would put all the "podness"
>> checks together into one method instead of scattered throughout sema.
>> What do you think?
>
> Most declarations of a class type will need to perform the check for
> a POD type, which is recursive (it's only a POD if all of its non-
> static data members are PODs, and so on), so it might be expensive
> to compute this property on the fly. Personally, I prefer the way
> Sebastian's doing it: there will be quite a few other class
> properties like this, too.
What if the query is lazy but cached? Many types are defined in
headers that are never used, I can't believe that we'd end up querying
isPod for all of them...
>> Would it be possible to synthesize these lazily
>> like G++ does?
>
>
> Yes, but let's implement the semantics of these operations first, so
> that we have known, working regression tests when we go and optimize
> away these implicitly-declared special member functions.
Ok, that is fair enough. Would it make sense to add a README file or
something for notes on C++ optimization opportunities?
-Chris
More information about the cfe-commits
mailing list