[Lldb-commits] [PATCH] D20355: Avoid an assertion failure when a bit field is extracted from a value of the same size.
Bryan Chan via lldb-commits
lldb-commits at lists.llvm.org
Thu May 19 06:21:23 PDT 2016
bryanpkc added a comment.
In http://reviews.llvm.org/D20355#434117, @labath wrote:
> Do you have commit access?
Yes I do. Thanks for your review!
================
Comment at: unittests/Core/ScalarTest.cpp:90
@@ +89,3 @@
+ ASSERT_TRUE(s_scalar.ExtractBitfield(0, 0));
+ ASSERT_EQ(0, memcmp(&a1, s_scalar.GetBytes(), sizeof(a1)));
+ ASSERT_TRUE(s_scalar.ExtractBitfield(len, 0));
----------------
labath wrote:
> Is there a reason this couldn't be written as `ASSERT_EQ(a1, s_scalar.SLongLong())` ?
> If there isn't one, I think this would make the check more readable.
SLongLong() invokes sextOrTrunc() and getSExtValue(), potentially further changing the contents of the underlying m_integer. I felt that checking with memcmp() immediately after ExtractBitfield() is a more fool-proof way to confirm the behaviour of ExtractBitfield(). There are precedents for using memcmp() in the file, and it is not that much more unreadable.
http://reviews.llvm.org/D20355
More information about the lldb-commits
mailing list