summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/Core/DataExtractorTest.cpp
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2016-04-14 14:31:08 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2016-04-14 14:31:08 +0000
commitb00ef10b70b1939e7ef3a499eedbeac6860fa3fc (patch)
tree3b08522a96408b98d1505468839e1a37c172ac68 /lldb/unittests/Core/DataExtractorTest.cpp
parent377e4213e1fd9f242a92bf0f40f7e3734a4c6938 (diff)
downloadbcm5719-llvm-b00ef10b70b1939e7ef3a499eedbeac6860fa3fc.tar.gz
bcm5719-llvm-b00ef10b70b1939e7ef3a499eedbeac6860fa3fc.zip
Make Scalar::GetBytes and RegisterValue::GetBytes const
Scalar::GetBytes provides a non-const access to the underlying bytes of the scalar value, supposedly allowing for modification of those bytes. However, even with the current implementation, this is not really possible. For floating-point scalars, the pointer returned by GetBytes refers to a temporary copy; modifications to that copy will be simply ignored. For integer scalars, the pointer refers to internal memory of the APInt implementation, which isn't supposed to be directly modifyable; GetBytes simply casts aways the const-ness of the pointer ... With my upcoming patch to fix Scalar::GetBytes for big-endian systems, this problem is going to get worse, since there we need temporary copies even for some integer scalars. Therefore, this patch makes Scalar::GetBytes const, fixing all those problems. As a follow-on change, RegisterValues::GetBytes must be made const as well. This in turn means that the way of initializing a RegisterValue by doing a SetType followed by writing to GetBytes no longer works. Instead, I've changed SetValueFromData to do the equivalent of SetType itself, and then re-implemented SetFromMemoryData to work on top of SetValueFromData. There is still a need for RegisterValue::SetType, since some platform-specific code uses it to reinterpret the contents of an already filled RegisterValue. To make this usage work in all cases (even changing from a type implemented via Scalar to a type implemented as a byte buffer), SetType now simply copies the old contents out, and then reloads the RegisterValue from this data using the new type via SetValueFromData. This in turn means that there is no remaining caller of Scalar::SetType, so it can be removed. The only other follow-on change was in MIPS EmulateInstruction code, where some uses of RegisterValue::GetBytes could be made const trivially. Differential Revision: http://reviews.llvm.org/D18980 llvm-svn: 266310
Diffstat (limited to 'lldb/unittests/Core/DataExtractorTest.cpp')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud