Dead store detection automatically checks that an expression is a CXXConstructor and skips it because of potential side effects. In C++17, with guaranteed copy elision, this check can fail because we actually receive the implicit cast of a CXXConstructor.
Most checks in the dead store analysis were already stripping all casts and parenthesis and those that weren't were either forgotten (like the constructor) or would not suffer from it, so this patch proposes to factorize the stripping.
It has an impact on where the dead store warning is reported in the case of an explicit cast, from
auto a = static_cast<B>(A()); ^~~~~~~~~~~~~~~~~~~
to
auto a = static_cast<B>(A()); ^~~
which we think is an improvement.
It looks like this introduces a change in behavior in unrelated situations, eg. the ones in objc-arc.m.plist where the diagnostic is moved to the right:
I think this change is undesirable because it distracts from the assignment. In this case you can easily avoid this problem by using IgnoreParenImpCasts() instead, but it also generally makes sense to have patches that target specific situations to match on these situations more precisely. Eg., could you see if you can add a check that a constructor is involved, and maybe check for the exact cast kind that we want to unwrap?