This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] An attempt to fix pr19539 - crashes on temporaries life-extended via members
ClosedPublic

Authored by NoQ on Nov 17 2016, 11:29 PM.

Details

Summary
  1. Re-use approach used in codegen. MaterializeTemporaryExpr may be positioned in a strange manner, above the member access to the temporary, which makes it a bit tricky to find the expression that actually corresponds to the temporary object. FIXME: Hmm, probably we should re-use this approach in CFG as well (cf. D22419).
  2. Create the temporary region that corresponds to the full temporary object, rather than to the sub-object. This was a bug.
  3. If lifetime extension occurs, use the temporary object region's path-sensitive type, rather than reference variable type, in order to call the correct destructor.

Diff Detail

Event Timeline

NoQ updated this revision to Diff 78476.Nov 17 2016, 11:29 PM
NoQ retitled this revision from to [analyzer] An attempt to fix pr19539 - crashes on temporaries life-extended via members.
NoQ updated this object.
NoQ added subscribers: nandor, cfe-commits.
NoQ added a subscriber: alexfh.Nov 17 2016, 11:33 PM
alexander-shaposhnikov added inline comments.
test/Analysis/lifetime-extension.cpp
12

what is the role of S in this test ?

NoQ updated this revision to Diff 78478.Nov 18 2016, 12:22 AM
NoQ marked an inline comment as done.
NoQ added inline comments.
test/Analysis/lifetime-extension.cpp
12

I copy-pasted this from the original bug report. The only purpose of S is to provide a non-trivial destructor. I also thought it'd be a nice twist to the test to make the destructor non-obvious, but it doesn't really matter. Removed.

dcoughlin accepted this revision.Nov 28 2016, 4:44 PM
dcoughlin edited edge metadata.

This is great!

lib/StaticAnalyzer/Core/ExprEngine.cpp
226–229

I think it would good to show an AST representation in the comment to make it clear what "out of place" means. This could be a very simplified version of the dumped AST for a temporary with a field access.

This revision is now accepted and ready to land.Nov 28 2016, 4:44 PM
NoQ updated this revision to Diff 79540.Nov 29 2016, 4:35 AM
NoQ edited edge metadata.
NoQ marked an inline comment as done.

Update the comment.

This revision was automatically updated to reflect the committed changes.