[Lldb-commits] [lldb] 73714a3 - [lldb] Fix undefined behavior: left shift of negative value

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 5 09:37:36 PDT 2022


Author: Jonas Devlieghere
Date: 2022-04-05T09:37:31-07:00
New Revision: 73714a3c603c1e0656f138ad8b6ef2c4740c95f3

URL: https://github.com/llvm/llvm-project/commit/73714a3c603c1e0656f138ad8b6ef2c4740c95f3
DIFF: https://github.com/llvm/llvm-project/commit/73714a3c603c1e0656f138ad8b6ef2c4740c95f3.diff

LOG: [lldb] Fix undefined behavior: left shift of negative value

Fix undefined behavior in AppleObjCRuntimeV2 where we were left shifting
a signed value. This also removes redundant casts of unobfuscated to
uint64_t which it already is.

rdar://91242879

Differential revision: https://reviews.llvm.org/D123098

Added: 
    

Modified: 
    lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index f3deafd3e2b68..e6e12a631088a 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -2762,11 +2762,10 @@ AppleObjCRuntimeV2::TaggedPointerVendorRuntimeAssisted::GetClassDescriptor(
   }
 
   uint64_t data_payload =
-      (((uint64_t)unobfuscated << m_objc_debug_taggedpointer_payload_lshift) >>
+      ((unobfuscated << m_objc_debug_taggedpointer_payload_lshift) >>
        m_objc_debug_taggedpointer_payload_rshift);
   int64_t data_payload_signed =
-      ((int64_t)((int64_t)unobfuscated
-                 << m_objc_debug_taggedpointer_payload_lshift) >>
+      ((int64_t)(unobfuscated << m_objc_debug_taggedpointer_payload_lshift) >>
        m_objc_debug_taggedpointer_payload_rshift);
   return ClassDescriptorSP(new ClassDescriptorV2Tagged(
       actual_class_descriptor_sp, data_payload, data_payload_signed));


        


More information about the lldb-commits mailing list