]> granicus.if.org Git - clang/commit
CodeGen: ensure placeholder instruction for cleanup is created
authorSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 25 Jul 2019 17:59:29 +0000 (17:59 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 25 Jul 2019 17:59:29 +0000 (17:59 +0000)
commitc0048be7ff340ebba3092e95d82147bc9928b909
tree4eec583095ac609c25dd0abfa232e7c674624485
parent07d5b4a5da63a6e1602d04fee0eabcae3871b2f2
CodeGen: ensure placeholder instruction for cleanup is created

A placeholder instruction for use in generation of cleanup code for an
initializer list would not be emitted if the base class contained a
non-trivial destructor and the class contains no fields of its own. This
would be the case when using CTAD to deduce the template arguments for a
struct with an overloaded call operator, e.g.

```
template <class... Ts> struct ctad : Ts... {};
template <class... Ts> ctad(Ts...)->ctad<Ts...>;
```

and this class was initialized with a list of lambdas capturing by copy,
e.g.

```
ctad c {[s](short){}, [s](long){}};
```

In a release build the bug would manifest itself as a crash in the SROA
pass, however, in a debug build the following assert in CGCleanup.cpp
would fail:

```
assert(dominatingIP && "no existing variable and no dominating IP!");
```

By ensuring that a placeholder instruction is emitted even if there's no
fields in the class, neither the assert nor the crash is reproducible.

See https://bugs.llvm.org/show_bug.cgi?id=40771

Patch by Ã˜ystein Dale!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367042 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExprAgg.cpp
test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp [new file with mode: 0644]