This is an archive of the discontinued LLVM Phabricator instance.

[CFG] [analyzer] Fix a crash on finding construction context for an lvalue/xvalue call expression.
ClosedPublic

Authored by NoQ on Mar 8 2018, 1:47 PM.

Details

Summary

The type of the call expression and the return value type of the function are not necessarily the same thing. In the attached example, the function is declared to return const C &, but the actual call-expression has type const C and is also an lvalue. Which is, well, kinda the same thing, but needs a different sort of boilerplate.

Previously we tried to find construction context for such call-expression and became surprised that this is not a temporary object context. Fix the crash by making sure that the call-expression is not an lvalue before trying to attach a construction context to it.

Diff Detail

Repository
rC Clang

Event Timeline

NoQ created this revision.Mar 8 2018, 1:47 PM
NoQ updated this revision to Diff 137661.Mar 8 2018, 3:15 PM

Same goes for rvalue references. Hmm, we have a fancy helper method for that exact purpose. But it's not super easy to use, had to sacrifice a sanity check assertion to use it.

NoQ updated this revision to Diff 137662.Mar 8 2018, 3:16 PM

Fix typo in the comments.

NoQ retitled this revision from [CFG] [analyzer] Fix a crash on finding construction context for an lvalue call expression. to [CFG] [analyzer] Fix a crash on finding construction context for an lvalue/xvalue call expression..Mar 8 2018, 3:18 PM
NoQ updated this revision to Diff 137675.Mar 8 2018, 5:03 PM

Add the tests to a CFG-oriented test file as well, because it doesn't have much to do with the analyzer.

FIXME: temp-obj-dtors-cfg-output.cpp is a mess. It'd be great to interleave code and expected output, like other CFG tests do, to make it readable.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 12 2018, 4:56 PM
This revision was automatically updated to reflect the committed changes.