Author: David Spickett
Date: 2023-04-18T08:18:59Z
New Revision: 9984cfc86ed6d5c1558d8dd82d82448e50d704ad

URL: 
https://github.com/llvm/llvm-project/commit/9984cfc86ed6d5c1558d8dd82d82448e50d704ad
DIFF: 
https://github.com/llvm/llvm-project/commit/9984cfc86ed6d5c1558d8dd82d82448e50d704ad.diff

LOG: [lldb] Use llvm::byteswap in DumpRegisterValue

7978abd5aef1ba84d7a1cefbc3443245acff2c48 fixed a build issue
on MSVC with some code I previously added, by adding some
ifdefs.

Now I realise that I should have been using llvm::byteswap
in the first place, which does exactly that.

Added: 
    

Modified: 
    lldb/source/Core/DumpRegisterValue.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Core/DumpRegisterValue.cpp 
b/lldb/source/Core/DumpRegisterValue.cpp
index 3e59fb13b8ca..463aa5926772 100644
--- a/lldb/source/Core/DumpRegisterValue.cpp
+++ b/lldb/source/Core/DumpRegisterValue.cpp
@@ -17,26 +17,10 @@
 #include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/lldb-private-types.h"
-
-#if !defined(__has_builtin)
-#define __has_builtin(x) 0
-#endif
-
-#if __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)
-#define bswap_32(x) __builtin_bswap32(x)
-#define bswap_64(x) __builtin_bswap64(x)
-#elif defined(_MSC_VER)
-#define bswap_32(x) _byteswap_ulong(x)
-#define bswap_64(x) _byteswap_uint64(x)
-#else
-#include <byteswap.h>
-#endif
+#include "llvm/ADT/bit.h"
 
 using namespace lldb;
 
-static uint32_t swap_value(uint32_t v) { return bswap_32(v); }
-static uint64_t swap_value(uint64_t v) { return bswap_64(v); }
-
 template <typename T>
 static void dump_type_value(lldb_private::CompilerType &fields_type, T value,
                             lldb_private::ExecutionContextScope *exe_scope,
@@ -55,7 +39,7 @@ static void dump_type_value(lldb_private::CompilerType 
&fields_type, T value,
 
   // Then we need to match the target's endian on a byte level as well.
   if (lldb_private::endian::InlHostByteOrder() != target_order)
-    value = swap_value(value);
+    value = llvm::byteswap(value);
 
   lldb_private::DataExtractor data_extractor{
       &value, sizeof(T), lldb_private::endian::InlHostByteOrder(), 8};


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to