This is an archive of the discontinued LLVM Phabricator instance.

Don't take the address of an xvalue when printing an expr result
ClosedPublic

Authored by teemperor on Jun 18 2018, 4:35 PM.

Details

Summary

If we have an xvalue here, we will always hit the err_typecheck_invalid_lvalue_addrof error
in 'Sema::CheckAddressOfOperand' when trying to take the address of the result. This patch
uses the fallback code path where we store the result in a local variable instead when we hit
this case.

Fixes rdar://problem/40613277

Diff Detail

Event Timeline

teemperor created this revision.Jun 18 2018, 4:35 PM
teemperor planned changes to this revision.Jun 18 2018, 4:41 PM
  • Needs a test
teemperor updated this revision to Diff 151827.Jun 18 2018, 5:03 PM
  • Added test case
teemperor updated this revision to Diff 151828.Jun 18 2018, 5:04 PM
  • Removed now unnecessary brackets.
friss added a subscriber: friss.Jun 19 2018, 10:10 AM
friss added inline comments.
packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
32

Could you use a different value than 0? Getting a random zero from memory seems to easy. It would be better to test a real string.

  • Generalized test case a bit more and no longer checking only for 0.
teemperor marked an inline comment as done.Jun 19 2018, 12:48 PM
teemperor updated this revision to Diff 154656.Jul 9 2018, 11:36 AM
teemperor edited the summary of this revision. (Show Details)
teemperor added a subscriber: vsk.
  • Removed unnecessary include from the test.
vsk accepted this revision.Jul 9 2018, 12:00 PM

Thanks, LGTM. This looks pretty cut and dry. The evaluator shouldn't try to take the address of an rvalue.

This revision is now accepted and ready to land.Jul 9 2018, 12:00 PM
This revision was automatically updated to reflect the committed changes.