[PATCH] D44619: [CodeGen] Add cleanup scope to EmitInlinedInheritingCXXConstructorCall

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 3 20:41:33 PDT 2018


smeenai added a comment.

Finally got a chance to dig into some of the failures this patch is causing. Here's an example crasher (run with `clang -cc1 -triple i686-windows -emit-llvm`):

  struct Q {
    Q(int);
    ~Q();
  };
  struct Z {};
  struct A {
    A(Q);
  };
  struct B : Z, A {
    using A::A;
  };
  B b(Q(1));

What's happening here is that we emit the inlined inherited constructor call (B's `using A::A`), which in turn emits the constructor call (`A::A`), which eventually winds up in CodeGenFunction::EmitCall, which calls deactivateArgCleanupsBeforeCall, which cleans the cleanup stack. However, the RunCleanupsScope that I added thinks it has cleanups to do, because the EHStack's stable_begin iterator holds a different (empty) value at its destruction than it did at its construction. Of course, the cleanup stack is actually empty at this point, so attempting to run cleanups just asserts.

I guess what I want is for my added scope to only apply to the cleanups added for base destructor calls (since any cleanups for arguments will be handled by deactivateArgCleanupsBeforeCall), but I'm not sure how best to accomplish that.

CodeGenFunction::EmitConstructorBody also wraps a RunCleanupsScope around its EmitCtorPrologue call, so in theory it should be affected by the same problem. I'll try to craft a test.


Repository:
  rC Clang

https://reviews.llvm.org/D44619





More information about the cfe-commits mailing list