With D44120 we can find the CXXBindTemporaryExpr and MaterializeTemporaryExpr that correspond to the temporary object that is being returned from a function into its caller. These expressions are on the caller side because it is the caller that's responsible for managing the lifetime of such temporary.
In order to find those expressions, we look at the call site's CFG element, notice that it is a CFGValueTypedCall that was added in D44120, and take the relevant construction context information from there.
This patch does not yet affect temporaries that were returned from conservatively evaluated functions.
The idea was initially described in the last part of http://lists.llvm.org/pipermail/cfe-dev/2018-February/056898.html and addresses most of the concerns from D42876.
5 closing braces is a lot. What about moving the entire block under CK_Complete into a static function?