[llvm-commits] CVS: llvm/include/llvm/ConstantHandling.h Constants.h GlobalValue.h GlobalVariable.h InstrTypes.h PassSupport.h Use.h User.h iMemory.h iOther.h iPHINode.h iTerminators.h

Chris Lattner lattner at cs.uiuc.edu
Sun Nov 16 14:22:01 PST 2003


Changes in directory llvm/include/llvm:

ConstantHandling.h updated: 1.32 -> 1.33
Constants.h updated: 1.34 -> 1.35
GlobalValue.h updated: 1.13 -> 1.14
GlobalVariable.h updated: 1.25 -> 1.26
InstrTypes.h updated: 1.34 -> 1.35
PassSupport.h updated: 1.17 -> 1.18
Use.h updated: 1.4 -> 1.5
User.h updated: 1.27 -> 1.28
iMemory.h updated: 1.42 -> 1.43
iOther.h updated: 1.41 -> 1.42
iPHINode.h updated: 1.14 -> 1.15
iTerminators.h updated: 1.34 -> 1.35

---
Log message:

Fixes for PR114: Thanks to Reid Spencer!



---
Diffs of the changes:  (+40 -33)

Index: llvm/include/llvm/ConstantHandling.h
diff -u llvm/include/llvm/ConstantHandling.h:1.32 llvm/include/llvm/ConstantHandling.h:1.33
--- llvm/include/llvm/ConstantHandling.h:1.32	Tue Nov 11 16:41:29 2003
+++ llvm/include/llvm/ConstantHandling.h	Sun Nov 16 14:21:15 2003
@@ -113,7 +113,8 @@
     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 @@
   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: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.34 llvm/include/llvm/Constants.h:1.35
--- llvm/include/llvm/Constants.h:1.34	Tue Nov 11 16:41:29 2003
+++ llvm/include/llvm/Constants.h	Sun Nov 16 14:21:15 2003
@@ -301,7 +301,7 @@
   /// 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 @@
 
   /// 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 @@
 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: llvm/include/llvm/GlobalValue.h
diff -u llvm/include/llvm/GlobalValue.h:1.13 llvm/include/llvm/GlobalValue.h:1.14
--- llvm/include/llvm/GlobalValue.h:1.13	Tue Nov 11 16:41:29 2003
+++ llvm/include/llvm/GlobalValue.h	Sun Nov 16 14:21:15 2003
@@ -46,7 +46,7 @@
 
   /// 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: llvm/include/llvm/GlobalVariable.h
diff -u llvm/include/llvm/GlobalVariable.h:1.25 llvm/include/llvm/GlobalVariable.h:1.26
--- llvm/include/llvm/GlobalVariable.h:1.25	Tue Nov 11 16:41:29 2003
+++ llvm/include/llvm/GlobalVariable.h	Sun Nov 16 14:21:15 2003
@@ -70,18 +70,18 @@
   ///
   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: llvm/include/llvm/InstrTypes.h
diff -u llvm/include/llvm/InstrTypes.h:1.34 llvm/include/llvm/InstrTypes.h:1.35
--- llvm/include/llvm/InstrTypes.h:1.34	Tue Nov 11 16:41:29 2003
+++ llvm/include/llvm/InstrTypes.h	Sun Nov 16 14:21:15 2003
@@ -50,7 +50,8 @@
   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 @@
   static       Value*    getNotArgument(      BinaryOperator* Bop);
 
   BinaryOps getOpcode() const { 
-    return (BinaryOps)Instruction::getOpcode();
+    return static_cast<BinaryOps>(Instruction::getOpcode());
   }
 
   virtual Instruction *clone() const {


Index: llvm/include/llvm/PassSupport.h
diff -u llvm/include/llvm/PassSupport.h:1.17 llvm/include/llvm/PassSupport.h:1.18
--- llvm/include/llvm/PassSupport.h:1.17	Tue Nov 11 16:41:30 2003
+++ llvm/include/llvm/PassSupport.h	Sun Nov 16 14:21:15 2003
@@ -226,7 +226,8 @@
   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 @@
               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: llvm/include/llvm/Use.h
diff -u llvm/include/llvm/Use.h:1.4 llvm/include/llvm/Use.h:1.5
--- llvm/include/llvm/Use.h:1.4	Fri Nov 14 00:03:05 2003
+++ llvm/include/llvm/Use.h	Sun Nov 16 14:21:15 2003
@@ -83,13 +83,13 @@
 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: llvm/include/llvm/User.h
diff -u llvm/include/llvm/User.h:1.27 llvm/include/llvm/User.h:1.28
--- llvm/include/llvm/User.h:1.27	Tue Nov 11 16:41:30 2003
+++ llvm/include/llvm/User.h	Sun Nov 16 14:21:15 2003
@@ -96,7 +96,7 @@
   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 @@
   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: llvm/include/llvm/iMemory.h
diff -u llvm/include/llvm/iMemory.h:1.42 llvm/include/llvm/iMemory.h:1.43
--- llvm/include/llvm/iMemory.h:1.42	Tue Nov 11 16:41:30 2003
+++ llvm/include/llvm/iMemory.h	Sun Nov 16 14:21:15 2003
@@ -47,7 +47,7 @@
 
   // 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 @@
 
 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 @@
   
   // 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: llvm/include/llvm/iOther.h
diff -u llvm/include/llvm/iOther.h:1.41 llvm/include/llvm/iOther.h:1.42
--- llvm/include/llvm/iOther.h:1.41	Tue Nov 11 16:41:30 2003
+++ llvm/include/llvm/iOther.h	Sun Nov 16 14:21:15 2003
@@ -113,7 +113,9 @@
     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: llvm/include/llvm/iPHINode.h
diff -u llvm/include/llvm/iPHINode.h:1.14 llvm/include/llvm/iPHINode.h:1.15
--- llvm/include/llvm/iPHINode.h:1.14	Tue Nov 11 16:41:30 2003
+++ llvm/include/llvm/iPHINode.h	Sun Nov 16 14:21:15 2003
@@ -58,11 +58,11 @@
   /// 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 @@
     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: llvm/include/llvm/iTerminators.h
diff -u llvm/include/llvm/iTerminators.h:1.34 llvm/include/llvm/iTerminators.h:1.35
--- llvm/include/llvm/iTerminators.h:1.34	Tue Nov 11 16:41:30 2003
+++ llvm/include/llvm/iTerminators.h	Sun Nov 16 14:21:15 2003
@@ -87,7 +87,7 @@
   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 @@
   //
   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 @@
                       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 @@
 
   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 @@
   }
 
   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 @@
 
   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; }





More information about the llvm-commits mailing list