[cfe-commits] PR12204 PATCH: static_cast to Base class overrides the Derived class field.

John McCall rjmccall at apple.com
Wed Mar 28 16:36:30 PDT 2012


On Mar 28, 2012, at 12:03 PM, John McCall wrote:
> On Mar 28, 2012, at 11:50 AM, Richard Smith wrote:
>> On Wed, Mar 28, 2012 at 11:33 AM, Stepan Dyatkovskiy <stpworld at narod.ru> wrote:
>> Hello John.
>> I attached reworked patch.
>> I couldn't found in CXXRecordDecl methods like "isFinal", but I know only 2 ways to make class final in C++:
>> 
>> 1. Make dtor private (will work only with dynamic allocation):
>> 
>> class Final {
>> ~Final() {}
>> public:
>>  Final* create() { return new Final(); }
>> };
>> 
>> 2. Make dtor and ctor private, and create friend-child using virtual inharitance:
>> 
>> class Finalizer {
>> Final() {}
>> ~Final() {}
>> friend class Final;
>> };
>> 
>> class Final : virtual public Finalizer {
>> };
>> 
>> As I found, second way in clang doesn't use EmitAggregateCopy for assignment "Final = Final", so I wrote the check for first case only.
>> 
>> In case 1, Final can still be derived from in friends and members of the class. In case 2, it can still be derived from in friends and members of Finalizer, and in members of Final. John is referring to the C++11 'final' feature:
>> 
>> class Final final {
>> };
>> 
>> You can check for this with Record->hasAttr<FinalAttr>().
> 
> Exactly.  I'm just going to rewrite the patch, though.

Rewritten and committed as r153613.

John.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120328/abc3d10f/attachment.html>


More information about the cfe-commits mailing list