[Lldb-commits] [PATCH] D113519: [lldb] [gdb-server] Fix fill_clamp to handle signed src types
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 10 00:39:15 PST 2021
This revision was automatically updated to reflect the committed changes.
mgorny marked an inline comment as done.
Closed by commit rG82ce9127436b: [lldb] [gdb-server] Fix fill_clamp to handle signed src types (authored by mgorny).
Herald added a project: LLDB.
Changed prior to commit:
https://reviews.llvm.org/D113519?vs=385989&id=386079#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113519/new/
https://reviews.llvm.org/D113519
Files:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -771,8 +771,11 @@
template <typename T, typename U>
static void fill_clamp(T &dest, U src, typename T::value_type fallback) {
- dest = src <= std::numeric_limits<typename T::value_type>::max() ? src
- : fallback;
+ static_assert(std::is_unsigned<typename T::value_type>::value,
+ "Destination type must be unsigned.");
+ using UU = typename std::make_unsigned<U>::type;
+ constexpr auto T_max = std::numeric_limits<typename T::value_type>::max();
+ dest = src >= 0 && static_cast<UU>(src) <= T_max ? src : fallback;
}
GDBRemoteCommunication::PacketResult
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113519.386079.patch
Type: text/x-patch
Size: 969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211110/370d349e/attachment.bin>
More information about the lldb-commits
mailing list