[llvm-commits] [PATCH] Casting.h: Don't cast away const with static_cast<>

Sean Silva silvas at purdue.edu
Thu Oct 4 21:26:57 PDT 2012


Does this look right? Or is there some subtlety here that is eluding me?

I verified that `check` passes with this applied. Since the patch is
so small, I'll just paste it here (it's also attached):

diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h
index d35febb..03dd442 100644
--- a/include/llvm/Support/Casting.h
+++ b/include/llvm/Support/Casting.h
@@ -37,7 +37,7 @@ template<typename From> struct simplify_type {
 template<typename From> struct simplify_type<const From> {
   typedef const From SimpleType;
   static SimpleType &getSimplifiedValue(const From &Val) {
-    return simplify_type<From>::getSimplifiedValue(static_cast<From&>(Val));
+    return simplify_type<From>::getSimplifiedValue(const_cast<From&>(Val));
   }
 };

-- Sean Silva
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dont-cast-away-const-with-static_cast.patch
Type: application/octet-stream
Size: 566 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121005/13e968c0/attachment.obj>


More information about the llvm-commits mailing list