Changes For Bug 352
[oota-llvm.git] / include / llvm / Support / Casting.h
index 065919c1792a87c71cc491e3c464cb4418f1eeca..d18975486571a00313d0bb6e7c295cc10126260c 100644 (file)
@@ -1,4 +1,4 @@
-//===-- Support/Casting.h - Allow flexible, checked, casts ------*- C++ -*-===//
+//===-- llvm/Support/Casting.h - Allow flexible, checked, casts -*- C++ -*-===//
 // 
 //                     The LLVM Compiler Infrastructure
 //
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SUPPORT_CASTING_H
-#define SUPPORT_CASTING_H
+#ifndef LLVM_SUPPORT_CASTING_H
+#define LLVM_SUPPORT_CASTING_H
+
+namespace llvm {
 
 //===----------------------------------------------------------------------===//
 //                          isa<x> Support Templates
@@ -35,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((From&)Val);
+    return simplify_type<From>::getSimplifiedValue(static_cast<From&>(Val));
   }
 };
 
@@ -176,7 +178,8 @@ template<class To, class From, class SimpleFrom> struct cast_convert_val {
 template<class To, class FromTy> struct cast_convert_val<To,FromTy,FromTy> {
   // This _is_ a simple type, just cast it.
   static typename cast_retty<To, FromTy>::ret_type doit(const FromTy &Val) {
-    return (typename cast_retty<To, FromTy>::ret_type)Val;
+    return reinterpret_cast<typename cast_retty<To, FromTy>::ret_type>(
+                         const_cast<FromTy&>(Val));
   }
 };
 
@@ -293,4 +296,6 @@ void main() {
 
 #endif
 
+} // End llvm namespace
+
 #endif