Page MenuHomePhabricator

[analyzer] Support destruction and lifetime-extension of inlined function return values.

Authored by NoQ on Mar 5 2018, 3:41 PM.



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 and addresses most of the concerns from D42876.

Diff Detail

rC Clang

Event Timeline

NoQ created this revision.Mar 5 2018, 3:41 PM

5 closing braces is a lot. What about moving the entire block under CK_Complete into a static function?

NoQ added inline comments.Mar 5 2018, 4:18 PM

I'm already on it for the next patch^^

dcoughlin accepted this revision.Mar 5 2018, 5:12 PM



It might be easier to follow if you started from '0' so that steps here match offsets into buf.

This revision is now accepted and ready to land.Mar 5 2018, 5:12 PM
NoQ updated this revision to Diff 137117.Mar 5 2018, 7:18 PM

Fix test comments and make them start from 0 :) Also rebase.

This revision was automatically updated to reflect the committed changes.