Remove redundant const qualifiers from cast<> expressions


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7253 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/Analysis/InstForest.h b/include/llvm/Analysis/InstForest.h
index 56a918b..f49fa98 100644
--- a/include/llvm/Analysis/InstForest.h
+++ b/include/llvm/Analysis/InstForest.h
@@ -76,13 +76,13 @@
     return cast<Constant>(getValue());
   }
   inline const Constant *getConstant() const {
-    return cast<const Constant>(getValue());
+    return cast<Constant>(getValue());
   }
   inline BasicBlock *getBasicBlock() {
     return cast<BasicBlock>(getValue());
   }
   inline const BasicBlock *getBasicBlock() const {
-    return cast<const BasicBlock>(getValue());
+    return cast<BasicBlock>(getValue());
   }
   inline Instruction *getInstruction() {
     assert(isInstruction() && "getInstruction() on non instruction node!");
diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h
index 76a4e0f..efccc74 100644
--- a/include/llvm/DerivedTypes.h
+++ b/include/llvm/DerivedTypes.h
@@ -139,7 +139,7 @@
     return T->getPrimitiveID() == FunctionTyID;
   }
   static inline bool classof(const Value *V) {
-    return isa<Type>(V) && classof(cast<const Type>(V));
+    return isa<Type>(V) && classof(cast<Type>(V));
   }
 };
 
@@ -172,7 +172,7 @@
            T->getPrimitiveID() == PointerTyID;
   }
   static inline bool classof(const Value *V) {
-    return isa<Type>(V) && classof(cast<const Type>(V));
+    return isa<Type>(V) && classof(cast<Type>(V));
   }
 };
 
@@ -228,7 +228,7 @@
     return T->getPrimitiveID() == StructTyID;
   }
   static inline bool classof(const Value *V) {
-    return isa<Type>(V) && classof(cast<const Type>(V));
+    return isa<Type>(V) && classof(cast<Type>(V));
   }
 };
 
@@ -279,7 +279,7 @@
            T->getPrimitiveID() == PointerTyID;
   }
   static inline bool classof(const Value *V) {
-    return isa<Type>(V) && classof(cast<const Type>(V));
+    return isa<Type>(V) && classof(cast<Type>(V));
   }
 };
 
@@ -314,7 +314,7 @@
     return T->getPrimitiveID() == ArrayTyID;
   }
   static inline bool classof(const Value *V) {
-    return isa<Type>(V) && classof(cast<const Type>(V));
+    return isa<Type>(V) && classof(cast<Type>(V));
   }
 };
 
@@ -347,7 +347,7 @@
     return T->getPrimitiveID() == PointerTyID;
   }
   static inline bool classof(const Value *V) {
-    return isa<Type>(V) && classof(cast<const Type>(V));
+    return isa<Type>(V) && classof(cast<Type>(V));
   }
 };
 
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index ae394df..a06a4b7 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -242,7 +242,7 @@
     }
 
     D.destroy();  // Free old strdup'd memory...
-    return cast<const Type>(N);
+    return cast<Type>(N);
   }
   default:
     ThrowException("Internal parser error: Invalid symbol type reference!");
@@ -506,7 +506,7 @@
   if (Existing) {    // Inserting a name that is already defined???
     // There is only one case where this is allowed: when we are refining an
     // opaque type.  In this case, Existing will be an opaque type.
-    if (const Type *Ty = dyn_cast<const Type>(Existing)) {
+    if (const Type *Ty = dyn_cast<Type>(Existing)) {
       if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Ty)) {
 	// We ARE replacing an opaque type!
 	((OpaqueType*)OpTy)->refineAbstractTypeTo(cast<Type>(V));
@@ -519,7 +519,7 @@
     if (const Type *Ty = dyn_cast<Type>(Existing)) {
       if (Ty == cast<Type>(V)) return true;  // Yes, it's equal.
       // std::cerr << "Type: " << Ty->getDescription() << " != "
-      //      << cast<const Type>(V)->getDescription() << "!\n";
+      //      << cast<Type>(V)->getDescription() << "!\n";
     } else if (const Constant *C = dyn_cast<Constant>(Existing)) {
       if (C == V) return true;      // Constants are equal to themselves
     } else if (GlobalVariable *EGV = dyn_cast<GlobalVariable>(Existing)) {
@@ -875,7 +875,7 @@
 // ResolvedVal, ValueRef and ConstValueRef productions.
 //
 ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
-    const ArrayType *ATy = dyn_cast<const ArrayType>($1->get());
+    const ArrayType *ATy = dyn_cast<ArrayType>($1->get());
     if (ATy == 0)
       ThrowException("Cannot make array constant with type: '" + 
                      (*$1)->getDescription() + "'!");
@@ -900,7 +900,7 @@
     delete $1; delete $3;
   }
   | Types '[' ']' {
-    const ArrayType *ATy = dyn_cast<const ArrayType>($1->get());
+    const ArrayType *ATy = dyn_cast<ArrayType>($1->get());
     if (ATy == 0)
       ThrowException("Cannot make array constant with type: '" + 
                      (*$1)->getDescription() + "'!");
@@ -913,7 +913,7 @@
     delete $1;
   }
   | Types 'c' STRINGCONSTANT {
-    const ArrayType *ATy = dyn_cast<const ArrayType>($1->get());
+    const ArrayType *ATy = dyn_cast<ArrayType>($1->get());
     if (ATy == 0)
       ThrowException("Cannot make array constant with type: '" + 
                      (*$1)->getDescription() + "'!");
@@ -941,7 +941,7 @@
     delete $1;
   }
   | Types '{' ConstVector '}' {
-    const StructType *STy = dyn_cast<const StructType>($1->get());
+    const StructType *STy = dyn_cast<StructType>($1->get());
     if (STy == 0)
       ThrowException("Cannot make struct constant with type: '" + 
                      (*$1)->getDescription() + "'!");
@@ -961,7 +961,7 @@
     delete $1; delete $3;
   }
   | Types '{' '}' {
-    const StructType *STy = dyn_cast<const StructType>($1->get());
+    const StructType *STy = dyn_cast<StructType>($1->get());
     if (STy == 0)
       ThrowException("Cannot make struct constant with type: '" + 
                      (*$1)->getDescription() + "'!");
@@ -973,7 +973,7 @@
     delete $1;
   }
   | Types NULL_TOK {
-    const PointerType *PTy = dyn_cast<const PointerType>($1->get());
+    const PointerType *PTy = dyn_cast<PointerType>($1->get());
     if (PTy == 0)
       ThrowException("Cannot make null pointer constant with type: '" + 
                      (*$1)->getDescription() + "'!");
@@ -982,7 +982,7 @@
     delete $1;
   }
   | Types SymbolicValueRef {
-    const PointerType *Ty = dyn_cast<const PointerType>($1->get());
+    const PointerType *Ty = dyn_cast<PointerType>($1->get());
     if (Ty == 0)
       ThrowException("Global const reference must be a pointer type!");
 
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index 8877fe3..d52e5a6 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -277,7 +277,7 @@
     abort();
 
   case Type::ArrayTyID: {
-    const ArrayType *AT = cast<const ArrayType>(Ty);
+    const ArrayType *AT = cast<ArrayType>(Ty);
     unsigned NumElements = AT->getNumElements();
 
     std::vector<Constant*> Elements;
@@ -310,7 +310,7 @@
   }    
 
   case Type::PointerTyID: {
-    const PointerType *PT = cast<const PointerType>(Ty);
+    const PointerType *PT = cast<PointerType>(Ty);
     unsigned SubClass;
     if (HasImplicitZeroInitializer)
       SubClass = 1;
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index c9560c1..005c5c1 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -262,7 +262,7 @@
     }
 
   // If it's a type, make sure that all subtypes of the type are included...
-  if (const Type *TheTy = dyn_cast<const Type>(D)) {
+  if (const Type *TheTy = dyn_cast<Type>(D)) {
 
     // Insert the current type before any subtypes.  This is important because
     // recursive types elements are inserted in a bottom up order.  Changing
diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
index 019d447..1094a48 100644
--- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
+++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
@@ -413,7 +413,7 @@
         const Value *Val = mop.getVRegValue();
         assert(Val && "\tNULL Value in SparcFunctionAsmPrinter");
         
-        if (const BasicBlock *BB = dyn_cast<const BasicBlock>(Val))
+        if (const BasicBlock *BB = dyn_cast<BasicBlock>(Val))
           toAsm << getID(BB);
         else if (const Function *M = dyn_cast<Function>(Val))
           toAsm << getID(M);
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index 8aa1851..e86e51f 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -69,10 +69,10 @@
 				      void *D) {
   const TargetData &TD = *(const TargetData*)D;
   assert(AID == TD.AID && "Target data annotation ID mismatch!");
-  const Type *Ty = cast<const Type>((const Value *)T);
+  const Type *Ty = cast<Type>((const Value *)T);
   assert(isa<StructType>(Ty) && 
 	 "Can only create StructLayout annotation on structs!");
-  return new StructLayout((const StructType *)Ty, TD);
+  return new StructLayout(cast<StructType>(Ty), TD);
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 545349a..2ebce72 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -36,29 +36,29 @@
                                    SlotCalculator *Table);
 
 static const Module *getModuleFromVal(const Value *V) {
-  if (const Argument *MA = dyn_cast<const Argument>(V))
+  if (const Argument *MA = dyn_cast<Argument>(V))
     return MA->getParent() ? MA->getParent()->getParent() : 0;
-  else if (const BasicBlock *BB = dyn_cast<const BasicBlock>(V))
+  else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V))
     return BB->getParent() ? BB->getParent()->getParent() : 0;
-  else if (const Instruction *I = dyn_cast<const Instruction>(V)) {
+  else if (const Instruction *I = dyn_cast<Instruction>(V)) {
     const Function *M = I->getParent() ? I->getParent()->getParent() : 0;
     return M ? M->getParent() : 0;
-  } else if (const GlobalValue *GV = dyn_cast<const GlobalValue>(V))
+  } else if (const GlobalValue *GV = dyn_cast<GlobalValue>(V))
     return GV->getParent();
   return 0;
 }
 
 static SlotCalculator *createSlotCalculator(const Value *V) {
   assert(!isa<Type>(V) && "Can't create an SC for a type!");
-  if (const Argument *FA = dyn_cast<const Argument>(V)) {
+  if (const Argument *FA = dyn_cast<Argument>(V)) {
     return new SlotCalculator(FA->getParent(), true);
-  } else if (const Instruction *I = dyn_cast<const Instruction>(V)) {
+  } else if (const Instruction *I = dyn_cast<Instruction>(V)) {
     return new SlotCalculator(I->getParent()->getParent(), true);
-  } else if (const BasicBlock *BB = dyn_cast<const BasicBlock>(V)) {
+  } else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
     return new SlotCalculator(BB->getParent(), true);
-  } else if (const GlobalVariable *GV = dyn_cast<const GlobalVariable>(V)){
+  } else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)){
     return new SlotCalculator(GV->getParent(), true);
-  } else if (const Function *Func = dyn_cast<const Function>(V)) {
+  } else if (const Function *Func = dyn_cast<Function>(V)) {
     return new SlotCalculator(Func, true);
   }
   return 0;
@@ -79,7 +79,7 @@
       // As a heuristic, don't insert pointer to primitive types, because
       // they are used too often to have a single useful name.
       //
-      const Type *Ty = cast<const Type>(I->second);
+      const Type *Ty = cast<Type>(I->second);
       if (!isa<PointerType>(Ty) ||
           !cast<PointerType>(Ty)->getElementType()->isPrimitiveType())
         TypeNames.insert(std::make_pair(Ty, "%"+I->first));
@@ -114,7 +114,7 @@
   std::string Result;
   switch (Ty->getPrimitiveID()) {
   case Type::FunctionTyID: {
-    const FunctionType *FTy = cast<const FunctionType>(Ty);
+    const FunctionType *FTy = cast<FunctionType>(Ty);
     Result = calcTypeName(FTy->getReturnType(), TypeStack, TypeNames) + " (";
     for (FunctionType::ParamTypes::const_iterator
            I = FTy->getParamTypes().begin(),
@@ -131,7 +131,7 @@
     break;
   }
   case Type::StructTyID: {
-    const StructType *STy = cast<const StructType>(Ty);
+    const StructType *STy = cast<StructType>(Ty);
     Result = "{ ";
     for (StructType::ElementTypes::const_iterator
            I = STy->getElementTypes().begin(),
@@ -144,11 +144,11 @@
     break;
   }
   case Type::PointerTyID:
-    Result = calcTypeName(cast<const PointerType>(Ty)->getElementType(), 
+    Result = calcTypeName(cast<PointerType>(Ty)->getElementType(), 
                           TypeStack, TypeNames) + "*";
     break;
   case Type::ArrayTyID: {
-    const ArrayType *ATy = cast<const ArrayType>(Ty);
+    const ArrayType *ATy = cast<ArrayType>(Ty);
     Result = "[" + utostr(ATy->getNumElements()) + " x ";
     Result += calcTypeName(ATy->getElementType(), TypeStack, TypeNames) + "]";
     break;
@@ -377,14 +377,14 @@
   if (PrintName && V->hasName()) {
     Out << "%" << V->getName();
   } else {
-    if (const Constant *CV = dyn_cast<const Constant>(V)) {
+    if (const Constant *CV = dyn_cast<Constant>(V)) {
       WriteConstantInt(Out, CV, PrintName, TypeTable, Table);
     } else {
       int Slot;
       if (Table) {
 	Slot = Table->getValSlot(V);
       } else {
-        if (const Type *Ty = dyn_cast<const Type>(V)) {
+        if (const Type *Ty = dyn_cast<Type>(V)) {
           Out << Ty->getDescription();
           return;
         }
@@ -580,9 +580,9 @@
     
     for (; I != End; ++I) {
       const Value *V = I->second;
-      if (const Constant *CPV = dyn_cast<const Constant>(V)) {
+      if (const Constant *CPV = dyn_cast<Constant>(V)) {
 	printConstant(CPV);
-      } else if (const Type *Ty = dyn_cast<const Type>(V)) {
+      } else if (const Type *Ty = dyn_cast<Type>(V)) {
 	Out << "\t%" << I->first << " = type ";
 
         // Make sure we print out at least one level of the type structure, so
@@ -959,7 +959,7 @@
   switch (V->getValueType()) {
   case Value::ConstantVal:
   case Value::ArgumentVal:       AW->writeOperand(V, true, true); break;
-  case Value::TypeVal:           AW->write(cast<const Type>(V)); break;
+  case Value::TypeVal:           AW->write(cast<Type>(V)); break;
   case Value::InstructionVal:    AW->write(cast<Instruction>(V)); break;
   case Value::BasicBlockVal:     AW->write(cast<BasicBlock>(V)); break;
   case Value::FunctionVal:       AW->write(cast<Function>(V)); break;
diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp
index c9560c1..005c5c1 100644
--- a/lib/VMCore/SlotCalculator.cpp
+++ b/lib/VMCore/SlotCalculator.cpp
@@ -262,7 +262,7 @@
     }
 
   // If it's a type, make sure that all subtypes of the type are included...
-  if (const Type *TheTy = dyn_cast<const Type>(D)) {
+  if (const Type *TheTy = dyn_cast<Type>(D)) {
 
     // Insert the current type before any subtypes.  This is important because
     // recursive types elements are inserted in a bottom up order.  Changing
diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp
index 12c8798..ddd769d 100644
--- a/lib/VMCore/SymbolTable.cpp
+++ b/lib/VMCore/SymbolTable.cpp
@@ -19,7 +19,7 @@
   if (TyPlane != end()) {
     VarMap &TyP = TyPlane->second;
     for (VarMap::iterator I = TyP.begin(), E = TyP.end(); I != E; ++I) {
-      const Type *Ty = cast<const Type>(I->second);
+      const Type *Ty = cast<Type>(I->second);
       if (Ty->isAbstract())   // If abstract, drop the reference...
 	cast<DerivedType>(Ty)->removeAbstractTypeUser(this);
     }
@@ -122,7 +122,7 @@
   // If we are removing an abstract type, remove the symbol table from it's use
   // list...
   if (Ty == Type::TypeTy) {
-    const Type *T = cast<const Type>(Result);
+    const Type *T = cast<Type>(Result);
     if (T->isAbstract()) {
 #if DEBUG_ABSTYPE
       std::cerr << "Removing abs type from symtab" << T->getDescription()<<"\n";
@@ -179,7 +179,7 @@
 
   // If we are adding an abstract type, add the symbol table to it's use list.
   if (VTy == Type::TypeTy) {
-    const Type *T = cast<const Type>(V);
+    const Type *T = cast<Type>(V);
     if (T->isAbstract()) {
       cast<DerivedType>(T)->addAbstractTypeUser(this);
 #if DEBUG_ABSTYPE
@@ -311,7 +311,7 @@
 #if DEBUG_ABSTYPE
           std::cerr << "Added type " << NewType->getDescription() << "\n";
 #endif
-          cast<const DerivedType>(NewType)->addAbstractTypeUser(this);
+          cast<DerivedType>(NewType)->addAbstractTypeUser(this);
         }
       }
   }
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 28ed4f3..d74433a 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -293,7 +293,7 @@
       
       switch (Ty->getPrimitiveID()) {
       case Type::FunctionTyID: {
-	const FunctionType *MTy = cast<const FunctionType>(Ty);
+	const FunctionType *MTy = cast<FunctionType>(Ty);
 	Result = getTypeProps(MTy->getReturnType(), TypeStack,
 			      isAbstract, isRecursive)+" (";
 	for (FunctionType::ParamTypes::const_iterator
@@ -311,7 +311,7 @@
 	break;
       }
       case Type::StructTyID: {
-	const StructType *STy = cast<const StructType>(Ty);
+	const StructType *STy = cast<StructType>(Ty);
 	Result = "{ ";
 	for (StructType::ElementTypes::const_iterator
 	       I = STy->getElementTypes().begin(),
@@ -324,13 +324,13 @@
 	break;
       }
       case Type::PointerTyID: {
-	const PointerType *PTy = cast<const PointerType>(Ty);
+	const PointerType *PTy = cast<PointerType>(Ty);
 	Result = getTypeProps(PTy->getElementType(), TypeStack,
 			      isAbstract, isRecursive) + " *";
 	break;
       }
       case Type::ArrayTyID: {
-	const ArrayType *ATy = cast<const ArrayType>(Ty);
+	const ArrayType *ATy = cast<ArrayType>(Ty);
 	unsigned NumElements = ATy->getNumElements();
 	Result = "[";
 	Result += utostr(NumElements) + " x ";
@@ -400,10 +400,10 @@
   // algorithm is the fact that arraytypes have sizes that differentiates types,
   // and that method types can be varargs or not.  Consider this now.
   if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
-    if (ATy->getNumElements() != cast<const ArrayType>(Ty2)->getNumElements())
+    if (ATy->getNumElements() != cast<ArrayType>(Ty2)->getNumElements())
       return false;
   } else if (const FunctionType *MTy = dyn_cast<FunctionType>(Ty)) {
-    if (MTy->isVarArg() != cast<const FunctionType>(Ty2)->isVarArg())
+    if (MTy->isVarArg() != cast<FunctionType>(Ty2)->isVarArg())
       return false;
   }