[NFC] use bit_cast in PointerSumType
authorJF Bastien <jfbastien@apple.com>
Fri, 21 Sep 2018 18:35:32 +0000 (18:35 +0000)
committerJF Bastien <jfbastien@apple.com>
Fri, 21 Sep 2018 18:35:32 +0000 (18:35 +0000)
The code was already using union and memcpy to do this. Remove the memcpy. We can't just change the union because a reference to its member is returned.

llvm-svn: 342759

llvm/include/llvm/ADT/PointerSumType.h

index f5b2053..a19e45a 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef LLVM_ADT_POINTERSUMTYPE_H
 #define LLVM_ADT_POINTERSUMTYPE_H
 
+#include "llvm/ADT/bit.h"
 #include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/Support/PointerLikeTypeTraits.h"
 #include <cassert>
@@ -186,11 +187,9 @@ public:
   }
 
   uintptr_t getOpaqueValue() const {
-    uintptr_t Value;
     // Read the underlying storage of the union, regardless of the active
     // member.
-    memcpy(&Value, &Storage, sizeof(Value));
-    return Value;
+    return bit_cast<uintptr_t>(Storage);
   }
 
 protected: