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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 12:37:46 PDT 2017


lebedev.ri updated this revision to Diff 102383.
lebedev.ri added a comment.

Address review notes: replaced C-style cast with reinterpret_cast<>()


Repository:
  rL LLVM

https://reviews.llvm.org/D34153

Files:
  include/llvm/ADT/PointerUnion.h


Index: include/llvm/ADT/PointerUnion.h
===================================================================
--- include/llvm/ADT/PointerUnion.h
+++ 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.102383.patch
Type: text/x-patch
Size: 532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170613/ee6ec213/attachment.bin>


More information about the llvm-commits mailing list