This is an archive of the discontinued LLVM Phabricator instance.

[CFG] [analyzer] Don't treat argument constructors as temporary constructors.
ClosedPublic

Authored by NoQ on Apr 13 2018, 8:12 PM.

Details

Summary

Function argument constructors (that are used for passing objects into functions by value) are completely unlike temporary object constructors, but we were treating them as such because they are also wrapped into a CXXBindTemporaryExpr.

This patch adds a partial construction context layer for call argument values, but doesn't proceed to transform it into an actual construction context yet. This is tells the clients that we aren't supporting these constructors yet.

A lesson to learn here is that construction contexts aren't as safe as i originally expected - even though they work by pattern-matching small specific AST patterns.

Diff Detail

Event Timeline

NoQ created this revision.Apr 13 2018, 8:12 PM
NoQ updated this revision to Diff 142505.Apr 13 2018, 8:20 PM

Add tests where the argument is passed by reference. These tests work correctly (i.e. they correctly identify the argument constructor as a temporary constructor) because such constructors would include a MaterializeTemporaryExpr that is not allowed in the middle of the partial construction context. For the same reason remove the defensive check in the branch of ConstructionContext::createFromLayers that deals with MaterializeTemporaryExpr-based layers.

This revision was not accepted when it landed; it landed in state Needs Review.Apr 19 2018, 4:12 PM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.
chh added a subscriber: chh.Jun 18 2018, 9:35 AM