llvm-project/lldb
Pavel Labath b725142c8d [lldb] Fix type conversion in the Scalar getters
Summary:
The Scalar class claims to follow the C type conversion rules. This is
true for the Promote function, but it is not true for the implicit
conversions done in the getter methods.

These functions had a subtle bug: when extending the type, they used the
signedness of the *target* type in order to determine whether to do
sign-extension or zero-extension. This is not how things work in C,
which uses the signedness of the *source* type. I.e., C does
(sign-)extension before it does signed->unsigned conversion, and not the
other way around.

This means that: (unsigned long)(int)-1
      is equal to (unsigned long)0xffffffffffffffff
      and not (unsigned long)0x00000000ffffffff

Unsurprisingly, we have accumulated code which depended on this
inconsistent behavior. It mainly manifested itself as code calling
"ULongLong/SLongLong" as a way to get the value of the Scalar object in
a primitive type that is "large enough". Previously, the ULongLong
conversion did not do sign-extension, but now it does.

This patch makes the Scalar getters consistent with the declared
semantics, and fixes the couple of call sites that were using it
incorrectly.

Reviewers: teemperor, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D82772
2020-07-02 18:02:57 +02:00
..
bindings [lldb/api] Improve error reporting in SBBreakpoint::AddName (NFCI) 2020-07-01 12:45:05 +02:00
cmake [lldb/Lua] Require Lua 5.3 2020-06-23 09:24:01 -07:00
docs [lldb/Docs] Add more details to the issues with custom Python installs on macOS 2020-06-25 10:53:30 -07:00
examples As part of using inclusive language within the llvm project, 2020-06-19 14:51:04 -07:00
include/lldb [lldb] Fix type conversion in the Scalar getters 2020-07-02 18:02:57 +02:00
packages/Python [TestReturnValue] Skip based on architecutre, not platform. 2020-06-30 12:48:23 -07:00
resources
scripts [lldb/Scripts] 2020-06-30 17:06:14 +02:00
source [lldb] Fix type conversion in the Scalar getters 2020-07-02 18:02:57 +02:00
test [lldb] Fix type conversion in the Scalar getters 2020-07-02 18:02:57 +02:00
third_party/Python/module [lldb] NFC: Fix trivial typo in comments, documents, and messages 2020-04-07 01:06:16 +09:00
tools debugserver: Return a nullptr in GetPlatformString() 2020-07-01 11:06:25 -07:00
unittests [lldb] Fix type conversion in the Scalar getters 2020-07-02 18:02:57 +02:00
utils [lldb/Utils] Serialize exit code in lldb-repro.py 2020-05-05 16:05:49 -07:00
.clang-format
.clang-tidy [lldb] Add .clang-tidy with customization to disable readability-identifier-naming 2020-03-09 12:50:28 -07:00
.gitignore Add .noindex to the gitignore 2019-04-05 17:57:42 +00:00
CMakeLists.txt [lldb/CMake] Only CMAKE_CFG_INTDIR if it's not '.' 2020-03-27 17:49:00 -07:00
CODE_OWNERS.txt [lldb][NFC] Cleanup mentions and code related to lldb-mi 2019-07-19 15:55:23 +00:00
LICENSE.TXT
use_lldb_suite_root.py