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.
Please declare a lambda to add a cleanup which implicitly creates this dominator and then just call it in the places that currently directly do cleanups.push_back.