[PATCH] D34153: [ADT] PointerUnion::getAddrOfPtr1(): fix/silence -Wcast-qual warning.

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 13:34:38 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL305319: [ADT] PointerUnion::getAddrOfPtr1(): fix/silence -Wcast-qual warning. (authored by lebedevri).

Changed prior to commit:
  https://reviews.llvm.org/D34153?vs=102383&id=102393#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34153

Files:
  llvm/trunk/include/llvm/ADT/PointerUnion.h


Index: llvm/trunk/include/llvm/ADT/PointerUnion.h
===================================================================
--- llvm/trunk/include/llvm/ADT/PointerUnion.h
+++ llvm/trunk/include/llvm/ADT/PointerUnion.h
@@ -158,7 +158,7 @@
     assert(
         get<PT1>() == Val.getPointer() &&
         "Can't get the address because PointerLikeTypeTraits changes the ptr");
-    return (PT1 *)Val.getAddrOfPointer();
+    return const_cast<PT1 *>(reinterpret_cast<const PT1 *>(Val.getAddrOfPointer()));
   }
 
   /// Assignment from nullptr which just clears the union.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34153.102393.patch
Type: text/x-patch
Size: 565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170613/f2c0310d/attachment.bin>


More information about the llvm-commits mailing list