[cfe-commits] r90283 - in /cfe/trunk: lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExprCXX.cpp test/CodeGenCXX/virtual-destructor-synthesis.cpp

Anders Carlsson andersca at mac.com
Tue Dec 1 19:50:26 PST 2009


>>> 
>>> What if there isn't any valid delete operator?  I'm not entirely sure
>>> off the top of my head how that would happen, but I think it's
>>> possible.  We don't print a diagnostic, and there isn't a delete
>>> operator, so we're back to crashing.
>> 
>> I thought about this too. I think this will not happen. If we have a
>> declaration which eventually requires
>> the delete operator for its destruction, the CheckDestructor is called and
>>  operator delete will
>> be looked up. Except that this time a diagnostic will be issued.
> 
> If it's in the vtable, the destructor might be called, even if the
> call isn't obvious.  That isn't really the issue here anyway, though:
> the issue is that it would crash trying to generate the destructor,
> whether or not it's actually called.
> 

Incidentally, I'm working on a fix for this :) Basically, when we emit a function definition, we check if it's the key function (where the vtable should be emitted). 

If it is the key function, indicating that this is where the vtable will be emitted by codegen, then we mark all the implicit virtual declarations (the dtor, and maybe the assignment operator?) as referenced. 

If the record decl does not have a key method, we mark the virtual declarations when we encounter the constructor instead, because that's where the vtable will be first used.

Anders

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


More information about the cfe-commits mailing list