Fixes for PR114: Thanks to Reid Spencer!
authorChris Lattner <sabre@nondot.org>
Sun, 16 Nov 2003 20:21:15 +0000 (20:21 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 16 Nov 2003 20:21:15 +0000 (20:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10029 91177308-0d34-0410-b5e6-96231b3b80d8

28 files changed:
include/Support/Casting.h
include/Support/CommandLine.h
include/Support/GraphWriter.h
include/Support/HashExtras.h
include/Support/MallocAllocator.h
include/Support/MathExtras.h
include/Support/StringExtras.h
include/llvm/ADT/HashExtras.h
include/llvm/ADT/StringExtras.h
include/llvm/ConstantHandling.h
include/llvm/Constants.h
include/llvm/GlobalValue.h
include/llvm/GlobalVariable.h
include/llvm/InstrTypes.h
include/llvm/PassSupport.h
include/llvm/Support/Casting.h
include/llvm/Support/CommandLine.h
include/llvm/Support/GraphWriter.h
include/llvm/Support/MallocAllocator.h
include/llvm/Support/MathExtras.h
include/llvm/Use.h
include/llvm/User.h
include/llvm/iMemory.h
include/llvm/iOther.h
include/llvm/iPHINode.h
include/llvm/iTerminators.h
lib/VMCore/ConstantFold.h
lib/VMCore/ConstantFolding.h

index 4b070c18d85a4d3a3a05cf60cd03b9a7163abe8b..abc80aac7af4568cfc1e74b9806a2445d9eeafff 100644 (file)
@@ -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((From&)Val);
+    return simplify_type<From>::getSimplifiedValue(static_cast<From&>(Val));
   }
 };
 
@@ -178,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));
   }
 };
 
index df40d80070e2a6a5d941ad788e30233b103fa554..0a3cb6f320b7cac125beabdd433097a9c3b34652 100644 (file)
@@ -148,19 +148,23 @@ public:
 
   inline enum NumOccurrences getNumOccurrencesFlag() const {
     int NO = Flags & OccurrencesMask;
-    return NO ? (enum NumOccurrences)NO : getNumOccurrencesFlagDefault();
+    return NO ? static_cast<enum NumOccurrences>(NO)
+              : getNumOccurrencesFlagDefault();
   }
   inline enum ValueExpected getValueExpectedFlag() const {
     int VE = Flags & ValueMask;
-    return VE ? (enum ValueExpected)VE : getValueExpectedFlagDefault();
+    return VE ? static_cast<enum ValueExpected>(VE)
+              : getValueExpectedFlagDefault();
   }
   inline enum OptionHidden getOptionHiddenFlag() const {
     int OH = Flags & HiddenMask;
-    return OH ? (enum OptionHidden)OH : getOptionHiddenFlagDefault();
+    return OH ? static_cast<enum OptionHidden>(OH)
+              : getOptionHiddenFlagDefault();
   }
   inline enum FormattingFlags getFormattingFlag() const {
     int OH = Flags & FormattingMask;
-    return OH ? (enum FormattingFlags)OH : getFormattingFlagDefault();
+    return OH ? static_cast<enum FormattingFlags>(OH)
+              : getFormattingFlagDefault();
   }
   inline unsigned getMiscFlags() const {
     return Flags & MiscMask;
@@ -307,7 +311,7 @@ public:
 
     // Process the varargs portion of the values...
     while (const char *EnumName = va_arg(ValueArgs, const char *)) {
-      DataType EnumVal = (DataType)va_arg(ValueArgs, int);
+      DataType EnumVal = static_cast<DataType>(va_arg(ValueArgs, int));
       const char *EnumDesc = va_arg(ValueArgs, const char *);
       Values.push_back(std::make_pair(EnumName,      // Add value to value map
                                       std::make_pair(EnumVal, EnumDesc)));
@@ -452,7 +456,8 @@ public:
   template <class DT>
   void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) {
     assert(findOption(Name) == Values.size() && "Option already exists!");
-    Values.push_back(std::make_pair(Name, std::make_pair((DataType)V,HelpStr)));
+    Values.push_back(std::make_pair(Name,
+                             std::make_pair(static_cast<DataType>(V),HelpStr)));
   }
 
   // removeLiteralOption - Remove the specified option.
index 7e5aa80645b2439a7e329b537336abec8eb8f360..0eace78d73fa2fdad04364286b352dd7072b2e28 100644 (file)
@@ -100,7 +100,7 @@ public:
   void writeNode(NodeType *Node) {
     std::string NodeAttributes = DOTTraits::getNodeAttributes(Node);
       
-    O << "\tNode" << (void*)Node << " [shape=record,";
+    O << "\tNode" << reinterpret_cast<const void*>(Node) << " [shape=record,";
     if (!NodeAttributes.empty()) O << NodeAttributes << ",";
     O << "label=\"{"
       << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
@@ -137,10 +137,11 @@ public:
         // Figure out which edge this targets...
         unsigned Offset = std::distance(GTraits::child_begin(TargetNode),
                                         TargetIt);
-        DestPort = (int)Offset;
+        DestPort = static_cast<int>(Offset);
       }
 
-      emitEdge((void *)Node, edgeidx, (void*)TargetNode, DestPort,
+      emitEdge(reinterpret_cast<const void*>(Node), edgeidx,
+               reinterpret_cast<const void*>(TargetNode), DestPort,
                DOTTraits::getEdgeAttributes(Node, EI));
     }
   }
@@ -178,7 +179,7 @@ public:
     O << "\tNode" << SrcNodeID;
     if (SrcNodePort >= 0)
       O << ":g" << SrcNodePort;
-    O << " -> Node" << (void*)DestNodeID;
+    O << " -> Node" << reinterpret_cast<const void*>(DestNodeID);
     if (DestNodePort >= 0)
       O << ":g" << DestNodePort;    
 
index 871080c46756847fee7fe7542a1ce82107a6b15b..67f65b5f3ac061a70172baa2f787d272dea10ade 100644 (file)
@@ -31,7 +31,9 @@ template <> struct hash<std::string> {
 
 // Provide a hash function for arbitrary pointers...
 template <class T> struct hash<T *> {
-  inline size_t operator()(const T *Val) const { return (size_t)Val; }
+  inline size_t operator()(const T *Val) const {
+    return reinterpret_cast<size_t>(Val);
+  }
 };
 
 }  // End namespace std
index 022953df93dff113bb07ec967c2d33a3b088357d..3e3da4139c10e2bb796dc1a2f844126288dd91ca 100644 (file)
@@ -47,15 +47,15 @@ struct MallocAllocator {
   size_type max_size() const { return ~0 / sizeof(T); }
   
   static pointer allocate(size_t n, void* hint = 0) {
-    return (pointer)malloc(n*sizeof(T));
+    return static_cast<pointer>(malloc(n*sizeof(T)));
   }
 
   static void deallocate(pointer p, size_t n) {
-    free((void*)p);
+    free(static_cast<void*>(p));
   }
 
   void construct(pointer p, const T &val) {
-    new((void*)p) T(val);
+    new(static_cast<void*>(p)) T(val);
   }
   void destroy(pointer p) {
     p->~T();
index 74958fbc3570bc61d79c2678a043ba54d2e8fc1c..125aff3b9ff255f10dce9441ef213403bbd43088 100644 (file)
@@ -28,7 +28,7 @@ inline unsigned log2(uint64_t C) {
 inline bool isPowerOf2(int64_t C, unsigned &getPow) {
   if (C < 0) C = -C;
   if (C > 0 && C == (C & ~(C - 1))) {
-    getPow = log2((uint64_t)C);
+    getPow = log2(static_cast<uint64_t>(C));
     return true;
   }
 
index 2ebac81935cae59777898199f119060f9df7ed17..08e5eb7e04107bda3c716319dace5d880a46bc34 100644 (file)
@@ -57,14 +57,14 @@ static inline std::string utostr(unsigned long long X, bool isNeg = false) {
 
 static inline std::string itostr(int64_t X) {
   if (X < 0) 
-    return utostr((uint64_t)-X, true);
+    return utostr(static_cast<uint64_t>(-X), true);
   else
-    return utostr((uint64_t)X);
+    return utostr(static_cast<uint64_t>(X));
 }
 
 
 static inline std::string utostr(unsigned long X, bool isNeg = false) {
-  return utostr((unsigned long long)X, isNeg);
+  return utostr(static_cast<unsigned long long>(X), isNeg);
 }
 
 static inline std::string utostr(unsigned X, bool isNeg = false) {
@@ -86,9 +86,9 @@ static inline std::string utostr(unsigned X, bool isNeg = false) {
 
 static inline std::string itostr(int X) {
   if (X < 0) 
-    return utostr((unsigned)-X, true);
+    return utostr(static_cast<unsigned>(-X), true);
   else
-    return utostr((unsigned)X);
+    return utostr(static_cast<unsigned>(X));
 }
 
 static inline std::string ftostr(double V) {
index 871080c46756847fee7fe7542a1ce82107a6b15b..67f65b5f3ac061a70172baa2f787d272dea10ade 100644 (file)
@@ -31,7 +31,9 @@ template <> struct hash<std::string> {
 
 // Provide a hash function for arbitrary pointers...
 template <class T> struct hash<T *> {
-  inline size_t operator()(const T *Val) const { return (size_t)Val; }
+  inline size_t operator()(const T *Val) const {
+    return reinterpret_cast<size_t>(Val);
+  }
 };
 
 }  // End namespace std
index 2ebac81935cae59777898199f119060f9df7ed17..08e5eb7e04107bda3c716319dace5d880a46bc34 100644 (file)
@@ -57,14 +57,14 @@ static inline std::string utostr(unsigned long long X, bool isNeg = false) {
 
 static inline std::string itostr(int64_t X) {
   if (X < 0) 
-    return utostr((uint64_t)-X, true);
+    return utostr(static_cast<uint64_t>(-X), true);
   else
-    return utostr((uint64_t)X);
+    return utostr(static_cast<uint64_t>(X));
 }
 
 
 static inline std::string utostr(unsigned long X, bool isNeg = false) {
-  return utostr((unsigned long long)X, isNeg);
+  return utostr(static_cast<unsigned long long>(X), isNeg);
 }
 
 static inline std::string utostr(unsigned X, bool isNeg = false) {
@@ -86,9 +86,9 @@ static inline std::string utostr(unsigned X, bool isNeg = false) {
 
 static inline std::string itostr(int X) {
   if (X < 0) 
-    return utostr((unsigned)-X, true);
+    return utostr(static_cast<unsigned>(-X), true);
   else
-    return utostr((unsigned)X);
+    return utostr(static_cast<unsigned>(X));
 }
 
 static inline std::string ftostr(double V) {
index a0a01e5306309d71f1cd44c8f1ab8f15f34e5210..b392ad1173779d0bfb64dae15eb22f75b7903420 100644 (file)
@@ -113,7 +113,8 @@ public:
     case Type::LongTyID:   return castToLong(V);
     case Type::FloatTyID:  return castToFloat(V);
     case Type::DoubleTyID: return castToDouble(V);
-    case Type::PointerTyID:return castToPointer(V, (PointerType*)Ty);
+    case Type::PointerTyID:
+      return castToPointer(V, reinterpret_cast<const PointerType*>(Ty));
     default: return 0;
     }
   }
@@ -125,7 +126,7 @@ public:
   static inline ConstRules *get(const Constant &V1, const Constant &V2) {
     if (isa<ConstantExpr>(V1) || isa<ConstantExpr>(V2))
       return getConstantExprRules();
-    return (ConstRules*)V1.getType()->getOrCreateAnnotation(AID);
+    return static_cast<ConstRules*>(V1.getType()->getOrCreateAnnotation(AID));
   }
 private:
   static ConstRules *getConstantExprRules();
index 5d65b2f0c7fd875ce88fa3540d8fc63276c736f4..06f1308fdf9b66dadf8a66d4aded5de6f57782e5 100644 (file)
@@ -301,7 +301,7 @@ public:
   /// which reduces the amount of casting needed in parts of the compiler.
   ///
   inline const ArrayType *getType() const {
-    return (ArrayType*)Value::getType();
+    return reinterpret_cast<const ArrayType*>(Value::getType());
   }
 
   /// getAsString - If the sub-element type of this array is either sbyte or
@@ -354,7 +354,7 @@ public:
 
   /// getType() specialization - Reduce amount of casting...
   inline const StructType *getType() const {
-    return (StructType*)Value::getType();
+    return reinterpret_cast<const StructType*>(Value::getType());
   }
 
   /// getValues - Return a vector of the component constants that make up this
@@ -394,10 +394,11 @@ public:
 class ConstantPointer : public Constant {
   ConstantPointer(const ConstantPointer &);      // DO NOT IMPLEMENT
 protected:
-  inline ConstantPointer(const PointerType *T) : Constant((const Type*)T) {}
+  inline ConstantPointer(const PointerType *T)
+    : Constant(reinterpret_cast<const Type*>(T)) { }
 public:
   inline const PointerType *getType() const {
-    return (PointerType*)Value::getType();
+    return reinterpret_cast<const PointerType*>(Value::getType());
   }
 
   /// isNullValue - Return true if this is the value that would be returned by
index 47a2189fa4ae7e2e37241ea1e6188e887558ce97..942d9b9a4081ded2b6e951a24dfbea4943ba8d43 100644 (file)
@@ -46,7 +46,7 @@ public:
 
   /// getType - Global values are always pointers.
   inline const PointerType *getType() const {
-    return (const PointerType*)User::getType();
+    return reinterpret_cast<const PointerType*>(User::getType());
   }
 
   bool hasExternalLinkage()  const { return Linkage == ExternalLinkage; }
index 03c4f3912024ec68b7c0f3b2ab457ff09fc5c2fc..b09bf40f05904da6346f032c799dfb7492153a54 100644 (file)
@@ -70,18 +70,18 @@ public:
   ///
   inline Constant *getInitializer() const {
     assert(hasInitializer() && "GV doesn't have initializer!");
-    return (Constant*)Operands[0].get();
+    return reinterpret_cast<Constant*>(Operands[0].get());
   }
   inline Constant *getInitializer() {
     assert(hasInitializer() && "GV doesn't have initializer!");
-    return (Constant*)Operands[0].get();
+    return reinterpret_cast<Constant*>(Operands[0].get());
   }
   inline void setInitializer(Constant *CPV) {
     if (CPV == 0) {
       if (hasInitializer()) Operands.pop_back();
     } else {
       if (!hasInitializer()) Operands.push_back(Use(0, this));
-      Operands[0] = (Value*)CPV;
+      Operands[0] = reinterpret_cast<Value*>(CPV);
     }
   }
 
index 7938b483c7cc60c0d4d80910c019bc93ef3f613d..70cb742d96da78115dfdc0d4e4456ed7cdea5510 100644 (file)
@@ -50,7 +50,8 @@ public:
   virtual void setSuccessor(unsigned idx, BasicBlock *B) = 0;
 
   inline BasicBlock *getSuccessor(unsigned idx) {
-    return (BasicBlock*)((const TerminatorInst *)this)->getSuccessor(idx);
+    const TerminatorInst *TI = this;
+    return const_cast<BasicBlock*>(TI->getSuccessor(idx));
   }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -110,7 +111,7 @@ public:
   static       Value*    getNotArgument(      BinaryOperator* Bop);
 
   BinaryOps getOpcode() const { 
-    return (BinaryOps)Instruction::getOpcode();
+    return static_cast<BinaryOps>(Instruction::getOpcode());
   }
 
   virtual Instruction *clone() const {
index d985bf121d3da598c05983145ce1d38f156196cd..bc2b7da8a2442ac1f3a4fb86a282524f645982b1 100644 (file)
@@ -226,7 +226,8 @@ struct RegisterOpt : public RegisterPassBase {
   RegisterOpt(const char *PassArg, const char *Name, FunctionPass *(*ctor)(),
               bool CFGOnly = false) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
-                              PassInfo::Optimization, (Pass*(*)())ctor));
+                              PassInfo::Optimization, 
+                              static_cast<Pass*(*)()>(ctor)));
     if (CFGOnly) setOnlyUsesCFG();
   }
 
@@ -246,7 +247,7 @@ struct RegisterOpt : public RegisterPassBase {
               bool CFGOnly = false) {
     registerPass(new PassInfo(Name, PassArg, typeid(PassName),
                               PassInfo::Optimization, 0,
-                              (Pass*(*)(TargetMachine&))targetctor));
+                            static_cast<Pass*(*)(TargetMachine&)>(targetctor)));
     if (CFGOnly) setOnlyUsesCFG();
   }
 };
index 4b070c18d85a4d3a3a05cf60cd03b9a7163abe8b..abc80aac7af4568cfc1e74b9806a2445d9eeafff 100644 (file)
@@ -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((From&)Val);
+    return simplify_type<From>::getSimplifiedValue(static_cast<From&>(Val));
   }
 };
 
@@ -178,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));
   }
 };
 
index df40d80070e2a6a5d941ad788e30233b103fa554..0a3cb6f320b7cac125beabdd433097a9c3b34652 100644 (file)
@@ -148,19 +148,23 @@ public:
 
   inline enum NumOccurrences getNumOccurrencesFlag() const {
     int NO = Flags & OccurrencesMask;
-    return NO ? (enum NumOccurrences)NO : getNumOccurrencesFlagDefault();
+    return NO ? static_cast<enum NumOccurrences>(NO)
+              : getNumOccurrencesFlagDefault();
   }
   inline enum ValueExpected getValueExpectedFlag() const {
     int VE = Flags & ValueMask;
-    return VE ? (enum ValueExpected)VE : getValueExpectedFlagDefault();
+    return VE ? static_cast<enum ValueExpected>(VE)
+              : getValueExpectedFlagDefault();
   }
   inline enum OptionHidden getOptionHiddenFlag() const {
     int OH = Flags & HiddenMask;
-    return OH ? (enum OptionHidden)OH : getOptionHiddenFlagDefault();
+    return OH ? static_cast<enum OptionHidden>(OH)
+              : getOptionHiddenFlagDefault();
   }
   inline enum FormattingFlags getFormattingFlag() const {
     int OH = Flags & FormattingMask;
-    return OH ? (enum FormattingFlags)OH : getFormattingFlagDefault();
+    return OH ? static_cast<enum FormattingFlags>(OH)
+              : getFormattingFlagDefault();
   }
   inline unsigned getMiscFlags() const {
     return Flags & MiscMask;
@@ -307,7 +311,7 @@ public:
 
     // Process the varargs portion of the values...
     while (const char *EnumName = va_arg(ValueArgs, const char *)) {
-      DataType EnumVal = (DataType)va_arg(ValueArgs, int);
+      DataType EnumVal = static_cast<DataType>(va_arg(ValueArgs, int));
       const char *EnumDesc = va_arg(ValueArgs, const char *);
       Values.push_back(std::make_pair(EnumName,      // Add value to value map
                                       std::make_pair(EnumVal, EnumDesc)));
@@ -452,7 +456,8 @@ public:
   template <class DT>
   void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) {
     assert(findOption(Name) == Values.size() && "Option already exists!");
-    Values.push_back(std::make_pair(Name, std::make_pair((DataType)V,HelpStr)));
+    Values.push_back(std::make_pair(Name,
+                             std::make_pair(static_cast<DataType>(V),HelpStr)));
   }
 
   // removeLiteralOption - Remove the specified option.
index 7e5aa80645b2439a7e329b537336abec8eb8f360..0eace78d73fa2fdad04364286b352dd7072b2e28 100644 (file)
@@ -100,7 +100,7 @@ public:
   void writeNode(NodeType *Node) {
     std::string NodeAttributes = DOTTraits::getNodeAttributes(Node);
       
-    O << "\tNode" << (void*)Node << " [shape=record,";
+    O << "\tNode" << reinterpret_cast<const void*>(Node) << " [shape=record,";
     if (!NodeAttributes.empty()) O << NodeAttributes << ",";
     O << "label=\"{"
       << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G));
@@ -137,10 +137,11 @@ public:
         // Figure out which edge this targets...
         unsigned Offset = std::distance(GTraits::child_begin(TargetNode),
                                         TargetIt);
-        DestPort = (int)Offset;
+        DestPort = static_cast<int>(Offset);
       }
 
-      emitEdge((void *)Node, edgeidx, (void*)TargetNode, DestPort,
+      emitEdge(reinterpret_cast<const void*>(Node), edgeidx,
+               reinterpret_cast<const void*>(TargetNode), DestPort,
                DOTTraits::getEdgeAttributes(Node, EI));
     }
   }
@@ -178,7 +179,7 @@ public:
     O << "\tNode" << SrcNodeID;
     if (SrcNodePort >= 0)
       O << ":g" << SrcNodePort;
-    O << " -> Node" << (void*)DestNodeID;
+    O << " -> Node" << reinterpret_cast<const void*>(DestNodeID);
     if (DestNodePort >= 0)
       O << ":g" << DestNodePort;    
 
index 022953df93dff113bb07ec967c2d33a3b088357d..3e3da4139c10e2bb796dc1a2f844126288dd91ca 100644 (file)
@@ -47,15 +47,15 @@ struct MallocAllocator {
   size_type max_size() const { return ~0 / sizeof(T); }
   
   static pointer allocate(size_t n, void* hint = 0) {
-    return (pointer)malloc(n*sizeof(T));
+    return static_cast<pointer>(malloc(n*sizeof(T)));
   }
 
   static void deallocate(pointer p, size_t n) {
-    free((void*)p);
+    free(static_cast<void*>(p));
   }
 
   void construct(pointer p, const T &val) {
-    new((void*)p) T(val);
+    new(static_cast<void*>(p)) T(val);
   }
   void destroy(pointer p) {
     p->~T();
index 74958fbc3570bc61d79c2678a043ba54d2e8fc1c..125aff3b9ff255f10dce9441ef213403bbd43088 100644 (file)
@@ -28,7 +28,7 @@ inline unsigned log2(uint64_t C) {
 inline bool isPowerOf2(int64_t C, unsigned &getPow) {
   if (C < 0) C = -C;
   if (C > 0 && C == (C & ~(C - 1))) {
-    getPow = log2((uint64_t)C);
+    getPow = log2(static_cast<uint64_t>(C));
     return true;
   }
 
index d7c1010fc899c9e1ec45380e38bac79f73ac307c..fb5eafb7122c00e5a02d57aba14a78967f1d7540 100644 (file)
@@ -83,13 +83,13 @@ struct ilist_traits<Use> {
 template<> struct simplify_type<Use> {
   typedef Value* SimpleType;
   static SimpleType getSimplifiedValue(const Use &Val) {
-    return (SimpleType)Val.get();
+    return static_cast<SimpleType>(Val.get());
   }
 };
 template<> struct simplify_type<const Use> {
   typedef Value* SimpleType;
   static SimpleType getSimplifiedValue(const Use &Val) {
-    return (SimpleType)Val.get();
+    return static_cast<SimpleType>(Val.get());
   }
 };
 
index cdd9b539ca4f17b752db178d25e897c6ab812b77..0482189b6d8d63cd6ccc61279a0a2adf1f14c2d9 100644 (file)
@@ -96,7 +96,7 @@ template<> struct simplify_type<User::op_iterator> {
   typedef Value* SimpleType;
   
   static SimpleType getSimplifiedValue(const User::op_iterator &Val) {
-    return (SimpleType)Val->get();
+    return static_cast<SimpleType>(Val->get());
   }
 };
 template<> struct simplify_type<const User::op_iterator>
@@ -106,7 +106,7 @@ template<> struct simplify_type<User::const_op_iterator> {
   typedef Value* SimpleType;
   
   static SimpleType getSimplifiedValue(const User::const_op_iterator &Val) {
-    return (SimpleType)Val->get();
+    return static_cast<SimpleType>(Val->get());
   }
 };
 template<> struct simplify_type<const User::const_op_iterator>
index e0a551a0f749e6ff25664980e4e6caed7da1a7c4..bec4502e40460c99c7f50ef10b80a4d85859e08a 100644 (file)
@@ -47,7 +47,7 @@ public:
 
   // getType - Overload to return most specific pointer type...
   inline const PointerType *getType() const {
-    return (const PointerType*)Instruction::getType(); 
+    return reinterpret_cast<const PointerType*>(Instruction::getType()); 
   }
 
   // getAllocatedType - Return the type that is being allocated by the
@@ -237,7 +237,7 @@ public:
 
 class GetElementPtrInst : public Instruction {
   GetElementPtrInst(const GetElementPtrInst &EPI)
-    : Instruction((Type*)EPI.getType(), GetElementPtr) {
+    : Instruction(reinterpret_cast<const Type*>(EPI.getType()), GetElementPtr) {
     Operands.reserve(EPI.Operands.size());
     for (unsigned i = 0, E = EPI.Operands.size(); i != E; ++i)
       Operands.push_back(Use(EPI.Operands[i], this));
@@ -249,7 +249,7 @@ public:
   
   // getType - Overload to return most specific pointer type...
   inline const PointerType *getType() const {
-    return (PointerType*)Instruction::getType();
+    return reinterpret_cast<const PointerType*>(Instruction::getType());
   }
 
   /// getIndexedType - Returns the type of the element that would be loaded with
index c611e06612edbef1052269d46e67a11918641737..8ecf6b02697989f9e30fcb9fe7e9cbecd2d7c0b9 100644 (file)
@@ -113,7 +113,9 @@ public:
     Operands.push_back(Use(SA, this));
   }
 
-  OtherOps getOpcode() const { return (OtherOps)Instruction::getOpcode(); }
+  OtherOps getOpcode() const {
+    return static_cast<OtherOps>(Instruction::getOpcode());
+  }
 
   virtual Instruction *clone() const { return new ShiftInst(*this); }
 
index 191de040e7016adc76911ddc0ba0f06d7e3e3a5b..399c761670b2125386a06c6397627e62dab676ba 100644 (file)
@@ -58,11 +58,11 @@ public:
   /// getIncomingBlock - Return incoming basic block #x
   BasicBlock *getIncomingBlock(unsigned i) const { 
     assert(i*2+1 < Operands.size() && "Invalid value number!");
-    return (BasicBlock*)Operands[i*2+1].get();
+    return reinterpret_cast<BasicBlock*>(Operands[i*2+1].get());
   }
   void setIncomingBlock(unsigned i, BasicBlock *BB) {
     assert(i*2+1 < Operands.size() && "Invalid value number!");
-    Operands[i*2+1] = (Value*)BB;
+    Operands[i*2+1] = reinterpret_cast<Value*>(BB);
   }
   unsigned getOperandNumForIncomingBlock(unsigned i) {
     return i*2+1;
@@ -73,7 +73,7 @@ public:
     assert(getType() == D->getType() &&
            "All operands to PHI node must be the same type as the PHI node!");
     Operands.push_back(Use(D, this));
-    Operands.push_back(Use((Value*)BB, this));
+    Operands.push_back(Use(reinterpret_cast<Value*>(BB), this));
   }
   
   /// removeIncomingValue - Remove an incoming value.  This is useful if a
index 93e3adce760edfae33871cbe0c4a12f789264243..a27ffdf81da5a0c373d36f34c429fafc2e298cd7 100644 (file)
@@ -87,7 +87,7 @@ public:
   inline bool isConditional()   const { return Operands.size() == 3; }
 
   inline Value *getCondition() const {
-    return isUnconditional() ? 0 : (Value*)Operands[2].get();
+    return isUnconditional() ? 0 : reinterpret_cast<Value*>(Operands[2].get());
   }
 
   void setCondition(Value *V) {
@@ -100,7 +100,7 @@ public:
   //
   void setUnconditionalDest(BasicBlock *Dest) {
     if (isConditional()) Operands.erase(Operands.begin()+1, Operands.end());
-    Operands[0] = (Value*)Dest;
+    Operands[0] = reinterpret_cast<Value*>(Dest);
   }
 
   virtual const BasicBlock *getSuccessor(unsigned i) const {
@@ -109,12 +109,13 @@ public:
                       cast<BasicBlock>(Operands[1].get());
   }
   inline BasicBlock *getSuccessor(unsigned idx) {
-    return (BasicBlock*)((const BranchInst *)this)->getSuccessor(idx);
+    const BranchInst *BI = this;
+    return const_cast<BasicBlock*>(BI->getSuccessor(idx));
   }
 
   virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
     assert(idx < getNumSuccessors() && "Successor # out of range for Branch!");
-    Operands[idx] = (Value*)NewSucc;
+    Operands[idx] = reinterpret_cast<Value*>(NewSucc);
   }
 
   virtual unsigned getNumSuccessors() const { return 1+isConditional(); }
@@ -176,7 +177,7 @@ public:
 
   virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
     assert(idx < getNumSuccessors() && "Successor # out of range for switch!");
-    Operands[idx*2+1] = (Value*)NewSucc;
+    Operands[idx*2+1] = reinterpret_cast<Value*>(NewSucc);
   }
 
   // getSuccessorValue - Return the value associated with the specified
@@ -243,11 +244,11 @@ public:
   }
 
   inline void setNormalDest(BasicBlock *B){
-    Operands[1] = (Value*)B;
+    Operands[1] = reinterpret_cast<Value*>(B);
   }
 
   inline void setExceptionalDest(BasicBlock *B){
-    Operands[2] = (Value*)B;
+    Operands[2] = reinterpret_cast<Value*>(B);
   }
 
   virtual const BasicBlock *getSuccessor(unsigned i) const {
@@ -261,7 +262,7 @@ public:
 
   virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
     assert(idx < 2 && "Successor # out of range for invoke!");
-    Operands[idx+1] = (Value*)NewSucc;
+    Operands[idx+1] = reinterpret_cast<Value*>(NewSucc);
   }
 
   virtual unsigned getNumSuccessors() const { return 2; }
index a0a01e5306309d71f1cd44c8f1ab8f15f34e5210..b392ad1173779d0bfb64dae15eb22f75b7903420 100644 (file)
@@ -113,7 +113,8 @@ public:
     case Type::LongTyID:   return castToLong(V);
     case Type::FloatTyID:  return castToFloat(V);
     case Type::DoubleTyID: return castToDouble(V);
-    case Type::PointerTyID:return castToPointer(V, (PointerType*)Ty);
+    case Type::PointerTyID:
+      return castToPointer(V, reinterpret_cast<const PointerType*>(Ty));
     default: return 0;
     }
   }
@@ -125,7 +126,7 @@ public:
   static inline ConstRules *get(const Constant &V1, const Constant &V2) {
     if (isa<ConstantExpr>(V1) || isa<ConstantExpr>(V2))
       return getConstantExprRules();
-    return (ConstRules*)V1.getType()->getOrCreateAnnotation(AID);
+    return static_cast<ConstRules*>(V1.getType()->getOrCreateAnnotation(AID));
   }
 private:
   static ConstRules *getConstantExprRules();
index a0a01e5306309d71f1cd44c8f1ab8f15f34e5210..b392ad1173779d0bfb64dae15eb22f75b7903420 100644 (file)
@@ -113,7 +113,8 @@ public:
     case Type::LongTyID:   return castToLong(V);
     case Type::FloatTyID:  return castToFloat(V);
     case Type::DoubleTyID: return castToDouble(V);
-    case Type::PointerTyID:return castToPointer(V, (PointerType*)Ty);
+    case Type::PointerTyID:
+      return castToPointer(V, reinterpret_cast<const PointerType*>(Ty));
     default: return 0;
     }
   }
@@ -125,7 +126,7 @@ public:
   static inline ConstRules *get(const Constant &V1, const Constant &V2) {
     if (isa<ConstantExpr>(V1) || isa<ConstantExpr>(V2))
       return getConstantExprRules();
-    return (ConstRules*)V1.getType()->getOrCreateAnnotation(AID);
+    return static_cast<ConstRules*>(V1.getType()->getOrCreateAnnotation(AID));
   }
 private:
   static ConstRules *getConstantExprRules();