This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix invalid shift operator overload in Scalar
ClosedPublic

Authored by mamai on Feb 3 2016, 3:03 PM.

Details

Summary

This also fixes an infinite recursion between lldb_private::operator>> () and Scalar::operator>>= ().

Diff Detail

Repository
rL LLVM

Event Timeline

mamai updated this revision to Diff 46841.Feb 3 2016, 3:03 PM
mamai retitled this revision from to [lldb] Fix invalid shift operator overload in Scalar.
mamai updated this object.
mamai added a reviewer: slthakur.
mamai set the repository for this revision to rL LLVM.
mamai added a subscriber: lldb-commits.
mamai updated this revision to Diff 47190.Feb 8 2016, 6:43 AM
mamai added reviewers: labath, tberghammer.
labath edited edge metadata.Feb 8 2016, 7:29 AM

Scalar::operator<<= seems to do a m_integer <<= .... Will it suffer from the same recursion problem?

In any case, I think the implementations of both methods should use the same API (it doesn't matter which one if both work).

Also it would be super great if you could make a tiny test for this, say in unittests/Core/ScalarTest.cpp

mamai added a comment.Feb 8 2016, 9:00 AM

Scalar::operator<<= works well as-is because it uses APInt &operator<<=(unsigned shiftAmt), whereas the right shift equivalent is not implemented. Should I add APInt &operator>>=, or should I change Scalar::operator<<= for consistency ?

labath added a comment.Feb 8 2016, 9:14 AM

Ah, ok I understand what's going on now. I guess APInt operator >> probably does not exist because it would be ambiguous (arithmetic or bitwise shift?). Let's just leave this as it is now.

Could you add that test though?

mamai updated this revision to Diff 47218.Feb 8 2016, 10:20 AM
mamai edited edge metadata.

Added a small unit test for scalar right shift operator, which invokes the >>= operator.

labath accepted this revision.Feb 9 2016, 12:44 AM
labath edited edge metadata.

That's perfect. Thanks for adding that test.

Do you have commit access, or shall I put this in?

This revision is now accepted and ready to land.Feb 9 2016, 12:44 AM
mamai added a comment.Feb 9 2016, 5:49 AM

I don't have commit access. It would be great if you can push it for me. Thanks !

labath closed this revision.Feb 9 2016, 9:33 AM

Committed as r260239.