[cfe-commits] r61746 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Parse/ lib/AST/ lib/Parse/ lib/Sema/ test/SemaCXX/
Douglas Gregor
dgregor at apple.com
Mon Jan 5 22:26:16 PST 2009
On Jan 5, 2009, at 8:49 PM, Chris Lattner wrote:
> 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?
Use Context.getTypeDeclType to get at the RecordType corresponding to
the RecordDecl, then compare the canonical types :)
We don't currently have an easier way to map from a RecordDecl to the
"canonical" RecordDecl known to the RecordType.
>
>>>> + 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...
We could certainly make the query lazy but cached, but why? The most
expensive check needed to maintain this flag is "if (!T->isPODType())".
>
>>> 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?
That's a good idea.
- Doug
More information about the cfe-commits
mailing list