[PATCH] D44536: Avoid segfault when destructor is not yet known

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 28 17:09:20 PDT 2018


ahatanak added a comment.

In https://reviews.llvm.org/D44536#1039428, @rjmccall wrote:

> Hmm.  Sema is lazy about actually creating implicit destructor declarations, but it's supposed to only do it whenever the destructor is actually used for something.


I'm looking at a similar problem where clang crashes in IRGen because the destructor of a class hasn't been added to the AST.

I'm not sure why Sema has to add the declaration lazily on demand rather than always adding it after the class definition has been parsed, for example. Could you explain the reason for this behavior? Does doing so break something or cause mis-compile?

It seems that DeclareImplicitDestructor should be called somewhere, but it's not clear to me where it should be called. Calling it at the end of Sema::CheckCompletedCXXClass fixes the crash I'm seeing, but that doesn't seem to be the right fix.


Repository:
  rC Clang

https://reviews.llvm.org/D44536





More information about the cfe-commits mailing list