Remove redundant const qualifiers from cast<> expressions

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7253 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-07-23 15:30:06 +00:00
parent c07736a397
commit 949a362802
11 changed files with 54 additions and 54 deletions

View File

@ -76,13 +76,13 @@ public:
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!");

View File

@ -139,7 +139,7 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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));
}
};

View File

@ -242,7 +242,7 @@ static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
}
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 @@ static bool setValueName(Value *V, char *NameStr) {
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 @@ static bool setValueName(Value *V, char *NameStr) {
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 @@ ArgTypeListI : TypeListI
// 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 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
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 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
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 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
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 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
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 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
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 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
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!");

View File

@ -277,7 +277,7 @@ bool BytecodeParser::parseConstantValue(const unsigned char *&Buf,
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 @@ bool BytecodeParser::parseConstantValue(const unsigned char *&Buf,
}
case Type::PointerTyID: {
const PointerType *PT = cast<const PointerType>(Ty);
const PointerType *PT = cast<PointerType>(Ty);
unsigned SubClass;
if (HasImplicitZeroInitializer)
SubClass = 1;

View File

@ -262,7 +262,7 @@ int SlotCalculator::insertVal(const Value *D, bool dontIgnore) {
}
// 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

View File

@ -413,7 +413,7 @@ SparcFunctionAsmPrinter::printOneOperand(const MachineOperand &mop,
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);

View File

@ -69,10 +69,10 @@ Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T,
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);
}
//===----------------------------------------------------------------------===//

View File

@ -36,29 +36,29 @@ static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
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 @@ static void fillTypeNameTable(const Module *M,
// 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 @@ static std::string calcTypeName(const Type *Ty,
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 @@ static std::string calcTypeName(const Type *Ty,
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 @@ static std::string calcTypeName(const Type *Ty,
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 @@ static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
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 @@ void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
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 @@ CachedWriter &CachedWriter::operator<<(const Value *V) {
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;

View File

@ -262,7 +262,7 @@ int SlotCalculator::insertVal(const Value *D, bool dontIgnore) {
}
// 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

View File

@ -19,7 +19,7 @@ SymbolTable::~SymbolTable() {
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 @@ Value *SymbolTable::removeEntry(iterator Plane, type_iterator Entry) {
// 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 @@ void SymbolTable::insertEntry(const std::string &Name, const Type *VTy,
// 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 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType,
#if DEBUG_ABSTYPE
std::cerr << "Added type " << NewType->getDescription() << "\n";
#endif
cast<const DerivedType>(NewType)->addAbstractTypeUser(this);
cast<DerivedType>(NewType)->addAbstractTypeUser(this);
}
}
}

View File

@ -293,7 +293,7 @@ static std::string getTypeProps(const Type *Ty,
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 @@ static std::string getTypeProps(const Type *Ty,
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 @@ static std::string getTypeProps(const Type *Ty,
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 @@ static bool TypesEqual(const Type *Ty, const Type *Ty2,
// 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;
}