Now with the patch actually attached.

On 5 November 2013 00:33, Rafael Espíndola <rafael.espind...@gmail.com> wrote:
>>> What happens is that at the end of GetOrCreateLLVMFunction we check if
>>> we have a decl defined in class and if so add it to
>>> DeferredDeclsToEmit. The net result is that we end up running
>>> replaceAllUsesWith twice when something in DeferredDeclsToEmit causes
>>> a new use of the destructor/constructor.
>>>
>>> Do you think this is OK? If not I can add a list of "DeclsToReplace"
>>> to Codegen and process that after EmitDeferred.
>>
>>
>> Ah, that makes sense.  Sounds fine, if a little bit silly.
>
> You were right. The example I tried worked because there was a call to
> GetOrCreateLLVMFunction before every try to emit the decl, so we would
> recreate the declaration before trying to emit it in EmitDeferred.
>
> With
>
> struct Option {
>   virtual ~Option() {}
> };
> template <class DataType> class opt : public Option {};
> template class opt<int>;
> bool handleOccurrence() {
>   Option x;
>   return true;
> }
>
> the template instantiation will not cause a declaration to be created
> and we assert when trying to replace the value the second time.
>
> The attached patch fixes this by doing all replacements after the
> deferred decls have been emitted. With this approach it should then be
> easy to also handle
>
> class foo {
>   ~foo();
> }
> class bar : public foo {
> }
>
> i.e., when we know a function is equal to one we don't have a definition for.
>
> Cheers,
> Rafael

Attachment: t.patch
Description: Binary data

_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to