Fixes assertion
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file llvm/Support/Casting.h, line 255.
It was triggered by trying to cast FunctionDecl to CXXMethodDecl as
CGF.CurCodeDecl in CallBaseDtor::Emit. It was happening because
cleanups were emitted in ScalarExprEmitter::VisitExprWithCleanups
after destroying InlinedInheritingConstructorScope, so
CodeGenFunction.CurCodeDecl didn't correspond to expected cleanup decl.
Fix the assertion by emitting cleanups before leaving
InlinedInheritingConstructorScope and changing CurCodeDecl.
rdar://problem/45805151
To test what I'd like to see, this needs to take Strong by value, not by reference. There won't be a cleanup for the inlined parameter if it's taken by reference.