[PATCH] D70172: [CUDA][HIP] Fix assertion due to dtor check on windows

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 8 00:05:26 PST 2020


rjmccall added a comment.

I thought you were saying that the destructor decl hadn't been created yet, but I see now that you're saying something more subtle.

`CurContext` is set to the destructor because the standard says in [class.dtor]p13:

  At the point of definition of a virtual destructor (including an implicit definition), the non-array deallocation function is determined as if for the expression `delete this` appearing in a non-virtual destructor of the destructor’s class.

Which is to say that, semantically, the context is as if it were within the destructor, to the extent that this affects access control and so on.

I can see why this causes problems for your call graph (really a use graph), since it's a use in the apparent context of the destructor at a point where the destructor is not being defined.  A similar thing happens with default arguments, but because we don't consider uses from default arguments to be true ODR-uses until the default argument is used, that probably doesn't cause problems for you.

I don't think the destructor -> deallocation function edge is actually interesting for your use graph.  It'd be more appropriate to treat the deallocation function as used by the v-table than by the destructor; I don't know whether you make any attempt to model v-tables as nodes in your use graph.  You might consider finding a simple way to suppress adding this edge, like just not adding edges from a destructor that's not currently being defined (`D->willHaveBody()`).

With all that said, maintaining a use graph for all the functions you might emit in the entire translation unit seems very expensive and brittle.  Have you considered doing this walk in a final pass?   You could just build up a set of all the functions you know you're going to emit and then walk their bodies looking for uses of lazy-emitted entities.  If we don't already have a function that calls a callback for every declaration ODR-used by a function body, we should.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70172/new/

https://reviews.llvm.org/D70172





More information about the cfe-commits mailing list